Update src/editor/autocomplete to correctly call countCompletions and moveSelection

This commit is contained in:
Pierre Boyer 2019-06-04 13:21:39 +02:00
parent 97d4d1b73a
commit ed6427571e

View file

@ -42,31 +42,19 @@ export default class AutocompleteWrapperModel {
async onTab(e) {
const acComponent = this._getAutocompleterComponent();
if (acComponent.state.completionList.length === 0) {
if (acComponent.countCompletions() === 0) {
// Force completions to show for the text currently entered
await acComponent.forceComplete();
// Select the first item by moving "down"
await acComponent.onDownArrow();
await acComponent.moveSelection(+1);
} else {
if (e.shiftKey) {
await acComponent.onUpArrow();
} else {
await acComponent.onDownArrow();
}
await acComponent.moveSelection(e.shiftKey ? -1 : +1);
}
this._updateCallback({
close: true,
});
}
onUpArrow() {
this._getAutocompleterComponent().onUpArrow();
}
onDownArrow() {
this._getAutocompleterComponent().onDownArrow();
}
onPartUpdate(part, offset) {
// cache the typed value and caret here
// so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text)