Shougo / ddu.vim

Dark deno-powered UI framework for Vim/Neovim
MIT License
294 stars 23 forks source link

Toggle hidden files does not work #100

Closed k-86 closed 10 months ago

k-86 commented 10 months ago

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

Problems summary

I tried toggling hidden files, but it didn't work from e07df9d.

This seems to be the problem. https://github.com/Shougo/ddu.vim/blob/a897c77a109cc551fd0ccb87123a04de179dd932/denops/ddu/ddu.ts#L1574-L1576

ret.sourceOptions === this.#options.sourceOptions // true

https://github.com/Shougo/ddu.vim/blob/a897c77a109cc551fd0ccb87123a04de179dd932/denops/ddu/ddu.ts#L1601

This will fix it, but I'm not sure if it's correct.

const ret = structuredClone(this.#options);

Expected

Can toggle.

Environment Information

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

set rtp+=/path/to/github.com/vim-denops/denops.vim
set rtp+=/path/to/github.com/Shougo/ddu.vim
set rtp+=/path/to/github.com/Shougo/ddu-ui-ff
set rtp+=/path/to/github.com/Shougo/ddu-source-file
set rtp+=/path/to/github.com/Shougo/ddu-filter-matcher_hidden

call ddu#custom#patch_global(#{
  \ ui: 'ff',
  \ sources: ['file'],
  \ sourceOptions: #{
  \   _: #{
  \     matchers:['matcher_hidden'],
  \     },
  \   },
  \})

autocmd FileType ddu-ff call s:ddu_ff_setting()

function s:ddu_ff_setting()
  nnoremap <buffer> >
  \ <Cmd>call ddu#ui#do_action('updateOptions', #{
  \   sourceOptions: #{
  \     _: #{
  \       matchers: ToggleHidden(),
  \     },
  \   },
  \ })<CR>
  \<Cmd>call ddu#ui#do_action('redraw')<CR>
endfunction

function ToggleHidden()
  const current = ddu#custom#get_current(b:ddu_ui_name)
  const source_options = get(current, 'sourceOptions', {})
  const source_options_all = get(source_options, '_', {})
  const matchers = get(source_options_all, 'matchers', [])
  return empty(matchers) ? ['matcher_hidden'] : []
endfunction

function EchoMatchers()
  const current = ddu#custom#get_current(b:ddu_ui_name)
  const source_options = get(current, 'sourceOptions', {})
  const source_options_all = get(source_options, '_', {})
  const source_options_file = get(source_options, 'file', {})
  echo "_:" . string(get(source_options_all, 'matchers'))
  echo "file:" . string(get(source_options_file, 'matchers'))
endfunction

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

  1. nvim -u init.vim
  2. :call ddu#start()
  3. :call EchoMatchers()
  4. type >
  5. :call EchoMatchers()

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

// before toggle
_:['matcher_hidden']
file:['matcher_hidden']

// after toggle
_:[]
file:['matcher_hidden']
Shougo commented 10 months ago

Fixed.