diff --git a/lib/symbols-view.coffee b/lib/symbols-view.coffee index a26797d..dd25e7e 100644 --- a/lib/symbols-view.coffee +++ b/lib/symbols-view.coffee @@ -100,6 +100,10 @@ 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 + return new Point(tag.lineNumber - 1, 0) if tag.lineNumber is parseInt(pattern) + return unless pattern file = path.join(tag.directory, tag.file) return unless fs.isFileSync(file) diff --git a/spec/fixtures/js-excmd-number/sorry.js b/spec/fixtures/js-excmd-number/sorry.js new file mode 100644 index 0000000..adb42e1 --- /dev/null +++ b/spec/fixtures/js-excmd-number/sorry.js @@ -0,0 +1,11 @@ +function saySorry() { + return "I'm sorry"; +} + +var isItTooLate = saySorry(); + +var didIletYouDown = true; + +function redeemOhReedeem() { + return !didIletYouDown; +} diff --git a/spec/fixtures/js-excmd-number/tags b/spec/fixtures/js-excmd-number/tags new file mode 100644 index 0000000..42be080 --- /dev/null +++ b/spec/fixtures/js-excmd-number/tags @@ -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 /dhiebert@users.sourceforge.net/ +!_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 diff --git a/spec/symbols-view-spec.coffee b/spec/symbols-view-spec.coffee index a75599b..7f0a461 100644 --- a/spec/symbols-view-spec.coffee +++ b/spec/symbols-view-spec.coffee @@ -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])