Shougo / ddu-ui-filer

File listing UI for ddu.vim
MIT License
55 stars 8 forks source link

If you run the quit action once and then open the filer again, an error will occur #44

Closed yasunori0418 closed 4 months ago

yasunori0418 commented 4 months ago

Problems summary

After opening the filer and closing it with the quit action, if you try to open the filer again, an error will occur.

Below is the error message reproduced with the minimum configuration.

# Neovim error messages
Error detected while processing CursorMoved Autocommands for "<buffer=2>"..function ddu#ui#filer#_save_cursor:
line   16:
E121: Undefined variable: b:ddu_ui_filer_save_cursor_item
[denops] Unhandled rejection: Error: Failed to call 'denops#api#cmd' in Neovim: CursorMoved Autocommands for "<buffer=2>"..function ddu#ui#filer#_save_cursor[16]..ddu#ui#get_item[1]..ddu#ui_sync_action[4]..ddu#denops#_request[15]..denops#request[1]..denops#_internal#server#chan#request[6]..denops#_internal#rpc#nvim#request[1]..denops#api#cmd, line 2: Vim(close):E444: Cannot close last window (code: 0)
[denops]     at Neovim.call (file:///home/yasunori/.cache/dpp/repos/github.com/vim-denops/denops.vim/denops/@denops-private/host/nvim.ts:65:15)
[denops]     at eventLoopTick (ext:core/01_core.js:168:7)
[denops]     at async DenopsImpl.cmd (file:///home/yasunori/.cache/dpp/repos/github.com/vim-denops/denops.vim/denops/@denops-private/denops.ts:63:5)
[denops]     at async Ui.quit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu-ui-filer/denops/@ddu-uis/filer.ts:592:9)
[denops]     at async uiQuit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ext.ts:921:3)
[denops]     at async Ddu.quit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ddu.ts:828:5)
# Vim error messages
[ddu] BatchError: Failed to call 'ddu#ui#filer#_highlight_items' in Vim: Vim(call):E970: Unknown highlight group name: 'String'
[ddu] function denops#api#vim#batch[3]..<lambda>11875[1]..ddu#ui#filer#_highlight_items[17]..ddu#ui#filer#_highlight, line 10
[ddu]     at DenopsImpl.batch (file:///home/yasunori/.cache/dpp/repos/github.com/vim-denops/denops.vim/denops/@denops-private/denops.ts:57:13)
[ddu]     at eventLoopTick (ext:core/01_core.js:168:7)
[ddu]     at async batch (https://deno.land/x/denops_std@v6.5.0/batch/batch.ts:194:3)
[ddu]     at async Ui.redraw (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu-ui-filer/denops/@ddu-uis/filer.ts:445:7)
[ddu]     at async file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ext.ts:971:7
[ddu]     at async Lock.lock (https://jsr.io/@lambdalisue/async/2.1.1/lock.ts:51:14)
[ddu]     at async uiRedraw (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ext.ts:944:3)
[ddu]     at async Ddu.uiRedraw (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ddu.ts:781:5)
[ddu]     at async Ddu.start (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ddu.ts:237:5)
[ddu]     at async file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/app.ts:234:9
[ddu] [ddu-ui-filer] update buffer failed
[denops] Unhandled rejection: Error: Failed to call 'denops#api#cmd' in Vim: Vim(close):E444: Cannot close last window
[denops] function denops#api#vim#call[2]..denops#api#cmd, line 2
[denops]     at Vim.call (file:///home/yasunori/.cache/dpp/repos/github.com/vim-denops/denops.vim/denops/@denops-private/host/vim.ts:56:13)
[denops]     at eventLoopTick (ext:core/01_core.js:168:7)
[denops]     at async DenopsImpl.cmd (file:///home/yasunori/.cache/dpp/repos/github.com/vim-denops/denops.vim/denops/@denops-private/denops.ts:63:5
)
[denops]     at async Ui.quit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu-ui-filer/denops/@ddu-uis/filer.ts:592:9)
[denops]     at async uiQuit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ext.ts:921:3)
[denops]     at async Ddu.quit (file:///home/yasunori/.cache/dpp/repos/github.com/Shougo/ddu.vim/denops/ddu/ddu.ts:828:5)
[denops] Unhandled rejection: Error: Failed to call 'denops#api#cmd' in Vim: Vim(close):E444: Cannot close last window

Expected

Environment Information

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run ":verbose version" for more info
:version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jun 17 2024 22:29:09)
Included patches: 1-496
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               +cryptv            +fork()            +modify_fname      +persistent_undo   -sun_workshop      +viminfo
+arabic            +cscope            +gettext           +mouse             +popupwin          +syntax            +virtualedit
+autocmd           +cursorbind        -hangul_input      -mouseshape        +postscript        +tag_binary        +visual
+autochdir         +cursorshape       +iconv             +mouse_dec         +printer           -tag_old_static    +visualextra
-autoservername    +dialog_con        +insert_expand     +mouse_gpm         +profile           -tag_any_white     +vreplace
-balloon_eval      +diff              +ipv6              -mouse_jsbterm     -python            +tcl/dyn           +wildignore
+balloon_eval_term +digraphs          +job               +mouse_netterm     +python3/dyn       +termguicolors     +wildmenu
-browse            -dnd               +jumplist          +mouse_sgr         +quickfix          +terminal          +windows
++builtin_terms    -ebcdic            +keymap            -mouse_sysmouse    +reltime           +terminfo          +writebackup
+byte_offset       +emacs_tags        +lambda            +mouse_urxvt       +rightleft         +termresponse      -X11
+channel           +eval              +langmap           +mouse_xterm       +ruby/dyn          +textobjects       +xattr
+cindent           +ex_extra          +libcall           +multi_byte        +scrollbind        +textprop          -xfontset
-clientserver      +extra_search      +linebreak         +multi_lang        +signs             +timers            -xim
-clipboard         -farsi             +lispindent        -mzscheme          +smartindent       +title             -xpm
+cmdline_compl     +file_in_path      +listcmds          +netbeans_intg     -sodium            -toolbar           -xsmp
+cmdline_hist      +find_in_path      +localmap          +num64             -sound             +user_commands     -xterm_clipboard
+cmdline_info      +float             +lua/dyn           +packages          +spell             +vartabs           -xterm_save
+comments          +folding           +menu              +path_extra        +startuptime       +vertsplit
+conceal           -footer            +mksession         +perl/dyn          +statusline        +vim9script
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "$XDG_CONFIG_HOME/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wformat -Werror=format-security -fsta
ck-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/vim/src=/usr/src/debug/vim -fl
to=auto -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.38/core_perl/CORE -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-rel
ative-relocs -flto=auto -L/usr/local/lib -o vim -lm -ltinfo -lacl -lattr -lgpm -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

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

const s:plugin_dir = '~/.cache/dpp/repos/github.com'->expand()
const s:plugins = [
  \ 'vim-denops/denops.vim',
  \ 'Shougo/ddu.vim',
  \ 'Shougo/ddu-ui-filer',
  \ 'Shougo/ddu-kind-file',
  \ 'Shougo/ddu-source-file',
  \ 'Shougo/ddu-filter-matcher_substring'
\ ]

for p in s:plugins
  execute $'set rtp^={s:plugin_dir}/{p}'
endfor

call ddu#custom#patch_global(#{
  \ ui: 'filer',
  \ kindOptions: #{
    \ file: #{
      \ defaultAction: "open",
    \ },
  \ },
  \ sources: [
    \ #{
      \ name: 'file',
      \ options: #{
        \ matchers: ['matcher_substring'],
      \ }
    \ },
  \ ],
\ })

function! s:keymaps() abort
  nnoremap <buffer> <CR> <Cmd>call ddu#ui#sync_action("itemAction")<CR>
  nnoremap <buffer> q <Cmd>call ddu#ui#sync_action("quit")<CR>
endfunction

augroup filer
  autocmd!
  autocmd FileType ddu-filer call s:keymaps()
augroup END

command! Test call ddu#start()

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

  1. Start the editor.
    • Neovim -> nvim -u init.vim
    • Vim -> vim -N -u init.vim
  2. Execute the keymapped quit action after opening the filer.
    1. :Test
    2. execute q in ddu-filer buffer
  3. When I open filer again, an error occurs.
    1. :Test
Shougo commented 4 months ago

Fixed. Please update ddu.vim.