Add option for <Esc> to close non-floating preview window

Closes #718.
This commit is contained in:
Andy Stewart
2020-06-23 15:18:25 +01:00
parent faf2581f00
commit 51a03d4ae0
3 changed files with 10 additions and 0 deletions

View File

@@ -455,6 +455,9 @@ function! s:open_hunk_preview_window()
setlocal filetype=diff buftype=acwrite bufhidden=delete setlocal filetype=diff buftype=acwrite bufhidden=delete
" Reset some defaults in case someone else has changed them. " Reset some defaults in case someone else has changed them.
setlocal noreadonly modifiable noswapfile setlocal noreadonly modifiable noswapfile
if g:gitgutter_close_preview_on_escape
nnoremap <buffer> <silent> <Esc> :pclose<CR>
endif
endfunction endfunction

View File

@@ -311,6 +311,7 @@ Signs:~
Hunk previews:~ Hunk previews:~
|g:gitgutter_preview_win_floating| |g:gitgutter_preview_win_floating|
|g:gitgutter_close_preview_on_escape|
Terminal:~ Terminal:~
@@ -468,6 +469,11 @@ Whether to use floating/popup windows for hunk previews. Note that if you use
popup windows on Vim you will not be able to stage partial hunks via the popup windows on Vim you will not be able to stage partial hunks via the
preview window. preview window.
*g:gitgutter_close_preview_on_escape*
Default: 0
Whether pressing <Esc> in a non-floating preview window closes it.
*g:gitgutter_terminal_reports_focus* *g:gitgutter_terminal_reports_focus*
Default: 1 Default: 1

View File

@@ -73,6 +73,7 @@ call s:set('g:gitgutter_terminal_reports_focus', 1)
call s:set('g:gitgutter_async', 1) call s:set('g:gitgutter_async', 1)
call s:set('g:gitgutter_log', 0) call s:set('g:gitgutter_log', 0)
call s:set('g:gitgutter_use_location_list', 0) call s:set('g:gitgutter_use_location_list', 0)
call s:set('g:gitgutter_close_preview_on_escape', 0)
call s:set('g:gitgutter_git_executable', 'git') call s:set('g:gitgutter_git_executable', 'git')
if !executable(g:gitgutter_git_executable) if !executable(g:gitgutter_git_executable)