Skip to content

Commit

Permalink
fix: don't show loading state when empty completer array is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
akoreman committed Dec 8, 2023
1 parent a7412b7 commit 7a8a929
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 @@ -111,7 +111,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 7a8a929

Please sign in to comment.