Skip to content

Commit

Permalink
Add preventRedraw in expandItems
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Nov 14, 2024
1 parent 3864343 commit 6a9b079
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,12 @@ export class Ddu {
async expandItems(
denops: Denops,
items: ExpandItem[],
opts?: { signal?: AbortSignal },
opts?: {
preventRedraw?: boolean;
signal?: AbortSignal;
},
): Promise<void> {
const { signal = this.#aborter.signal } = opts ?? {};
const { preventRedraw, signal = this.#aborter.signal } = opts ?? {};
for (const item of items.sort((a, b) => a.item.__level - b.item.__level)) {
const maxLevel = item.maxLevel && item.maxLevel < 0
? -1
Expand All @@ -1121,7 +1124,9 @@ export class Ddu {
);
}

await this.uiRedraw(denops, { signal });
if (!preventRedraw && !signal.aborted) {
await this.uiRedraw(denops, { signal });
}
}

async expandItem(
Expand Down Expand Up @@ -1719,6 +1724,10 @@ export class Ddu {

async restoreTree(
denops: Denops,
opts?: {
preventRedraw?: boolean;
signal?: AbortSignal;
},
): Promise<void> {
// NOTE: Check expandedItems are exists in this.#items
const checkItems: Map<string, DduItem> = new Map();
Expand All @@ -1734,7 +1743,7 @@ export class Ddu {
return;
}

await this.expandItems(denops, restoreItems);
await this.expandItems(denops, restoreItems, opts);
}

async #filterItems(
Expand Down

0 comments on commit 6a9b079

Please sign in to comment.