Skip to content

Commit

Permalink
Overwrite event for manual completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Aug 4, 2023
1 parent 3b823fa commit 2abe9a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions denops/@ddu-sources/ddc.ts
Original file line number Diff line number Diff line change
@@ -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<never, never>;
Expand Down
6 changes: 4 additions & 2 deletions denops/ddc/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 6 additions & 4 deletions denops/ddc/ddc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class Ddc {

prevSources: UserSource[] = [];
prevUi = "";
prevEvent = "";

constructor(loader: Loader) {
this.loader = loader;
Expand Down Expand Up @@ -595,6 +596,7 @@ export class Ddc {
});

this.prevUi = options.ui;
this.prevEvent = context.event;
this.visibleUi = true;
}

Expand Down Expand Up @@ -627,6 +629,10 @@ export class Ddc {
context: Context,
options: DdcOptions,
): Promise<boolean> {
if (this.visibleUi) {
return true;
}

const [ui, uiOptions, uiParams] = await this.getUi(
denops,
context,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions denops/ddc/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 2abe9a6

Please sign in to comment.