From aa606dfc7abf0c7b74e1eaad872b4970d90c71e3 Mon Sep 17 00:00:00 2001 From: Basarat Syed Date: Thu, 19 Feb 2015 10:27:26 +1100 Subject: [PATCH] feat : support goto declaration menu item closes #96 --- lib/main/atom/commands.js | 9 ++++++--- lib/main/atom/commands.ts | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/main/atom/commands.js b/lib/main/atom/commands.js index 915fa809d..1ff397784 100644 --- a/lib/main/atom/commands.js +++ b/lib/main/atom/commands.js @@ -46,12 +46,13 @@ function registerCommands() { buildView.setBuildOutput(resp.outputs); }); }); - atom.commands.add('atom-text-editor', 'typescript:go-to-declaration', function (e) { + var handleGoToDeclaration = function (e) { if (!commandForTypeScript(e)) return; var editor = atom.workspace.getActiveTextEditor(); var filePath = editor.getPath(); - parent.getDefinitionsAtPosition({ filePath: filePath, position: atomUtils.getEditorPosition(editor) }).then(function (res) { + var position = atomUtils.getEditorPosition(editor); + parent.getDefinitionsAtPosition({ filePath: filePath, position: position }).then(function (res) { var definitions = res.definitions; if (!definitions || !definitions.length) { atom.notifications.addInfo('AtomTS: No definition found.'); @@ -63,7 +64,9 @@ function registerCommands() { newWindow: false }); }); - }); + }; + atom.commands.add('atom-text-editor', 'typescript:go-to-declaration', handleGoToDeclaration); + atom.commands.add('atom-text-editor', 'symbols-view:go-to-declaration', handleGoToDeclaration); atom.commands.add('atom-text-editor', 'typescript:context-actions', function (e) { atom.notifications.addSuccess('Context options coming soon!'); }); diff --git a/lib/main/atom/commands.ts b/lib/main/atom/commands.ts index 958f0bfdf..e2a878841 100644 --- a/lib/main/atom/commands.ts +++ b/lib/main/atom/commands.ts @@ -58,12 +58,14 @@ export function registerCommands() { buildView.setBuildOutput(resp.outputs); }); }); - atom.commands.add('atom-text-editor', 'typescript:go-to-declaration',(e) => { + + var handleGoToDeclaration = (e) => { if (!commandForTypeScript(e)) return; var editor = atom.workspace.getActiveTextEditor(); var filePath = editor.getPath(); - parent.getDefinitionsAtPosition({ filePath: filePath, position: atomUtils.getEditorPosition(editor) }).then(res=> { + var position = atomUtils.getEditorPosition(editor); + parent.getDefinitionsAtPosition({ filePath: filePath, position: position }).then(res=> { var definitions = res.definitions; if (!definitions || !definitions.length) { atom.notifications.addInfo('AtomTS: No definition found.'); @@ -82,8 +84,11 @@ export function registerCommands() { newWindow: false }); }); - }); + }; + atom.commands.add('atom-text-editor', 'typescript:go-to-declaration', handleGoToDeclaration); + // This exists by default in the right click menu https://github.com/TypeStrong/atom-typescript/issues/96 + atom.commands.add('atom-text-editor', 'symbols-view:go-to-declaration', handleGoToDeclaration); atom.commands.add('atom-text-editor', 'typescript:context-actions',(e) => { atom.notifications.addSuccess('Context options coming soon!');