Skip to content

Commit

Permalink
Merge pull request #5418 from akoreman/loading_fix
Browse files Browse the repository at this point in the history
fix: don't show loading state when empty completer array is provided
  • Loading branch information
akoreman authored Dec 11, 2023
2 parents c6475c0 + 7e08bf5 commit ef29ada
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Autocomplete {

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

this.completions = new FilteredList(Autocomplete.completionsForLoading);
this.openPopup(this.editor, initialPosition.prefix, false);
Expand Down
13 changes: 13 additions & 0 deletions src/autocomplete_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,19 @@ module.exports = {

done();
}, 100);
},
"test: should not show loading state when empty completer array is provided": function(done) {
var editor = initEditor("");
editor.completers = [];
var completer = Autocomplete.for(editor);
completer.showLoadingState = true;

user.type("Ctrl-Space");

// Tooltip should not be open
assert.ok(!(completer.popup && completer.popup.isOpen));

done();
}
};

Expand Down

0 comments on commit ef29ada

Please sign in to comment.