Skip to content

Commit 39c75f4

Browse files
committed
remove autocomplete for snippets as it is a part of atom core
closes #566
1 parent e1660ba commit 39c75f4

File tree

2 files changed

+2
-82
lines changed

2 files changed

+2
-82
lines changed

dist/main/atom/autoCompleteProvider.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,9 @@ function triggerAutocompletePlus() {
1010
explicitlyTriggered = true;
1111
}
1212
exports.triggerAutocompletePlus = triggerAutocompletePlus;
13-
var tsSnipPrefixLookup = Object.create(null);
14-
function loadSnippets() {
15-
var confPath = atom.getConfigDirPath();
16-
CSON.readFile(confPath + "/packages/atom-typescript/snippets/typescript-snippets.cson", function (err, snippetsRoot) {
17-
if (err)
18-
return;
19-
if (!snippetsRoot || !snippetsRoot['.source.ts'])
20-
return;
21-
var tsSnippets = snippetsRoot['.source.ts'];
22-
for (var snippetName in tsSnippets) {
23-
if (tsSnippets.hasOwnProperty(snippetName)) {
24-
tsSnipPrefixLookup[tsSnippets[snippetName].prefix] = {
25-
body: tsSnippets[snippetName].body,
26-
name: snippetName
27-
};
28-
}
29-
}
30-
});
31-
}
32-
loadSnippets();
3313
exports.provider = {
3414
selector: '.source.ts',
35-
inclusionPriority: 3,
15+
inclusionPriority: 4,
3616
excludeLowerPriority: false,
3717
getSuggestions: function (options) {
3818
var filePath = options.editor.getPath();
@@ -114,15 +94,6 @@ exports.provider = {
11494
};
11595
}
11696
});
117-
if (tsSnipPrefixLookup[options.prefix]) {
118-
var suggestion = {
119-
snippet: tsSnipPrefixLookup[options.prefix].body,
120-
replacementPrefix: options.prefix,
121-
rightLabelHTML: "snippet: " + options.prefix,
122-
type: 'snippet'
123-
};
124-
suggestions.unshift(suggestion);
125-
}
12697
return suggestions;
12798
});
12899
return promisedSuggestions;

lib/main/atom/autoCompleteProvider.ts

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -77,45 +77,9 @@ interface SnippetsContianer {
7777
[name: string]: SnippetDescriptor;
7878
}
7979

80-
81-
// this is the structure we use to speed up the lookup by avoiding having to
82-
// iterate over the object properties during the requestHandler
83-
// this will take a little longer during load but I guess that is better than
84-
// taking longer at each key stroke
85-
interface SnippetDetail {
86-
body: string;
87-
name: string;
88-
}
89-
90-
var tsSnipPrefixLookup: { [prefix: string]: SnippetDetail; } = Object.create(null);
91-
function loadSnippets() {
92-
var confPath = atom.getConfigDirPath();
93-
CSON.readFile(confPath + "/packages/atom-typescript/snippets/typescript-snippets.cson",
94-
(err, snippetsRoot) => {
95-
if (err) return;
96-
if (!snippetsRoot || !snippetsRoot['.source.ts']) return;
97-
98-
// rearrange/invert the way this can be looked up: we want to lookup by prefix
99-
// this way the lookup gets faster because we dont have to iterate over the
100-
// properties of the object
101-
var tsSnippets: SnippetsContianer = snippetsRoot['.source.ts'];
102-
for (var snippetName in tsSnippets) {
103-
if (tsSnippets.hasOwnProperty(snippetName)) {
104-
// if the file contains a prefix multiple times only
105-
// the last will be active because the previous ones will be overwritten
106-
tsSnipPrefixLookup[tsSnippets[snippetName].prefix] = {
107-
body: tsSnippets[snippetName].body,
108-
name: snippetName
109-
}
110-
}
111-
}
112-
});
113-
}
114-
loadSnippets();
115-
11680
export var provider: autocompleteplus.Provider = {
11781
selector: '.source.ts',
118-
inclusionPriority: 3,
82+
inclusionPriority: 4,
11983
excludeLowerPriority: false,
12084
getSuggestions: (options: autocompleteplus.RequestOptions): Promise<autocompleteplus.Suggestion[]>=> {
12185

@@ -224,21 +188,6 @@ export var provider: autocompleteplus.Provider = {
224188
}
225189
});
226190

227-
228-
// see if we have a snippet for this prefix
229-
if (tsSnipPrefixLookup[options.prefix]) {
230-
// you only get the snippet suggested after you have typed
231-
// the full trigger word/ prefex
232-
// and then it replaces a keyword/match that might also be present, e.g. "class"
233-
let suggestion: autocompleteplus.Suggestion = {
234-
snippet: tsSnipPrefixLookup[options.prefix].body,
235-
replacementPrefix: options.prefix,
236-
rightLabelHTML: "snippet: " + options.prefix,
237-
type: 'snippet'
238-
};
239-
suggestions.unshift(suggestion);
240-
}
241-
242191
return suggestions;
243192
});
244193

0 commit comments

Comments
 (0)