Skip to content

Commit

Permalink
Fix uiQuit() infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jul 5, 2024
1 parent d87fbf8 commit 6b9ef63
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 42 deletions.
64 changes: 24 additions & 40 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ export class Ddu {
}

if (checkToggle && uiOptions.toggle) {
await ui.quit({
await uiQuit(
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
ui.prevDone = false;
this.#loader,
this.#context,
this.#options,
);
this.quit();
return;
}
Expand Down Expand Up @@ -213,21 +211,19 @@ export class Ddu {
}

// NOTE: UI must be reset.
const [ui, uiOptions, uiParams] = await getUi(
const [ui, uiOptions, _] = await getUi(
denops,
this.#loader,
this.#options,
);

if (checkToggle && ui && uiOptions.toggle) {
await ui.quit({
await uiQuit(
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
ui.prevDone = false;
this.#loader,
this.#context,
this.#options,
);
this.quit();
return;
}
Expand Down Expand Up @@ -1026,32 +1022,14 @@ export class Ddu {
return;
}

const [ui, uiOptions, uiParams] = await getUi(
denops,
this.#loader,
this.#options,
);
if (ui) {
const visible = await ui.visible({
if (itemAction.actionOptions.quit) {
// Quit UI before action
await uiQuit(
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
tabNr: await fn.tabpagenr(denops),
});

if (itemAction.actionOptions.quit && visible) {
// Quit UI before action
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
ui.prevDone = false;
}
this.#loader,
this.#context,
this.#options,
);
}

const prevPath = itemAction.sourceOptions.path;
Expand Down Expand Up @@ -1123,6 +1101,12 @@ export class Ddu {

const winId = await fn.win_getid(denops);

const [ui, uiOptions, uiParams] = await getUi(
denops,
this.#loader,
this.#options,
);

if (flags & ActionFlags.RefreshItems) {
// Restore quitted flag before refresh and redraw
this.#resetQuitted();
Expand Down
16 changes: 14 additions & 2 deletions denops/ddu/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,14 +1008,26 @@ export async function uiQuit<
if (!ui) {
return;
}
await ui.quit({

const visible = await ui.visible({
denops,
context,
options,
uiOptions,
uiParams,
tabNr: await fn.tabpagenr(denops),
});
ui.prevDone = false;

if (visible) {
await ui.quit({
denops,
context,
options,
uiOptions,
uiParams,
});
ui.prevDone = false;
}
}

async function checkFilterOnInit(
Expand Down

0 comments on commit 6b9ef63

Please sign in to comment.