Skip to content

Commit 720f834

Browse files
committed
Prevent returning suggestions for files that aren't TypeScript
1 parent 0880857 commit 720f834

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

dist/hyperclickProvider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ var TS_GRAMMARS = immutable_1.Set(["source.ts", "source.tsx"]);
66
exports.providerName = "typescript-hyperclick-provider";
77
exports.wordRegExp = /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g;
88
function getSuggestionForWord(textEditor, text, range) {
9+
if (!TS_GRAMMARS.has(textEditor.getGrammar().scopeName)) {
10+
return null;
11+
}
912
return {
1013
range: range,
1114
callback: function () {
12-
if (!TS_GRAMMARS.has(textEditor.getGrammar().scopeName)) {
13-
return null;
14-
}
1515
var filePathPosition = {
1616
filePath: textEditor.getPath(),
1717
position: atomUtils.getEditorPositionForBufferPosition(textEditor, range.start)

lib/hyperclickProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export let providerName = "typescript-hyperclick-provider";
99
export let wordRegExp = /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g;
1010

1111
export function getSuggestionForWord(textEditor: AtomCore.IEditor, text: string, range: TextBuffer.IRange) {
12+
if (!TS_GRAMMARS.has(textEditor.getGrammar().scopeName)) {
13+
return null;
14+
}
15+
1216
return {
1317
range: range,
1418
callback() {
15-
if (!TS_GRAMMARS.has(textEditor.getGrammar().scopeName)) {
16-
return null;
17-
}
18-
1919
let filePathPosition = {
2020
filePath: textEditor.getPath(),
2121
position: atomUtils.getEditorPositionForBufferPosition(textEditor, range.start)

0 commit comments

Comments
 (0)