Skip to content

Commit

Permalink
fix(list): avoid unnecessary lines redraw
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Oct 15, 2022
1 parent 3da02fa commit 50c34f2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/list/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,18 @@ export default class Worker {
return
}
let called = false
const onFilter = (items: ListItemWithScore[], finished: boolean, sort?: boolean) => {
finished = finished && this._finished
let itemsToSort: ListItemWithScore[] = []
const onFilter = (items: ListItemWithScore[], done: boolean, sort?: boolean) => {
let finished = done && this._finished
if (token.isCancellationRequested || (!finished && items.length == 0)) return
let append = opts.append === true || called
called = true
this._onDidChangeItems.fire({ items, append, sorted: !sort, reload: opts.reload, finished })
if (sort) {
itemsToSort.push(...items)
if (done) this._onDidChangeItems.fire({ items: itemsToSort, append: false, sorted: false, reload: opts.reload, finished })
} else {
let append = opts.append === true || called
called = true
this._onDidChangeItems.fire({ items, append, sorted: true, reload: opts.reload, finished })
}
}
switch (this.listOptions.matcher) {
case 'strict':
Expand Down

0 comments on commit 50c34f2

Please sign in to comment.