Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Completion Blocked by incomplete Item #5029

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/completion/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,10 @@ export default class Complete {
return added
}

public async completeInComplete(resumeInput: string): Promise<DurationCompleteItem[] | undefined> {
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, {
Expand All @@ -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)
hexh250786313 marked this conversation as resolved.
Show resolved Hide resolved
}

public filterItems(input: string): DurationCompleteItem[] | undefined {
Expand Down Expand Up @@ -322,7 +318,7 @@ export default class Complete {
public async filterResults(input: string): Promise<DurationCompleteItem[] | undefined> {
clearTimeout(this.timer)
if (input !== this.option.input && this.hasInComplete) {
return await this.completeInComplete(input)
void this.completeInComplete(input)
}
return this.filterItems(input)
}
Expand Down
2 changes: 1 addition & 1 deletion src/completion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/completion/pum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down