Skip to content

Commit

Permalink
Revert "Fix ui.quit()"
Browse files Browse the repository at this point in the history
This reverts commit 9064bc3.
  • Loading branch information
Shougo committed Jul 3, 2024
1 parent 85e5ba7 commit 8127ada
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 50 deletions.
4 changes: 2 additions & 2 deletions denops/ddu/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export const main: Entrypoint = (denops: Denops) => {
const ddu = getDdu(name);

if (event === "close" || event === "cancel") {
await ddu.quit(denops);
ddu.quit();
}

await ddu.onEvent(denops, event);
Expand All @@ -372,7 +372,7 @@ export const main: Entrypoint = (denops: Denops) => {

if (dduLength <= 1 || opt?.quit) {
// Quit current ddu
await currentDdu.quit(denops);
currentDdu.quit();
await currentDdu.onEvent(denops, "cancel");
return;
}
Expand Down
76 changes: 57 additions & 19 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
getUi,
initSource,
sourceArgs,
uiQuit,
uiRedraw,
uiSearchItem,
} from "./ext.ts";
Expand Down Expand Up @@ -113,7 +112,22 @@ export class Ddu {

if (uiChanged) {
// Quit current UI
await this.quit(denops);
const [ui, uiOptions, uiParams] = await getUi(
denops,
this.#loader,
this.#options,
);
if (!ui) {
return;
}
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
this.quit();
}

const checkToggle = this.#initialized && !prevSignal.aborted &&
Expand Down Expand Up @@ -151,7 +165,14 @@ export class Ddu {
}

if (checkToggle && uiOptions.toggle) {
await this.quit(denops);
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
this.quit();
return;
}

Expand Down Expand Up @@ -199,14 +220,21 @@ export class Ddu {
}

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

if (checkToggle && ui && uiOptions.toggle) {
await this.quit(denops);
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
this.quit();
return;
}

Expand Down Expand Up @@ -245,7 +273,23 @@ export class Ddu {
denops: Denops,
userOptions: UserOptions,
): Promise<void> {
await this.quit(denops);
// Quit current UI
const [ui, uiOptions, uiParams] = await getUi(
denops,
this.#loader,
this.#options,
);
if (!ui) {
return;
}
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
this.quit();

// Disable resume
userOptions.resume = false;
Expand Down Expand Up @@ -824,14 +868,7 @@ export class Ddu {
}
}

async quit(denops: Denops) {
await uiQuit(
denops,
this.#loader,
this.#context,
this.#options,
);

quit() {
// NOTE: quitted flag must be called after ui.quit().
this.#quitted = true;
this.#aborter.abort({ reason: "quit" });
Expand Down Expand Up @@ -1011,12 +1048,13 @@ export class Ddu {

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

Expand Down
29 changes: 0 additions & 29 deletions denops/ddu/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,33 +901,6 @@ async function checkUiOnInit(
}
}

export async function uiQuit<
Params extends BaseUiParams,
>(
denops: Denops,
loader: Loader,
context: Context,
options: DduOptions,
): Promise<void> {
// Quit current UI
const [ui, uiOptions, uiParams] = await getUi(
denops,
loader,
options,
);
if (!ui) {
return;
}
await ui.quit({
denops,
context,
options,
uiOptions,
uiParams,
});
ui.prevDone = false;
}

export async function uiRedraw<
Params extends BaseUiParams,
>(
Expand Down Expand Up @@ -956,7 +929,6 @@ export async function uiRedraw<
uiOptions,
uiParams,
});
ui.prevDone = false;
return;
}

Expand Down Expand Up @@ -985,7 +957,6 @@ export async function uiRedraw<
uiOptions,
uiParams,
});
ui.prevDone = false;
}

await denops.cmd("doautocmd <nomodeline> User Ddu:redraw");
Expand Down

0 comments on commit 8127ada

Please sign in to comment.