Skip to content

Commit

Permalink
Check expandedItems are exists in this.#items
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jun 2, 2024
1 parent 6143d17 commit a77be8b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ export class Ddu {

await this.refresh(denops);

if (searchPath.length > 0) {
if (searchPath.length <= 0) {
// NOTE: If searchPath exists, expandItems() is executed.
await this.restoreTree(denops);
}
Expand Down Expand Up @@ -1756,16 +1756,21 @@ export class Ddu {
async restoreTree(
denops: Denops,
): Promise<void> {
if (this.#expandedItems.size === 0) {
// NOTE: Check expandedItems are exists in this.#items
const checkItems: Map<string, DduItem> = new Map();
for (const item of this.#items) {
checkItems.set(item2Key(item), item);
}

const restoreItems = [...this.#expandedItems.values()].filter((item) =>
checkItems.has(item2Key(item))
).map((item) => ({ item }));

if (restoreItems.length === 0) {
return;
}

await this.expandItems(
denops,
[...this.#expandedItems.values()].map((item) => ({
item,
})),
);
await this.expandItems(denops, restoreItems);
}

async #filterItems(
Expand Down

0 comments on commit a77be8b

Please sign in to comment.