From 2abe9a6b88b8956e183fcbab78e7dc43f1d94883 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 5 Aug 2023 08:05:33 +0900 Subject: [PATCH] Overwrite event for manual completion --- denops/@ddu-sources/ddc.ts | 6 +++--- denops/ddc/app.ts | 6 ++++-- denops/ddc/ddc.ts | 10 ++++++---- denops/ddc/deps.ts | 8 ++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/denops/@ddu-sources/ddc.ts b/denops/@ddu-sources/ddc.ts index 667ce97..d5dd095 100644 --- a/denops/@ddu-sources/ddc.ts +++ b/denops/@ddu-sources/ddc.ts @@ -1,6 +1,6 @@ -import { Context, Item } from "https://deno.land/x/ddu_vim@v3.4.4/types.ts"; -import { BaseSource } from "https://deno.land/x/ddu_vim@v3.4.4/base/source.ts"; -import { Denops, vars } from "https://deno.land/x/ddu_vim@v3.4.4/deps.ts"; +import { Context, Item } from "https://deno.land/x/ddu_vim@v3.4.5/types.ts"; +import { BaseSource } from "https://deno.land/x/ddu_vim@v3.4.5/base/source.ts"; +import { Denops, vars } from "https://deno.land/x/ddu_vim@v3.4.5/deps.ts"; import { DdcItem } from "../ddc/types.ts"; type Params = Record; diff --git a/denops/ddc/app.ts b/denops/ddc/app.ts index a6f5828..ba24ed5 100644 --- a/denops/ddc/app.ts +++ b/denops/ddc/app.ts @@ -237,10 +237,12 @@ export function main(denops: Denops) { visible && ddc.prevUi !== "" && options.autoCompleteEvents.indexOf(event) > 0 ) { - // NOTE: If UI is visible, use prevSources/prevUi instead to update - // current items + // NOTE: If UI is visible, use prevSources/prevUi/prevEvent instead to + // update current items + options.sources = ddc.prevSources; options.ui = ddc.prevUi; + context.event = ddc.prevEvent; } await ddc.onEvent( diff --git a/denops/ddc/ddc.ts b/denops/ddc/ddc.ts index eb0cfeb..16abfa4 100644 --- a/denops/ddc/ddc.ts +++ b/denops/ddc/ddc.ts @@ -70,6 +70,7 @@ export class Ddc { prevSources: UserSource[] = []; prevUi = ""; + prevEvent = ""; constructor(loader: Loader) { this.loader = loader; @@ -595,6 +596,7 @@ export class Ddc { }); this.prevUi = options.ui; + this.prevEvent = context.event; this.visibleUi = true; } @@ -627,6 +629,10 @@ export class Ddc { context: Context, options: DdcOptions, ): Promise { + if (this.visibleUi) { + return true; + } + const [ui, uiOptions, uiParams] = await this.getUi( denops, context, @@ -636,10 +642,6 @@ export class Ddc { return false; } - if (this.visibleUi) { - return true; - } - // Check UI is visible // NOTE: UI may be closed by users return ui.visible diff --git a/denops/ddc/deps.ts b/denops/ddc/deps.ts index 818cbb6..2ca99ee 100644 --- a/denops/ddc/deps.ts +++ b/denops/ddc/deps.ts @@ -11,16 +11,16 @@ export * as op from "https://deno.land/x/denops_std@v5.0.1/option/mod.ts"; export * as fn from "https://deno.land/x/denops_std@v5.0.1/function/mod.ts"; export * as vars from "https://deno.land/x/denops_std@v5.0.1/variable/mod.ts"; export * as autocmd from "https://deno.land/x/denops_std@v5.0.1/autocmd/mod.ts"; -export * as base64 from "https://deno.land/std@0.196.0/encoding/base64.ts"; +export * as base64 from "https://deno.land/std@0.197.0/encoding/base64.ts"; export { assertEquals, equal, -} from "https://deno.land/std@0.196.0/assert/mod.ts"; -export { parse, toFileUrl } from "https://deno.land/std@0.196.0/path/mod.ts"; +} from "https://deno.land/std@0.197.0/assert/mod.ts"; +export { parse, toFileUrl } from "https://deno.land/std@0.197.0/path/mod.ts"; export { deadline, DeadlineError, -} from "https://deno.land/std@0.196.0/async/mod.ts"; +} from "https://deno.land/std@0.197.0/async/mod.ts"; export { TimeoutError } from "https://deno.land/x/msgpack_rpc@v4.0.1/response_waiter.ts"; export { spy } from "https://deno.land/x/mock@0.15.2/mock.ts"; export { ensure, is } from "https://deno.land/x/unknownutil@v3.4.0/mod.ts";