Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion plugin/autoswap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function! AS_HandleSwapfile (filename, swapname)
if (strlen(active_window) > 0)
call AS_DelayedMsg('Switched to existing session in another window')
call AS_SwitchToActiveWindow(active_window)
let v:swapchoice = 'q'
call Exit()

" Otherwise, if swapfile is older than file itself, just get rid of it...
elseif getftime(v:swapname) < getftime(a:filename)
Expand All @@ -73,6 +73,21 @@ function! AS_HandleSwapfile (filename, swapname)
endfunction


function! Exit()
if has("nvim") && exists("*GuiClose")
let l:num_buffers = len(getbufinfo({'buflisted':1}))
let l:num_windows = winnr('$')
if l:num_buffers == 1 && l:num_windows == 1
let v:swapchoice = 'o'
autocmd BufEnter * call GuiClose() | q
else
let v:swapchoice = 'q'
endif
else
let v:swapchoice = 'q'
endif
endfunction

" Print a message after the autocommand completes
" (so you can see it, but don't have to hit <ENTER> to continue)...
"
Expand Down