Shougo / ddu-ui-ff

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

ddu-ff buffer is not focused after closing filter window #45

Closed kbwo closed 2 years ago

kbwo commented 2 years ago

Thank you for great plugin.

Problems summary

ddu-ff buffer lose cursor focus after closing filter window.

Environment Information

This issue occurs from latest commit https://github.com/Shougo/ddu-ui-ff/commit/d7fbe6c16da6be920c53e18f229816ac3161dfc7.

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

call plug#begin(expand('~/.vim/plugged'))
Plug 'vim-denops/denops.vim'
Plug 'Shougo/ddu.vim'
Plug 'Shougo/ddu-ui-ff'
Plug 'Shougo/ddu-source-file_rec'
Plug 'Shougo/ddu-kind-file'
Plug 'yuki-yano/ddu-filter-fzf'
Plug 'matsui54/ddu-source-file_external'
call plug#end()

call ddu#custom#patch_global({
  \  'ui': 'ff',
  \  'sources': [
    \  {'name': 'file_external', 
    \  'params': 
    \  {
        \  'cmd': ['rg', '--files', '--hidden', '--glob', '!.git', '--color', 'never']
      \  }
    \  }
  \  ],
  \   'sourceOptions': {
  \     '_': {
  \       'matchers': ['matcher_fzf'],
  \     },
  \   }
\  })
autocmd FileType ddu-ff call s:ddu_my_settings()
function! s:ddu_my_settings() abort
  nnoremap <buffer><silent> <CR>
        \ <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  nnoremap <buffer><silent> i
        \ <Cmd>call ddu#ui#ff#do_action('openFilterWindow')<CR>
  nnoremap <buffer><silent> q
        \ <Cmd>call ddu#ui#ff#do_action('quit')<CR>
endfunction

autocmd FileType ddu-ff-filter call s:ddu_filter_my_settings()

function! s:ddu_filter_my_settings() abort
  inoremap <buffer><silent> <CR>
  \ <Esc><Cmd>close<CR>
  nnoremap <buffer><silent> <CR>
  \ <Cmd>close<CR>
  nnoremap <buffer><silent> q
  \ <Cmd>close<CR>
endfunction

nmap <silent><c-p> :call ddu#start({})<CR>

After insert any word and close filter window by enter key, cursor don't move to the ddu-ff buffer but buffer of current opening file. If this is expected, could you tell me the way to focus the ddu-ff buffer?

Shougo commented 2 years ago
  inoremap <buffer><silent> <CR>
        \ <Esc><Cmd>close<CR>
        \<Cmd>call win_gotoid(g:ddu#ui#ff#_filter_parent_winid)<CR>

It fixes your problem.

kbwo commented 2 years ago

Thank you for your quick reply. My problem has been solved completely!!

Shougo commented 2 years ago

I have added ddu#ui#ff#close(). It is better.