Shougo / ddu-ui-ff

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

Doesn't restore the previous cursor position resuming #63

Closed creasty closed 1 year ago

creasty commented 1 year ago

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

Problems summary

Expected

Related: https://github.com/Shougo/ddu-ui-ff/issues/54

Environment Information

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

if has('vim_starting')
  let s:config_path = stdpath('config')
  for s:repo in [
    \ 'vim-denops/denops.vim',
    \ 'Shougo/ddu.vim',
    \ 'Shougo/ddu-ui-ff',
    \ 'Shougo/ddu-kind-file',
    \ 'matsui54/ddu-filter-fzy',
  \ ]
    let s:path = s:config_path . '/dein/repos/github.com/' . s:repo
    let &g:rtp .= ',' . s:path
  endfor
endif

call ddu#custom#patch_global({
  \ 'ui': 'ff',
  \ 'uiParams': {
    \ 'ff': {
      \ 'split': 'floating',
      \ 'filterSplitDirection': 'floating',
    \ },
  \ },
  \ 'sourceOptions': {
    \ 'ghq': {
      \ 'matchers': ['matcher_fzy'],
    \ },
  \ },
\ })

command! Open call s:open()
function! s:open() abort
  call ddu#start({
    \ 'name': 'ghq',
    \ 'sources': [{ 'name': 'ghq' }],
    \ 'uiParams': { 'ff': { 'startFilter': v:true } },
    \ 'resume': v:true,
  \ })
endfunction

augroup _init_ddu
  autocmd!
  autocmd FileType ddu-ff call <SID>init_ddu()
  autocmd FileType ddu-ff-filter call <SID>init_ddu()
augroup END

function! s:init_ddu() abort
  nnoremap <buffer> <Esc> <Cmd>call ddu#ui#ff#do_action('quit')<CR>
  nnoremap <buffer> q <Cmd>call ddu#ui#ff#do_action('quit')<CR>
  nnoremap <buffer> <C-q> <Cmd>call ddu#ui#ff#do_action('quit')<CR>
  inoremap <buffer> <C-q> <Cmd>call ddu#ui#ff#do_action('quit')<CR>

  nnoremap <buffer> <CR> <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  inoremap <buffer> <CR> <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  nnoremap <buffer> <C-j> <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  inoremap <buffer> <C-j> <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>

  if &filetype ==# 'ddu-ff'
    setl cursorline
  endif
  if &filetype ==# 'ddu-ff-filter'
    inoremap <buffer> <C-p> <Cmd>call ddu#ui#ff#execute("call cursor(line('.')-1,0)<Bar>redraw")<CR>
    inoremap <buffer> <C-n> <Cmd>call ddu#ui#ff#execute("call cursor(line('.')+1,0)<Bar>redraw")<CR>
  endif
endfunction

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

  1. Open ddu-ui by :Open
  2. Enter query (optional)
  3. Move cursor
  4. Quit with <C-q>
  5. Reopen ddu-ui

Screenshot (if possible)

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

Shougo commented 1 year ago

Sorry. It is expected behavior. The resume cursor is disabled when startFilter is enabled.

Shougo commented 1 year ago

Because it breaks autoAction.

creasty commented 1 year ago

The resume cursor is disabled when startFilter is enabled.

Any way I can mimic the previous behavior without changing the plugin itself?

My usual routine heavily depends on this specific behavior; In fact, it's one of the reasons I don't/can't use other plugins, there's no alternative. So I would really appreciate it if you could give it another thought. Like making the resume cursor available when the autoAction is disabled.

Shougo commented 1 year ago

Like making the resume cursor available when the autoAction is disabled.

I have implemented the feature. Please update.

creasty commented 1 year ago

Thanks a lot!