Skip to content

Commit

Permalink
fix(float.vim): prompt canceled in neovim will move cursor
Browse files Browse the repository at this point in the history
When using `<esc>` to cancel the prompt window and go back to the previous window,
cursor shift one left.

Look like it's a bug for closing floating window in insert mode.
  • Loading branch information
kevinhwang91 authored and chemzqm committed Aug 23, 2021
1 parent 1b9aa8c commit 388586f
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions autoload/coc/float.vim
Original file line number Diff line number Diff line change
Expand Up @@ -564,19 +564,14 @@ function! coc#float#create_prompt_win(title, default, opts) abort
call nvim_set_current_win(winid)
inoremap <buffer> <C-a> <Home>
inoremap <buffer><expr><C-e> pumvisible() ? "\<C-e>" : "\<End>"
exe 'inoremap <silent><buffer> <esc> <C-r>=coc#float#close_i('.winid.')<CR><esc>'
exe 'imap <silent><buffer> <esc> <esc><esc>'
exe 'nnoremap <silent><buffer> <esc> :call coc#float#close('.winid.')<CR>'
exe 'inoremap <silent><expr><nowait><buffer> <cr> "\<C-r>=coc#float#prompt_insert(getline(''.''))\<cr>\<esc>"'
call feedkeys('A', 'in')
endif
return [bufnr, winid]
endfunction

function! coc#float#close_i(winid) abort
call coc#float#close(a:winid)
return ''
endfunction

function! coc#float#prompt_insert(text) abort
call coc#rpc#notify('PromptInsert', [a:text])
return ''
Expand Down

0 comments on commit 388586f

Please sign in to comment.