Closed tennashi closed 1 year ago
OK. I have changed the behavior.
But it is experimental. I may restore the behavior.
@Shougo I've confirmed that it works, thanks!
However, even kind actions that don't invoke window creation always move the focus outside ddu.
Maybe it would be better to have another flag like ActionFlags.RestoreCursor
.
Please describe the example. I will check it later.
~/path/to/test_kind/denops/@ddu-kinds/test.ts
import {
ActionArguments,
ActionFlags,
BaseKind,
} from "https://deno.land/x/ddu_vim@v2.3.0/types.ts";
import { term_start } from "https://deno.land/x/denops_std@v4.0.0/function/vim/mod.ts";
type Params = Record<never, never>;
export class Kind extends BaseKind
= { test: async (args: ActionArguments
): Promise => { await term_start(args.denops, ["ls", "-la"]);
return ActionFlags.RefreshItems;
},
test2: async (args: ActionArguments<Params>): Promise<ActionFlags> => {
return ActionFlags.RefreshItems;
},
};
params(): Params { return {}; } }
The current behavior moves the focus outside ddu when action `test2` is executed.
The expected behavior is that the focus moves only when the focus is intentionally moved outside ddu in the action.
Since it may be difficult to distinguish whether intentional or not in the ddu, I thought it would be sufficient if we could specify this explicitly in the action:
* `~/path/to/test_kind/denops/@ddu-kinds/test.ts`
```ts
import {
ActionArguments,
ActionFlags,
BaseKind,
} from "https://deno.land/x/ddu_vim@v2.3.0/types.ts";
import { term_start } from "https://deno.land/x/denops_std@v4.0.0/function/vim/mod.ts";
type Params = Record<never, never>;
export class Kind extends BaseKind<Params> {
actions: Record<
string,
(args: ActionArguments<Params>) => Promise<ActionFlags>
> = {
test: async (args: ActionArguments<Params>): Promise<ActionFlags> => {
await term_start(args.denops, ["ls", "-la"]);
return ActionFlags.RefreshItems & ActionFlags.RestoreCursor; // current behavior
},
test2: async (args: ActionArguments<Params>): Promise<ActionFlags> => {
return ActionFlags.RefreshItems; // version "12633f6dea1019dbe4d02970a0a197ce84057c6e" behavior
},
};
params(): Params {
return {};
}
}
return ActionFlags.RefreshItems | ActionFlags.RestoreCursor; // current behavior
I have added RestoreCursor
.
Warning: I will close the issue without the minimal init.vim and the reproduction instructions.
Problems summary
Window focus does not move when executing
term_start()
in kind action that returnsActionFlags.RefreshItems
orActionFlags.Persist
.Works as expected for kind actions that return
ActionFlags.None
orActionFlags.Redraw
.Expected
Focus is moved to the window opened by
term_start()
.Environment Information
ddu.vim version (SHA1): 12633f6dea1019dbe4d02970a0a197ce84057c6e
denops.vim version (SHA1): 8f3899de3d3add07105221262dca90a31c4c2d4c
deno version(
deno -V
output): deno 1.31.1OS: Linux (6.1.0-4-amd64)
neovim/Vim
:version
output:Provide a minimal init.vim/vimrc without plugin managers (Required!)
~/path/to/test_kind/denops/@ddu-kinds/test.ts
type Params = Record<never, never>;
export class Kind extends BaseKind {
actions: Record<
string,
(args: ActionArguments) => Promise
};
params(): Params { return {}; } }
How to reproduce the problem from neovim/Vim startup (Required!)
:call ddu#start({'ui': 'ff', 'sources': [{'name': 'test'}]})
:call ddu#ui#ff#do_action('itemAction', {'name': 'test'})
Screenshot (if possible)
Upload the log messages by
:redir
and:message
(if errored)