From 06ea9777451036d17e777e02b14b8329d0314c55 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 11 Jul 2023 20:00:50 +0900 Subject: [PATCH] feat!: item actions can close UI when all items are gathered. --- denops/ddu/ddu.ts | 11 +++++++++++ denops/ddu/types.ts | 1 + doc/ddu.txt | 3 +++ 3 files changed, 15 insertions(+) diff --git a/denops/ddu/ddu.ts b/denops/ddu/ddu.ts index 672884e..9b2e607 100644 --- a/denops/ddu/ddu.ts +++ b/denops/ddu/ddu.ts @@ -189,6 +189,7 @@ export class Ddu { uiOptions, uiParams, ); + this.context.doneUi = true; return; } } else { @@ -482,6 +483,7 @@ export class Ddu { // Update current input this.context.done = true; + this.context.doneUi = false; this.context.input = this.input; this.context.maxItems = 0; @@ -607,6 +609,8 @@ export class Ddu { } await this.uiRedraw(denops, searchTargetItem); + + this.context.doneUi = this.context.done; } async uiRedraw( @@ -919,6 +923,12 @@ export class Ddu { } if (actionOptions.quit) { + // NOTE: To quit UI properly, all items must be gathered. + if (!this.context.doneUi) { + echo(denops, "Current ddu UI is not done"); + return; + } + // Quit UI before action await this.uiQuit(denops, ui, uiOptions, uiParams); } @@ -2016,6 +2026,7 @@ async function uiRedraw< const context = ddu.getContext(); try { if (ddu.shouldStopCurrentContext()) { + await ddu.uiQuit(denops, ui, uiOptions, uiParams); return; } diff --git a/denops/ddu/types.ts b/denops/ddu/types.ts index 27ad0d3..448f60f 100644 --- a/denops/ddu/types.ts +++ b/denops/ddu/types.ts @@ -45,6 +45,7 @@ export type Context = { bufName: string; bufNr: number; done: boolean; + doneUi: boolean; input: string; maxItems: number; mode: string; diff --git a/doc/ddu.txt b/doc/ddu.txt index acf8631..dcc1cc8 100644 --- a/doc/ddu.txt +++ b/doc/ddu.txt @@ -1385,6 +1385,9 @@ A: The example is here. > ============================================================================== COMPATIBILITY *ddu-compatibility* +2023.07.11 +* item actions can close UI when all items are gathered. + 2023.07.07 * Vim 9.0.1276+ or neovim 0.8+ is required to support the latest MacVim.