Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/symbols-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class SymbolsView extends SelectListView
# Remove leading /^ and trailing $/
pattern = tag.pattern?.replace(/(^^\/\^)|(\$\/$)/g, '').trim()

# `ctags -excmd=number`, giving line numbers instead of patterns to locate
# symbols. The line number is being interpreted as a pattern by node-ctags
if not isNaN(pattern) and tag.lineNumber is parseInt(pattern)
return new Point(tag.lineNumber - 1, 0)

return unless pattern
file = path.join(tag.directory, tag.file)
return unless fs.isFileSync(file)
Expand Down
11 changes: 11 additions & 0 deletions spec/fixtures/js-excmd-number/sorry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function saySorry() {
return "I'm sorry";
}

var isItTooLate = saySorry();

var didIletYouDown = true;

function redeemOhReedeem() {
return !didIletYouDown;
}
9 changes: 9 additions & 0 deletions spec/fixtures/js-excmd-number/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /[email protected]/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
didIletYouDown sorry.js 7;" v
redeemOhReedeem sorry.js 9;" f
saySorry sorry.js 1;" f
19 changes: 19 additions & 0 deletions spec/symbols-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ describe "SymbolsView", ->
expect(atom.workspace.getActiveTextEditor().getPath()).toBe directory.resolve("tagged-duplicate.js")
expect(atom.workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [0, 4]

it "moves the cursor to the declaration if the tags are numbered instead of patterned", ->
atom.project.setPaths([temp.mkdirSync("atom-symbols-view-js-excmd-number-")])
fs.copySync(path.join(__dirname, "fixtures", "js-excmd-number"), atom.project.getPaths()[0])

waitsForPromise ->
atom.workspace.open "sorry.js"

runs ->
editor = atom.workspace.getActiveTextEditor()
editor.setCursorBufferPosition([9, 16])
spyOn(SymbolsView.prototype, "moveToPosition").andCallThrough()
atom.commands.dispatch(getEditorView(), 'symbols-view:go-to-declaration')

waitsFor ->
SymbolsView::moveToPosition.callCount is 1

runs ->
expect(editor.getCursorBufferPosition()).toEqual [6, 0]

it "includes ? and ! characters in ruby symbols", ->
atom.project.setPaths([temp.mkdirSync("atom-symbols-view-ruby-")])
fs.copySync(path.join(__dirname, 'fixtures', 'ruby'), atom.project.getPaths()[0])
Expand Down