Shougo / ddu-ui-filer

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

UpdateOptions are not reflected after moving the tree #32

Closed Ttayu closed 1 year ago

Ttayu commented 1 year ago

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

Problems summary

Once the tree is moved, the option changes made by updateOptions are not reflected. I only checked the matcher part, so it is possible that this is a different issue

Expected

The options should be changed regardless of whether the tree is moved or not.

Environment Information

TODO: MacOS version

Run :checkhealth for more info


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

```vim
" Your minimal init.vim/vimrc
set runtimepath+=~/.cache/dein/repos/github.com/vim-denops/denops.vim
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu.vim
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu-source-file
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu-kind-file
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu-ui-filer
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu-filter-matcher_hidden
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/ddu-commands.vim

autocmd TabEnter,CursorHold,FocusGained <buffer>
      \ call ddu#ui#do_action('checkItems')
augroup DduFilerSettings
  autocmd!
  autocmd FileType ddu-filer call s:ddu_filer_settings()
augroup END

function! s:ddu_filer_settings() abort
  nnoremap <buffer> h
        \ <Cmd>call ddu#ui#do_action('itemAction',
        \ #{ name: 'narrow', params: #{ path: '..' } })<CR>
  nnoremap <buffer> >
      \ <Cmd>call ddu#ui#do_action('updateOptions', #{
      \   sourceOptions: #{
      \     file: #{
      \       matchers: ToggleHidden('file'),
      \     },
      \   },
      \ })<CR>
  nnoremap <buffer><expr> l
        \ ddu#ui#get_item()->get('isTree', v:false) ?
        \ "<Cmd>call ddu#ui#do_action('itemAction', #{ name: 'narrow' })<CR>" :
        \ "<Cmd>call ddu#ui#do_action('itemAction', #{ name: 'open' })<CR>"
  nnoremap q <Cmd>call ddu#ui#filer#do_action('quit')<CR>
endfunction

function! ToggleHidden(name)
  let current = ddu#custom#get_current(b:ddu_ui_name)
  let source_options = get(current, 'sourceOptions', {})
  let source_options_name = get(source_options, a:name, {})
  let matchers = get(source_options_name, 'matchers', [])
  return empty(matchers) ? ['matcher_hidden'] : []
endfunction

call ddu#custom#patch_global({
      \   'ui': 'filer',
      \   'sources': [
      \     {
      \       'name': 'file',
      \       'params': {},
      \     },
      \   ],
      \   'sourceOptions': {
      \     'file': {
      \       'matchers': ['matcher_hidden'],
      \     },
      \   },
      \   'kindOptions': {
      \     'file': {
      \       'defaultAction': 'open',
      \     },
      \   },
      \   'actionOptions': {
      \     'narrow': {
      \       'quit': v:false 
      \     },
      \   },
      \   'uiOptions': {
      \     'filer': {
      \       'toggle': v:true 
      \     },
      \   },
      \   'uiParams': {
      \     'filer': {
      \       'split': 'floating',
      \       'sort': 'filename',
      \       'sortTreesFirst': v:true,
      \       'toggle': v:true,
      \     },
      \   },
      \ })

nnoremap ,n <Cmd>Ddu -name=filer<CR>

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

  1. ,n to start Ddu filer
  2. > to check that the mather is switched and mathcer_hidden and '' are swapped
  3. l or h to move tree
  4. h or l to return to original position (not always necessary)
  5. > to change matcher, but not changed

Screenshot (if possible)

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

Shougo commented 1 year ago

Reproduced. But it is not reproduced in my config.

Ttayu commented 1 year ago

Ah, now we know why. nnoremap ,n <Cmd>Ddu -name=filer -sync file<CR> That solved the problem. Thank you very much.

Shougo commented 1 year ago

I get the reason. It is bug.

Shougo commented 1 year ago

fixed.