@@ -6,13 +6,22 @@ set cpo&vim
6
6
" Check if buffer {bufnr} is persistent:
7
7
" @signature: stay#ispersistent({bufnr:Number}, {volatile_ftypes:List<String>})
8
8
" @returns: Boolean
9
+ " @notes: the persistence heuristics are
10
+ " - buffer must be listed
11
+ " - buffer must be of ordinary or "acwrite" 'buftype'
12
+ " - not a preview window
13
+ " - not a diff window
14
+ " - buffer's 'bufhidden' must be empty or "hide"
15
+ " - buffer must not be of a volatile file type
16
+ " - buffer must map to a readable file
9
17
function ! stay#ispersistent (bufnr , volatile_ftypes) abort
10
18
return bufexists (a: bufnr )
11
19
\ && getbufvar (a: bufnr , ' stay_ignore' , 0 ) isnot 1
20
+ \ && getbufvar (a: bufnr , ' &buflisted' ) is 1
12
21
\ && index ([' ' , ' acwrite' ], getbufvar (a: bufnr , ' &buftype' )) isnot -1
13
22
\ && getbufvar (a: bufnr , ' &previewwindow' ) isnot 1
14
23
\ && getbufvar (a: bufnr , ' &diff' ) isnot 1
15
- \ && getbufvar (a: bufnr , ' &bufhidden' ) isnot # ' wipe '
24
+ \ && index ([ ' ' , ' hide ' ], getbufvar (a: bufnr , ' &bufhidden' )) isnot -1
16
25
\ && index (a: volatile_ftypes , getbufvar (a: bufnr , ' &filetype' )) is -1
17
26
\ && filereadable (fnamemodify (bufname (a: bufnr ), ' :p' ))
18
27
endfunction
0 commit comments