Shougo / ddu.vim

Dark deno-powered UI framework for Vim/NeoVim
MIT License
295 stars 24 forks source link

Preserve the input on resume #22

Closed creasty closed 2 years ago

creasty commented 2 years ago

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

Problems summary

Expected

Do not reset the input on resume.

Environment Information

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
     fall-back for $VIM: "/usr/local/Cellar/neovim/0.7.0/share/nvim"

     Run :checkhealth for more info

Provide a minimal init.vim/vimrc with less than 50 lines (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',
  \ '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-filter'
    inoremap <buffer> <C-p> <Cmd>call ddu#ui#ff#execute("call cursor(line('.')-1,0)")<CR>
    inoremap <buffer> <C-n> <Cmd>call ddu#ui#ff#execute("call cursor(line('.')+1,0)")<CR>
  endif
endfunction

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

  1. Open ddu-ui by :Open
  2. Enter query & move cursor
  3. Quit with <C-q>
  4. Reopen ddu-ui

Screenshot (if possible)

https://user-images.githubusercontent.com/1695538/179387894-b0bb1007-e376-466b-8e50-77a82ecfb935.mov

Shougo commented 2 years ago

Fixed.

creasty commented 2 years ago

Thanks again.