Skip to content

Commit

Permalink
Fix ui.quit() when onEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jul 3, 2024
1 parent bec4b27 commit d87fbf8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lint:
deno check ${TS}
deno fmt --check denops
deno test --no-run -A ${TS}
deno lint denops
deno lint denops --ignore=denops/ddu/_mod.js

test:
deno test -A ${TSTEST}
Expand Down
39 changes: 15 additions & 24 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
getUi,
initSource,
sourceArgs,
uiQuit,
uiRedraw,
uiSearchItem,
} from "./ext.ts";
Expand Down Expand Up @@ -112,22 +113,12 @@ export class Ddu {

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

Expand Down Expand Up @@ -277,22 +268,12 @@ export class Ddu {
userOptions: UserOptions,
): Promise<void> {
// Quit current UI
const [ui, uiOptions, uiParams] = await getUi(
await uiQuit(
denops,
this.#loader,
this.#context,
this.#options,
);
if (!ui) {
return;
}
await ui.quit({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
ui.prevDone = false;
this.quit();

// Disable resume
Expand Down Expand Up @@ -870,6 +851,16 @@ export class Ddu {
event,
});
}

if (event === "close" || event === "cancel") {
// Quit event
await uiQuit(
denops,
this.#loader,
this.#context,
this.#options,
);
}
}

quit() {
Expand Down
27 changes: 27 additions & 0 deletions denops/ddu/ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,33 @@ export async function uiRedraw<
});
}

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;
}

async function checkFilterOnInit(
filter: BaseFilter<BaseFilterParams>,
denops: Denops,
Expand Down

0 comments on commit d87fbf8

Please sign in to comment.