mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Close preview on escape: only map <Esc> while preview open
This only applies to floating preview windows on Neovim. Handles the following way of closing the floating preview: - <Esc> - Moving cursor - 2<C-W>c (where 2 is the floating window's window number) - <C-W><C-W> to move into and out of the floating window Closes #786.
This commit is contained in:
@@ -447,8 +447,14 @@ function! s:open_hunk_preview_window()
|
||||
|
||||
" Assumes cursor is in original window.
|
||||
autocmd CursorMoved <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
|
||||
|
||||
Reference in New Issue
Block a user