From 91d3c24d4cfc288d4c014f725464987040c257e4 Mon Sep 17 00:00:00 2001 From: hexh <250786313@qq.com> Date: Sun, 2 Jun 2024 20:25:18 +0800 Subject: [PATCH 1/2] feat: no block when whole completion panel when incomplete is true --- src/completion/complete.ts | 8 ++------ src/completion/index.ts | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) 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) From 7adbccbe8fa08a1c5031f62f8d2c6296f49e94b8 Mon Sep 17 00:00:00 2001 From: hexh <250786313@qq.com> Date: Mon, 3 Jun 2024 17:21:04 +0800 Subject: [PATCH 2/2] fix: completion pum not match the right item --- src/completion/pum.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 } }