Skip to content

Commit 0fc90f2

Browse files
committed
1 parent a211ea3 commit 0fc90f2

File tree

6 files changed

+126
-37
lines changed

6 files changed

+126
-37
lines changed

dist/main/atom/autoCompleteProvider.js

Lines changed: 25 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/atom/autoCompleteProvider.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/lang/projectService.js

Lines changed: 28 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main/lang/projectService.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main/atom/autoCompleteProvider.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export function triggerAutocompletePlus() {
7272
'autocomplete-plus:activate');
7373
}
7474

75+
var pendingActivation = false;
76+
function delayTriggerAutocompletePlus() {
77+
if (pendingActivation) return;
78+
pendingActivation = true;
79+
setTimeout(() => {
80+
triggerAutocompletePlus();
81+
pendingActivation = false;
82+
}, 50);
83+
}
7584

7685

7786
// the structure stored in the CSON snippet file
@@ -132,6 +141,7 @@ export var provider: autocompleteplus.Provider = {
132141
var pathMatchers = ['reference.path.string', 'require.path.string'];
133142
var lastScope = options.scopeDescriptor.scopes[options.scopeDescriptor.scopes.length - 1];
134143

144+
// For file path completions
135145
if (pathMatchers.some(p=> lastScope === p)) {
136146
return parent.getRelativePathsInProject({ filePath, prefix: options.prefix })
137147
.then((resp) => {
@@ -171,12 +181,26 @@ export var provider: autocompleteplus.Provider = {
171181
})
172182
.then((resp) => {
173183
var completionList = resp.completions;
174-
var suggestions = completionList.map((c):autocompleteplus.Suggestion => {
175-
return {
176-
text: c.name,
177-
replacementPrefix: resp.endsInPunctuation ? '' : options.prefix,
178-
rightLabelHTML: '<span style="color: ' + kindToColor(c.kind) + '">' + c.display + '</span>',
179-
};
184+
var suggestions = completionList.map((c): autocompleteplus.Suggestion => {
185+
186+
if (c.snippet) // currently only function completions are snippet
187+
{
188+
// TODO: remove once https://github.com/atom-community/autocomplete-plus/issues/329 is solved
189+
delayTriggerAutocompletePlus();
190+
191+
return {
192+
snippet: c.snippet,
193+
replacementPrefix: '',
194+
rightLabel: 'signature'
195+
};
196+
}
197+
else {
198+
return {
199+
text: c.name,
200+
replacementPrefix: resp.endsInPunctuation ? '' : options.prefix,
201+
rightLabelHTML: '<span style="color: ' + kindToColor(c.kind) + '">' + c.display + '</span>',
202+
};
203+
}
180204
});
181205

182206

@@ -185,7 +209,7 @@ export var provider: autocompleteplus.Provider = {
185209
// you only get the snippet suggested after you have typed
186210
// the full trigger word/ prefex
187211
// and then it replaces a keyword/match that might also be present, e.g. "class"
188-
let suggestion:autocompleteplus.Suggestion = {
212+
let suggestion: autocompleteplus.Suggestion = {
189213
snippet: tsSnipPrefixLookup[options.prefix].body,
190214
replacementPrefix: options.prefix,
191215
rightLabelHTML: "snippet: " + options.prefix,

0 commit comments

Comments
 (0)