Shougo / ddu-ui-ff

Fuzzy finder UI for ddu.vim
MIT License
55 stars 26 forks source link

UI is not focused in invoking custom action defined by TS at `Ddu:uiDone` #151

Closed 4513ECHO closed 4 months ago

4513ECHO commented 4 months ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

UI is not focused in invoking custom action (not UI action but source/kind action) defined by TS at Ddu:uiDone.

Expected

The behavior should be same as script from Vim script.

Environment Information

Neovim ``` NVIM v0.11.0-dev-3589+g1f2f460b4-Homebrew Build type: Release LuaJIT 2.1.1720049189 Run ":verbose version" for more info ```
Vim ``` VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jul 14 2024 09:43:21) macOS 版 - arm64 適用済パッチ: 1-568 Compiled by Homebrew Huge 版 without GUI. 機能の一覧 有効(+)/無効(-) +acl -ebcdic +lua -python +title +arabic +emacs_tags +menu +python3 -toolbar +autocmd +eval +mksession +quickfix +user_commands +autochdir +ex_extra +modify_fname +reltime +vartabs -autoservername +extra_search +mouse +rightleft +vertsplit -balloon_eval -farsi -mouseshape +ruby +vim9script +balloon_eval_term +file_in_path +mouse_dec +scrollbind +viminfo -browse +find_in_path -mouse_gpm +signs +virtualedit ++builtin_terms +float -mouse_jsbterm +smartindent +visual +byte_offset +folding +mouse_netterm +sodium +visualextra +channel -footer +mouse_sgr +sound +vreplace +cindent +fork() -mouse_sysmouse +spell +wildignore -clientserver +gettext +mouse_urxvt +startuptime +wildmenu +clipboard -hangul_input +mouse_xterm +statusline +windows +cmdline_compl +iconv +multi_byte -sun_workshop +writebackup +cmdline_hist +insert_expand +multi_lang +syntax -X11 +cmdline_info +ipv6 -mzscheme +tag_binary -xattr +comments +job +netbeans_intg -tag_old_static -xfontset +conceal +jumplist +num64 -tag_any_white -xim +cryptv +keymap +packages -tcl -xpm +cscope +lambda +path_extra +termguicolors -xsmp +cursorbind +langmap +perl +terminal -xterm_clipboard +cursorshape +libcall +persistent_undo +terminfo -xterm_save +dialog_con +linebreak +popupwin +termresponse +diff +lispindent +postscript +textobjects +digraphs +listcmds +printer +textprop -dnd +localmap +profile +timers システム vimrc: "$VIM/vimrc" ユーザー vimrc: "$HOME/.vimrc" 第2ユーザー vimrc: "~/.vim/vimrc" 第3ユーザー vimrc: "$XDG_CONFIG_HOME/vim/vimrc" ユーザー exrc: "$HOME/.exrc" デフォルトファイル: "$VIMRUNTIME/defaults.vim" 省略時の $VIM: "/Users/234531sch/Library/homebrew/share/vim" コンパイル: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -I/Users/234531sch/Library/homebrew/Cellar/libsodium/1.0.20/include -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 リンク: clang -o vim -lm -lncurses -L/Users/234531sch/Library/homebrew/Cellar/libsodium/1.0.20/lib -lsodium -liconv -lintl -framework AppKit -L/Users/234531sch/Library/homebrew/opt/lua/lib -llua5.4 -mmacosx-version-min=14.4 -fstack-protector-strong -L/Users/234531sch/Library/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level/CORE -lperl -L/Users/234531sch/Library/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin -lpython3.12 -lintl -framework CoreFoundation -lruby.3.3 -L/Users/234531sch/Library/homebrew/Cellar/ruby/3.3.4/lib ```

Provide a minimal init.vim/vimrc without plugin managers (Required!)

set runtimepath+=~/.cache/nvim/dein/repos/github.com/vim-denops/denops.vim_v7-pre
set runtimepath+=~/.cache/nvim/dein/repos/github.com/Shougo/ddu.vim
set runtimepath+=~/.cache/nvim/dein/repos/github.com/Shougo/ddu-ui-ff
set runtimepath+=~/.cache/nvim/dein/repos/github.com/Shougo/ddu-kind-file
set runtimepath+=~/.cache/nvim/dein/repos/github.com/Shougo/ddu-source-file_rec

autocmd User Ddu:uiDone ++once echomsg #{ from: 'vim', bufnr: bufnr(), winid: win_getid() }
autocmd User Ddu:uiDone ++once call ddu#ui#async_action('itemAction', #{ name: 'test' })
call ddu#custom#load_config(expand('<sfile>:p:h') .. '/config.ts')
nnoremap mm <Cmd>call ddu#start()<CR>

config.ts

import {
  BaseConfig,
  type ConfigArguments,
} from "https://deno.land/x/ddu_vim@v4.2.0/base/config.ts";
import { ActionFlags } from "https://deno.land/x/ddu_vim@v4.2.0/types.ts";

export class Config extends BaseConfig {
  override config(args: ConfigArguments): Promise<void> {
    args.contextBuilder.patchGlobal({
      sources: [{ name: "file_rec" }],
      sourceOptions: {
        _: {
          actions: {
            test: async (args) => {
              console.log({
                from: "ts",
                bufnr: await args.denops.call("bufnr"),
                winid: await args.denops.call("win_getid"),
                items: await args.denops.call("ddu#ui#get_items"),
              });
              return ActionFlags.Persist;
            },
          },
        },
      },
      ui: "ff",
    });
    return Promise.resolve();
  }
}

How to reproduce the problem from neovim/Vim startup (Required!)

  1. type mm
  2. see messages.

Screenshot (if possible)

None.

Upload the log messages by :redir and :message (if errored)

{'bufnr': 2, 'from': 'vim', 'winid': 1002}
[denops] {"from":"ts","bufnr":1,"winid":1000,"items":[]}
Shougo commented 4 months ago
      actionOptions: {
        test: {
          quit: false,
        },
      },

Fixes your problem. The default action behavior is quit UI.