mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 02:20:03 +08:00
Undo general quited window
This commit is contained in:
parent
5c9d745935
commit
d7a9ec1b75
@ -17,6 +17,7 @@ function! SpaceVim#autocmds#init() abort
|
|||||||
\ q | endif
|
\ q | endif
|
||||||
autocmd FileType jsp call JspFileTypeInit()
|
autocmd FileType jsp call JspFileTypeInit()
|
||||||
autocmd QuitPre * call SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo()
|
autocmd QuitPre * call SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo()
|
||||||
|
autocmd WinEnter * call SpaceVim#plugins#windowsmanager#MarkBaseWin()
|
||||||
autocmd FileType html,css,jsp EmmetInstall
|
autocmd FileType html,css,jsp EmmetInstall
|
||||||
autocmd BufRead,BufNewFile *.pp setfiletype puppet
|
autocmd BufRead,BufNewFile *.pp setfiletype puppet
|
||||||
if g:spacevim_enable_cursorline == 1
|
if g:spacevim_enable_cursorline == 1
|
||||||
|
@ -2,12 +2,17 @@ let s:TAB = SpaceVim#api#import('vim#tab')
|
|||||||
|
|
||||||
let s:restore_windows_stack = []
|
let s:restore_windows_stack = []
|
||||||
|
|
||||||
|
let s:unmarked = 0
|
||||||
|
|
||||||
|
|
||||||
function! s:get_window_restore_data() abort
|
function! s:get_window_restore_data() abort
|
||||||
let win_data = {
|
let win_data = {
|
||||||
\ 'bufid': bufnr('%'),
|
\ 'bufname': fnamemodify(bufname('%'), ':p'),
|
||||||
\ 'tabpagenr': tabpagenr(),
|
\ 'tabpagenr': tabpagenr(),
|
||||||
\ 'view': winsaveview(),
|
\ 'view': winsaveview(),
|
||||||
|
\ 'newtab':0,
|
||||||
|
\ 'oldwinid' : -1,
|
||||||
|
\ 'same_w' : 0,
|
||||||
\ }
|
\ }
|
||||||
return win_data
|
return win_data
|
||||||
endfunction
|
endfunction
|
||||||
@ -16,10 +21,16 @@ function! SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo() abort
|
|||||||
if !&buflisted
|
if !&buflisted
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
let s:unmarked = 1
|
||||||
let win_data = s:get_window_restore_data()
|
let win_data = s:get_window_restore_data()
|
||||||
if len(tabpagebuflist()) == 1
|
if len(tabpagebuflist()) == 1
|
||||||
let win_data.neighbour_buffer = ''
|
let win_data.newtab = 1
|
||||||
let win_data.open_command = (tabpagenr() - 1).'tabnew'
|
let win_data.open_command = (tabpagenr() - 1).'tabnew'
|
||||||
|
else
|
||||||
|
if winwidth(winnr()) == &columns
|
||||||
|
let win_data.same_w = 1
|
||||||
|
endif
|
||||||
|
let win_data.oldwinid = winnr()
|
||||||
endif
|
endif
|
||||||
call add(s:restore_windows_stack, win_data)
|
call add(s:restore_windows_stack, win_data)
|
||||||
endfunction
|
endfunction
|
||||||
@ -29,7 +40,31 @@ function! SpaceVim#plugins#windowsmanager#UndoQuitWin()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let win_data = remove(s:restore_windows_stack, -1)
|
let win_data = remove(s:restore_windows_stack, -1)
|
||||||
if win_data.neighbour_buffer != ''
|
if win_data.newtab
|
||||||
|
exe win_data.open_command . ' ' . win_data.bufname
|
||||||
|
else
|
||||||
|
exe win_data.open_command
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#plugins#windowsmanager#MarkBaseWin()
|
||||||
|
if s:unmarked
|
||||||
|
let win_data = s:restore_windows_stack[-1]
|
||||||
|
if win_data.same_w
|
||||||
|
" split
|
||||||
|
if win_data.oldwinid == winnr()
|
||||||
|
let win_data.open_command = 'topleft split ' . win_data.bufname
|
||||||
|
else
|
||||||
|
let win_data.open_command = 'rightbelow split ' . win_data.bufname
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
" vsplit
|
||||||
|
if win_data.oldwinid == winnr()
|
||||||
|
let win_data.open_command = 'topleft vsplit ' . win_data.bufname
|
||||||
|
else
|
||||||
|
let win_data.open_command = 'rightbelow vsplit ' . win_data.bufname
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let s:unmarked = 0
|
||||||
endif
|
endif
|
||||||
exe win_data.open_command . ' | b ' win_data.bufid
|
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user