Skip to content

Commit cc4d6ca

Browse files
committed
fix(keymaps) stronger specifity of build and go to declaration commands
ref TypeStrong#145 closes TypeStrong#139
1 parent 0459ee7 commit cc4d6ca

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

keymaps/atom-typescript.cson

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
'atom-text-editor[data-grammar~=ts]':
22
'alt-cmd-l': 'typescript:format-code'
33
'alt-ctrl-l': 'typescript:format-code'
4-
'ctrl-shift-b': 'typescript:build'
5-
'cmd-shift-b': 'typescript:build'
6-
'ctrl-b': 'typescript:go-to-declaration'
7-
'cmd-b': 'typescript:go-to-declaration'
84
'ctrl-;': 'typescript:context-actions'
95
'cmd-;': 'typescript:context-actions'
106
'f2': 'typescript:rename-variable'
7+
8+
# Note that we are good citizens in our commands handling logic
9+
# we will gladly hand off the command to something else if a ts file is not active
10+
# That said :
11+
# These need to be *platform specific* + on *body* to increase specifity + we need to have a menu item for these
12+
# if we want them to override what atom has by default (find buffer / find modified file)
13+
'body.platform-win32, body.platform-linux':
14+
'ctrl-shift-b': 'typescript:build'
15+
'ctrl-b': 'typescript:go-to-declaration'
16+
'body.platform-darwin':
17+
'cmd-shift-b': 'typescript:build'
18+
'cmd-b': 'typescript:go-to-declaration'
19+

lib/main/atom/commands.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function registerCommands() {
3939
});
4040
}
4141
});
42-
atom.commands.add('atom-text-editor', 'typescript:build', function (e) {
42+
atom.commands.add('atom-workspace', 'typescript:build', function (e) {
4343
if (!commandForTypeScript(e))
4444
return;
4545
var editor = atom.workspace.getActiveTextEditor();
@@ -68,7 +68,7 @@ function registerCommands() {
6868
});
6969
});
7070
};
71-
atom.commands.add('atom-text-editor', 'typescript:go-to-declaration', handleGoToDeclaration);
71+
atom.commands.add('atom-workspace', 'typescript:go-to-declaration', handleGoToDeclaration);
7272
atom.commands.add('atom-text-editor', 'symbols-view:go-to-declaration', handleGoToDeclaration);
7373
atom.commands.add('atom-text-editor', 'typescript:context-actions', function (e) {
7474
atom.notifications.addSuccess('Context options coming soon!');

lib/main/atom/commands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function registerCommands() {
5252

5353
}
5454
});
55-
atom.commands.add('atom-text-editor', 'typescript:build',(e) => {
55+
atom.commands.add('atom-workspace', 'typescript:build',(e) => {
5656
if (!commandForTypeScript(e)) return;
5757

5858
var editor = atom.workspace.getActiveTextEditor();
@@ -91,7 +91,7 @@ export function registerCommands() {
9191
});
9292
};
9393

94-
atom.commands.add('atom-text-editor', 'typescript:go-to-declaration', handleGoToDeclaration);
94+
atom.commands.add('atom-workspace', 'typescript:go-to-declaration', handleGoToDeclaration);
9595
// This exists by default in the right click menu https://github.com/TypeStrong/atom-typescript/issues/96
9696
atom.commands.add('atom-text-editor', 'symbols-view:go-to-declaration', handleGoToDeclaration);
9797

lib/main/atom/views/mainPanelView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var MainPanelView = (function (_super) {
2929
}, text);
3030
};
3131
this.div({
32-
class: 'am-panel tool-panel panel-bottom native-key-bindings',
32+
class: 'am-panel tool-panel panel-bottom native-key-bindings atomts-main-panel',
3333
tabindex: '-1'
3434
}, function () {
3535
_this.div({

lib/main/atom/views/mainPanelView.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class MainPanelView extends view.View<any> {
2828
}, text);
2929

3030
this.div({
31-
class: 'am-panel tool-panel panel-bottom native-key-bindings',
31+
class: 'am-panel tool-panel panel-bottom native-key-bindings atomts-main-panel',
3232
tabindex: '-1'
3333
},() => {
3434
this.div({

menus/atomts-menus.cson

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See https://atom.io/docs/latest/creating-a-package#menus for more details
2+
'menu': [
3+
{
4+
'label': 'Packages'
5+
'submenu': [
6+
'label': 'TypeScript'
7+
'submenu': [
8+
{ 'label': 'Build', 'command': 'typescript:build' }
9+
{ 'label': 'Go To Declaration', 'command': 'typescript:go-to-declaration' }
10+
]
11+
]
12+
}
13+
]

0 commit comments

Comments
 (0)