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

perf: return early in around and buffer source #4721

Merged
merged 1 commit into from
Aug 8, 2023
Merged
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
9 changes: 5 additions & 4 deletions src/completion/native/around.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ export class Around extends Source {

public async doComplete(opt: CompleteOption, token: CancellationToken): Promise<CompleteResult<ExtendedCompleteItem>> {
let { bufnr, input, word, linenr, triggerForInComplete } = opt
if (input.length === 0) return null
let buf = this.keywords.getItem(bufnr)
if (!buf) return null
await waitImmediate()
if (!triggerForInComplete) this.noMatchWords = new Set()
if (input.length === 0 || !buf || token.isCancellationRequested) return null
if (token.isCancellationRequested) return null
let iterable = buf.matchWords(linenr - 1)
let items: Set<string> = new Set()
let isIncomplete = await this.getResults([iterable], input, word, items, token)
return {
isIncomplete, items: Array.from(items).map(s => {
return { word: s }
})
isIncomplete,
items: Array.from(items, word => ({ word }))
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/completion/native/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class Buffer extends Source {

public async doComplete(opt: CompleteOption, token: CancellationToken): Promise<CompleteResult<ExtendedCompleteItem>> {
let { bufnr, input, word, triggerForInComplete } = opt
if (input.length === 0) return null
await waitImmediate()
if (!triggerForInComplete) this.noMatchWords = new Set()
if (input.length === 0 || token.isCancellationRequested) return null
if (token.isCancellationRequested) return null
let iterables: Iterable<string>[] = []
for (let buf of this.keywords.items) {
if (buf.bufnr === bufnr || (this.ignoreGitignore && buf.gitIgnored)) continue
Expand Down
Loading