From 24cc47789557827209add5881c226243711475ce Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Fri, 19 Mar 2021 16:31:26 +0000 Subject: [PATCH] Avoid cursor in unexpected window after Esc in preview Thanks @andymass for the patch. See #769. --- autoload/gitgutter/hunk.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index a13e170..eccf655 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -466,6 +466,8 @@ function! s:open_hunk_preview_window() endif endif + " Specifying where to open the preview window can lead to the cursor going + " to an unexpected window when the preview window is closed (#769). noautocmd execute g:gitgutter_preview_win_location 'pedit gitgutter://hunk-preview' silent! wincmd P setlocal statusline=%{''} @@ -479,7 +481,8 @@ function! s:open_hunk_preview_window() " Reset some defaults in case someone else has changed them. setlocal noreadonly modifiable noswapfile if g:gitgutter_close_preview_on_escape - nnoremap :pclose + " Ensure cursor goes to the expected window. + nnoremap :wincmd ppclose endif endfunction