Skip to content
Permalink
Browse files

use crag command param to parse line number

−−fields=[+|−]flags
n  Line number of tag definition
  • Loading branch information...
yongkangchen committed Jul 6, 2014
1 parent 0868504 commit 784160320309212d0acf865092133ba55980c605
Showing with 23 additions and 12 deletions.
  1. +2 −3 lib/file-view.coffee
  2. +4 −7 lib/symbols-view.coffee
  3. +17 −2 lib/tag-generator.coffee
@@ -27,9 +27,8 @@ class FileView extends SymbolsView
@span pattern, class: 'pull-right'

@div class: 'secondary-line', =>
@span file, class: 'pull-left'
# @span "Line #{position.row + 1}", class: 'pull-left'
# @span file, class: 'pull-right'
@span "Line #{position.row + 1}", class: 'pull-left'
@span file, class: 'pull-right'

toggle: ->
if @hasParent()
@@ -1,5 +1,5 @@
{$$, SelectListView} = require 'atom'
fs = require 'fs-plus'
fs = null

module.exports =
class SymbolsView extends SelectListView
@@ -28,6 +28,9 @@ class SymbolsView extends SelectListView
super

confirmed : (tag) ->
if fs == null
fs = require 'fs-plus'

if tag.file and not fs.isFileSync(atom.project.resolve(tag.file))
@setError('Selected file does not exist')
setTimeout((=> @setError()), 2000)
@@ -45,12 +48,6 @@ class SymbolsView extends SelectListView


atom.workspaceView.open(tag.file).done =>
if position.row == -1
regex = new RegExp(tag.pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'))
atom.workspace.getActiveEditor().buffer.scan regex , (obj)=>
position.row = obj.range.start.row
obj.stop()

@moveToPosition(position) if position

@stack.push(previous)
@@ -2,6 +2,9 @@
Q = require 'q'
path = require 'path'

TAG_LINE = "line:"
TAG_LINE_LENGTH = TAG_LINE.length

module.exports =
class TagGenerator
constructor: (@path, @scopeName) ->
@@ -13,6 +16,18 @@ class TagGenerator
name: sections.shift()
file: sections.shift()
}

i = sections.length - 1

while i >= 0
row = sections[i]
if row.indexOf(TAG_LINE) == 0
row = row.substr(TAG_LINE_LENGTH) - 1
break
else
row = -1
--i

pattern = sections.join("\t")

#match /^ and trailing $/;
@@ -21,7 +36,7 @@ class TagGenerator
tag.pattern = pattern.match(/^\/\^(.*)(\/;")/)?[1]

if tag.pattern
tag.position = new Point(-1, tag.pattern.indexOf(tag.name))
tag.position = new Point(row, tag.pattern.indexOf(tag.name))
else
return null
return tag
@@ -58,7 +73,7 @@ class TagGenerator
deferred = Q.defer()
tags = []
command = path.resolve(__dirname, '..', 'vendor', "ctags-#{process.platform}")
args = ['--fields=+KS']
args = ['--fields=+KSn']

if atom.config.get('atom-ctags.useEditorGrammarAsCtagsLanguage')
if language = @getLanguage()

1 comment on commit 7841603

@yongkangchen

This comment has been minimized.

Copy link
Owner Author

commented on 7841603 Jul 6, 2014

resolved #8

Please sign in to comment.
You can’t perform that action at this time.