mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Fix <Esc> in nvim floating preview window closes it
Previously the mapping was set in the original window not the floating window, so <Esc> in the floating window did nothing (when it should have closed it) while <Esc> in the original window closed the floating window (when it should have done nothing). Fixes #868.
This commit is contained in:
@@ -462,18 +462,16 @@ function! s:open_hunk_preview_window()
|
|||||||
call nvim_buf_set_option(buf, 'swapfile', v:false)
|
call nvim_buf_set_option(buf, 'swapfile', v:false)
|
||||||
call nvim_buf_set_name(buf, 'gitgutter://hunk-preview')
|
call nvim_buf_set_name(buf, 'gitgutter://hunk-preview')
|
||||||
|
|
||||||
|
if g:gitgutter_close_preview_on_escape
|
||||||
|
let winnr = nvim_win_get_number(s:winid)
|
||||||
|
execute winnr.'wincmd w'
|
||||||
|
nnoremap <buffer> <silent> <Esc> :<C-U>call gitgutter#hunk#close_hunk_preview_window()<CR>
|
||||||
|
wincmd w
|
||||||
|
endif
|
||||||
|
|
||||||
" Assumes cursor is in original window.
|
" Assumes cursor is in original window.
|
||||||
autocmd CursorMoved,TabLeave <buffer> ++once call gitgutter#hunk#close_hunk_preview_window()
|
autocmd CursorMoved,TabLeave <buffer> ++once call gitgutter#hunk#close_hunk_preview_window()
|
||||||
|
|
||||||
if g:gitgutter_close_preview_on_escape
|
|
||||||
" Map <Esc> to close the floating preview.
|
|
||||||
nnoremap <buffer> <silent> <Esc> :<C-U>call gitgutter#hunk#close_hunk_preview_window()<CR>
|
|
||||||
" Ensure that when the preview window is closed, the map is removed.
|
|
||||||
autocmd User GitGutterPreviewClosed silent! nunmap <buffer> <Esc>
|
|
||||||
autocmd CursorMoved <buffer> ++once silent! nunmap <buffer> <Esc>
|
|
||||||
execute "autocmd WinClosed <buffer=".winbufnr(s:winid)."> doautocmd" s:nomodeline "User GitGutterPreviewClosed"
|
|
||||||
endif
|
|
||||||
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user