Skip to content

Commit

Permalink
Merge pull request #5366 from akoreman/doc_tooltip_fix
Browse files Browse the repository at this point in the history
Fixes bug where the completion doc tooltip would not be filtered properly because it would get the data from the popup before it was updated.
  • Loading branch information
akoreman authored Oct 23, 2023
2 parents c8379be + a33e3ba commit 5c447e3
Show file tree
Hide file tree
Showing 2 changed files with 55 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 @@ -464,7 +464,7 @@ class Autocomplete {

updateDocTooltip() {
var popup = this.popup;
var all = popup.data;
var all = this.completions.filtered;
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
var doc = null;
if (!selected || !this.editor || !this.popup.isOpen)
Expand Down
54 changes: 54 additions & 0 deletions src/autocomplete_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,60 @@ module.exports = {
}, 10);
}
},
"test: completers tooltip filtering": function (done) {
var editor = initEditor("");
var firstDoc = "First tooltip";
var secondDoc = "Second tooltip";
editor.completers = [
{
getCompletions: function (editor, session, pos, prefix, callback) {
var completions = [
{
caption: "case",
value: "case"
}, {
caption: "catch",
value: "catch"
}
];
callback(null, completions);
},
getDocTooltip: function (item) {
if (item.value === 'case') {
item.docHTML = firstDoc;
}
if (item.value === 'catch') {
item.docHTML = secondDoc;
}
}
}
];

sendKey("ca");
var popup = editor.completer.popup;

check(function() {
assert.equal(popup.data.length, 2);
assert.equal(popup.container.lastChild.innerHTML, firstDoc);

sendKey("t");

check(function() {
assert.equal(popup.data.length, 1);
assert.equal(popup.container.lastChild.innerHTML, secondDoc);

editor.destroy();
editor.container.remove();
done();
});
});

function check(callback) {
setTimeout(function wait() {
callback();
}, 10);
}
},
"test: slow and fast completers": function(done) {
var syncCompleter={
getCompletions: function(editor, session, pos, prefix, callback) {
Expand Down

0 comments on commit 5c447e3

Please sign in to comment.