Skip to content

Commit 7841603

Browse files
committed
use crag command param to parse line number
−−fields=[+|−]flags n Line number of tag definition
1 parent 0868504 commit 7841603

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

lib/file-view.coffee

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ class FileView extends SymbolsView
2727
@span pattern, class: 'pull-right'
2828

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

3433
toggle: ->
3534
if @hasParent()

lib/symbols-view.coffee

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{$$, SelectListView} = require 'atom'
2-
fs = require 'fs-plus'
2+
fs = null
33

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

3030
confirmed : (tag) ->
31+
if fs == null
32+
fs = require 'fs-plus'
33+
3134
if tag.file and not fs.isFileSync(atom.project.resolve(tag.file))
3235
@setError('Selected file does not exist')
3336
setTimeout((=> @setError()), 2000)
@@ -45,12 +48,6 @@ class SymbolsView extends SelectListView
4548

4649

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

5653
@stack.push(previous)

lib/tag-generator.coffee

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Q = require 'q'
33
path = require 'path'
44

5+
TAG_LINE = "line:"
6+
TAG_LINE_LENGTH = TAG_LINE.length
7+
58
module.exports =
69
class TagGenerator
710
constructor: (@path, @scopeName) ->
@@ -13,6 +16,18 @@ class TagGenerator
1316
name: sections.shift()
1417
file: sections.shift()
1518
}
19+
20+
i = sections.length - 1
21+
22+
while i >= 0
23+
row = sections[i]
24+
if row.indexOf(TAG_LINE) == 0
25+
row = row.substr(TAG_LINE_LENGTH) - 1
26+
break
27+
else
28+
row = -1
29+
--i
30+
1631
pattern = sections.join("\t")
1732

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

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

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

0 commit comments

Comments
 (0)