diff --git a/src/completion/complete.ts b/src/completion/complete.ts index c05b6431c52..d7f6f634f3e 100644 --- a/src/completion/complete.ts +++ b/src/completion/complete.ts @@ -241,11 +241,10 @@ export default class Complete { return added } - public async completeInComplete(resumeInput: string): Promise { + public async completeInComplete(resumeInput: string) { let { document } = this this.cancelInComplete() let tokenSource = this.createTokenSource(true) - let token = tokenSource.token await document.patchChange(true) let { input, colnr, linenr, followWord, position } = this.option Object.assign(this.option, { @@ -257,11 +256,8 @@ export default class Complete { triggerCharacter: undefined, triggerForInComplete: true }) - this.cid++ const sources = this.getIncompleteSources() await this.completeSources(sources, tokenSource, this.cid) - if (token.isCancellationRequested) return undefined - return this.filterItems(resumeInput) } public filterItems(input: string): DurationCompleteItem[] | undefined { @@ -322,7 +318,7 @@ export default class Complete { public async filterResults(input: string): Promise { clearTimeout(this.timer) if (input !== this.option.input && this.hasInComplete) { - return await this.completeInComplete(input) + void this.completeInComplete(input) } return this.filterItems(input) } diff --git a/src/completion/index.ts b/src/completion/index.ts index 00d91f03339..7b3abc2ec5e 100644 --- a/src/completion/index.ts +++ b/src/completion/index.ts @@ -76,7 +76,7 @@ export class Completion implements Disposable { if (!this.option) return this.popupEvent = ev let resolved = this.complete.resolveItem(this.selectedItem) - if (!resolved || (!ev.move && this.complete.isCompleting)) return + if (!resolved) return let detailRendered = this.selectedItem.detailRendered let showDocs = this.config.enableFloat await this.floating.resolveItem(resolved.source, resolved.item, this.option, showDocs, detailRendered) diff --git a/src/completion/pum.ts b/src/completion/pum.ts index cf8afe06b1d..68fc1bf3849 100644 --- a/src/completion/pum.ts +++ b/src/completion/pum.ts @@ -166,7 +166,9 @@ export default class PopupMenu { } if (selectedIndex !== -1 && search.length > 0) { let item = items[selectedIndex] - if (!item.word.startsWith(search)) { + // `word` and `filterText` may be different + // `search` may match `word` or `filterText` + if (!item.word.startsWith(search) && !item.filterText.startsWith(search)) { selectedIndex = -1 } }