mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-14 10:45:42 +08:00
fix(flygrep): save previous windows id
merge: https://github.com/SpaceVim/SpaceVim/pull/4479 Co-authored-by: jsecchiero <secchierojacopo@gmail.com>
This commit is contained in:
parent
83aa15f1ee
commit
cf9b7c08aa
@ -31,6 +31,19 @@ let s:grepid = 0
|
||||
|
||||
let s:filename_pattern = '[^:]*:\d\+:\d\+:'
|
||||
|
||||
" if win_getid does not existing, use winnr instead
|
||||
let s:previous_winid = 0
|
||||
|
||||
function! s:close_flygrep_win() abort
|
||||
noautocmd q
|
||||
" this function requires vim 7.4.1557
|
||||
if has('patch-7.4.1557')
|
||||
call win_gotoid(s:previous_winid)
|
||||
else
|
||||
exe s:previous_winid . 'wincmd w'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Init local options: {{{
|
||||
let s:grep_expr = ''
|
||||
let [
|
||||
@ -342,7 +355,7 @@ function! s:close_buffer() abort
|
||||
noautocmd call s:close_preview_win()
|
||||
let s:preview_able = 0
|
||||
endif
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
endfunction
|
||||
let s:MPT._onclose = function('s:close_buffer')
|
||||
" }}}
|
||||
@ -502,7 +515,7 @@ function! s:open_item() abort
|
||||
call s:close_preview_win()
|
||||
endif
|
||||
let s:preview_able = 0
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
call s:update_history()
|
||||
call s:BUFFER.open_pos('edit', filename, linenr, colum)
|
||||
noautocmd normal! :
|
||||
@ -523,7 +536,7 @@ function! s:open_item_in_tab() abort
|
||||
call s:close_preview_win()
|
||||
endif
|
||||
let s:preview_able = 0
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
call s:update_history()
|
||||
call s:BUFFER.open_pos('tabedit', filename, linenr, colum)
|
||||
noautocmd normal! :
|
||||
@ -544,7 +557,7 @@ function! s:open_item_vertically() abort
|
||||
call s:close_preview_win()
|
||||
endif
|
||||
let s:preview_able = 0
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
call s:update_history()
|
||||
call s:BUFFER.open_pos('vsplit', filename, linenr, colum)
|
||||
noautocmd normal! :
|
||||
@ -565,7 +578,7 @@ function! s:open_item_horizontally() abort
|
||||
call s:close_preview_win()
|
||||
endif
|
||||
let s:preview_able = 0
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
call s:update_history()
|
||||
call s:BUFFER.open_pos('split', filename, linenr, colum)
|
||||
noautocmd normal! :
|
||||
@ -591,7 +604,7 @@ function! s:apply_to_quickfix() abort
|
||||
endif
|
||||
let s:preview_able = 0
|
||||
let searching_result = s:BUFFER.buf_get_lines(s:buffer_id, 0, -1, 0)
|
||||
noautocmd q
|
||||
call s:close_flygrep_win()
|
||||
call s:update_history()
|
||||
if !empty(searching_result)
|
||||
cgetexpr join(searching_result, "\n")
|
||||
@ -825,6 +838,11 @@ let s:MPT._keys.close = ["\<Esc>", "\<C-c>"]
|
||||
" files: files for grep, @buffers means listed buffer.
|
||||
" dir: specific a directory for grep
|
||||
function! SpaceVim#plugins#flygrep#open(argv) abort
|
||||
if has('patch-7.4.1557')
|
||||
let s:previous_winid = win_getid()
|
||||
else
|
||||
let s:previous_winid = winnr()
|
||||
endif
|
||||
if empty(s:grep_default_exe)
|
||||
call s:LOGGER.warn(' [flygrep] make sure you have one search tool in your PATH', 1)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user