mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
@@ -440,16 +440,24 @@ function! s:open_hunk_preview_window()
|
|||||||
|
|
||||||
" Assumes cursor is in original window.
|
" Assumes cursor is in original window.
|
||||||
autocmd CursorMoved <buffer> ++once call s:close_hunk_preview_window()
|
autocmd CursorMoved <buffer> ++once call s:close_hunk_preview_window()
|
||||||
|
if g:gitgutter_close_preview_on_escape
|
||||||
|
nnoremap <buffer> <silent> <Esc> :call <SID>close_hunk_preview_window()<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('*popup_create')
|
if exists('*popup_create')
|
||||||
let s:winid = popup_create('', {
|
let opts = {
|
||||||
\ 'line': 'cursor+1',
|
\ 'line': 'cursor+1',
|
||||||
\ 'col': 'cursor',
|
\ 'col': 'cursor',
|
||||||
\ 'moved': 'any',
|
\ 'moved': 'any',
|
||||||
\ })
|
\ }
|
||||||
|
if g:gitgutter_close_preview_on_escape
|
||||||
|
let opts.filter = function('s:close_popup_on_escape')
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:winid = popup_create('', opts)
|
||||||
|
|
||||||
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
|
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
|
||||||
|
|
||||||
@@ -480,6 +488,15 @@ function! s:open_hunk_preview_window()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:close_popup_on_escape(winid, key)
|
||||||
|
if a:key == "\<Esc>"
|
||||||
|
call popup_close(a:winid)
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Floating window: does not care where cursor is.
|
" Floating window: does not care where cursor is.
|
||||||
" Preview window: assumes cursor is in preview window.
|
" Preview window: assumes cursor is in preview window.
|
||||||
function! s:populate_hunk_preview_window(header, body)
|
function! s:populate_hunk_preview_window(header, body)
|
||||||
|
|||||||
Reference in New Issue
Block a user