Skip to content

Commit ef29ada

Browse files
authored
Merge pull request #5418 from akoreman/loading_fix
fix: don't show loading state when empty completer array is provided
2 parents c6475c0 + 7e08bf5 commit ef29ada

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Autocomplete {
112112

113113
this.$firstOpenTimer = lang.delayedCall(/**@this{Autocomplete}*/function() {
114114
var initialPosition = this.completionProvider && this.completionProvider.initialPosition;
115-
if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition) return;
115+
if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition || this.editor.completers.length === 0) return;
116116

117117
this.completions = new FilteredList(Autocomplete.completionsForLoading);
118118
this.openPopup(this.editor, initialPosition.prefix, false);

src/autocomplete_test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,19 @@ module.exports = {
13281328

13291329
done();
13301330
}, 100);
1331+
},
1332+
"test: should not show loading state when empty completer array is provided": function(done) {
1333+
var editor = initEditor("");
1334+
editor.completers = [];
1335+
var completer = Autocomplete.for(editor);
1336+
completer.showLoadingState = true;
1337+
1338+
user.type("Ctrl-Space");
1339+
1340+
// Tooltip should not be open
1341+
assert.ok(!(completer.popup && completer.popup.isOpen));
1342+
1343+
done();
13311344
}
13321345
};
13331346

0 commit comments

Comments
 (0)