mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-26 02:10:12 +08:00
dont clobber "special" windows when opening files
if the user tries to open a file and the previous window is "special" (eg the quickfix window or another explorer plugin) then force a new split to be opened instead
This commit is contained in:
parent
737ad58740
commit
24ad44b46f
|
@ -2450,16 +2450,28 @@ endfunction
|
||||||
"Args:
|
"Args:
|
||||||
"winnumber: the number of the window in question
|
"winnumber: the number of the window in question
|
||||||
function! s:ShouldSplitToOpen(winnumber)
|
function! s:ShouldSplitToOpen(winnumber)
|
||||||
if &hidden
|
"gotta split if theres only one window (i.e. the NERD tree)
|
||||||
return 0
|
if winnr("$") == 1
|
||||||
|
return 1
|
||||||
endif
|
endif
|
||||||
let oldwinnr = winnr()
|
|
||||||
|
|
||||||
|
let oldwinnr = winnr()
|
||||||
exec a:winnumber . "wincmd p"
|
exec a:winnumber . "wincmd p"
|
||||||
|
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
|
||||||
let modified = &modified
|
let modified = &modified
|
||||||
exec oldwinnr . "wincmd p"
|
exec oldwinnr . "wincmd p"
|
||||||
|
|
||||||
return winnr("$") == 1 || (modified && s:BufInWindows(winbufnr(a:winnumber)) < 2)
|
"if its a special window e.g. quickfix or another explorer plugin then we
|
||||||
|
"have to split
|
||||||
|
if specialWindow
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if &hidden
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return modified && s:BufInWindows(winbufnr(a:winnumber)) < 2
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:StripMarkupFromLine(line, removeLeadingSpaces){{{2
|
"FUNCTION: s:StripMarkupFromLine(line, removeLeadingSpaces){{{2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user