Skip to content

Commit

Permalink
use crag command param to parse line number
Browse files Browse the repository at this point in the history
−−fields=[+|−]flags
n  Line number of tag definition
  • Loading branch information
yongkangchen committed Jul 6, 2014
1 parent 0868504 commit 7841603
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 2 additions & 3 deletions lib/file-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 4 additions & 7 deletions lib/symbols-view.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{$$, SelectListView} = require 'atom'
fs = require 'fs-plus'
fs = null

module.exports =
class SymbolsView extends SelectListView
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
19 changes: 17 additions & 2 deletions lib/tag-generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand All @@ -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 $/;
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down

1 comment on commit 7841603

@yongkangchen
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved #8

Please sign in to comment.