@@ -423,18 +423,20 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
423423 set noswapfile
424424 mksession !
425425
426- let content = [' set nocp noswapfile' ,
427- \ ' let v:swapchoice="e"' ,
428- \ ' augroup test_autocmd_sessionload' ,
429- \ ' autocmd!' ,
430- \ ' autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"' ,
431- \ ' augroup END' ,
432- \ ' ' ,
433- \ ' func WriteErrors()' ,
434- \ ' call writefile([execute("messages")], "Xerrors")' ,
435- \ ' endfunc' ,
436- \ ' au VimLeave * call WriteErrors()' ,
437- \ ]
426+ let content = << trim [CODE]
427+ set nocp noswapfile
428+ let v: swapchoice= " e"
429+ augroup test_autocmd_sessionload
430+ autocmd !
431+ autocmd SessionLoadPost * exe bufnr (" Xsomething" ) . " bw!"
432+ augroup END
433+
434+ func WriteErrors ()
435+ call writefile ([execute (" messages" )], " Xerrors" )
436+ endfunc
437+ au VimLeave * call WriteErrors ()
438+ [CODE]
439+
438440 call writefile (content, ' Xvimrc' )
439441 call system (v: progpath . ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq' )
440442 let errors = join (readfile (' Xerrors' ))
@@ -452,27 +454,29 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
452454 set noswapfile
453455 mksession !
454456
455- let content = [' set nocp noswapfile' ,
456- \ ' function! DeleteInactiveBufs()' ,
457- \ ' tabfirst' ,
458- \ ' let tabblist = []' ,
459- \ ' for i in range(1, tabpagenr('' $'' ))' ,
460- \ ' call extend(tabblist, tabpagebuflist(i))' ,
461- \ ' endfor' ,
462- \ ' for b in range(1, bufnr('' $'' ))' ,
463- \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# '' ^$'' )' ,
464- \ ' exec '' bwipeout '' . b' ,
465- \ ' endif' ,
466- \ ' endfor' ,
467- \ ' echomsg "SessionLoadPost DONE"' ,
468- \ ' endfunction' ,
469- \ ' au SessionLoadPost * call DeleteInactiveBufs()' ,
470- \ ' ' ,
471- \ ' func WriteErrors()' ,
472- \ ' call writefile([execute("messages")], "Xerrors")' ,
473- \ ' endfunc' ,
474- \ ' au VimLeave * call WriteErrors()' ,
475- \ ]
457+ let content = << trim [CODE]
458+ set nocp noswapfile
459+ function ! DeleteInactiveBufs ()
460+ tabfirst
461+ let tabblist = []
462+ for i in range (1 , tabpagenr (' ' $ ' ' ))
463+ call extend (tabblist, tabpagebuflist (i ))
464+ endfor
465+ for b in range (1 , bufnr (' ' $ ' ' ))
466+ if bufexists (b ) && buflisted (b ) && (index (tabblist, b ) == -1 || bufname (b ) = ~# ' ' ^$ ' ' )
467+ exec ' ' bwipeout ' ' . b
468+ endif
469+ endfor
470+ echomsg " SessionLoadPost DONE"
471+ endfunction
472+ au SessionLoadPost * call DeleteInactiveBufs ()
473+
474+ func WriteErrors ()
475+ call writefile ([execute (" messages" )], " Xerrors" )
476+ endfunc
477+ au VimLeave * call WriteErrors ()
478+ [CODE]
479+
476480 call writefile (content, ' Xvimrc' )
477481 call system (v: progpath . ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq' )
478482 let errors = join (readfile (' Xerrors' ))
@@ -933,21 +937,23 @@ func Test_bufunload_all()
933937 call writefile ([' Test file Xxx1' ], ' Xxx1' )"
934938 call writefile ([' Test file Xxx2' ], ' Xxx2' )"
935939
936- let content = [
937- \ " func UnloadAllBufs()" ,
938- \ " let i = 1" ,
939- \ " while i <= bufnr('$')" ,
940- \ " if i != bufnr('%') && bufloaded(i)" ,
941- \ " exe i . 'bunload'" ,
942- \ " endif" ,
943- \ " let i += 1" ,
944- \ " endwhile" ,
945- \ " endfunc" ,
946- \ " au BufUnload * call UnloadAllBufs()" ,
947- \ " au VimLeave * call writefile(['Test Finished'], 'Xout')" ,
948- \ " edit Xxx1" ,
949- \ " split Xxx2" ,
950- \ " q" ]
940+ let content = << trim [CODE]
941+ func UnloadAllBufs ()
942+ let i = 1
943+ while i <= bufnr (' $' )
944+ if i != bufnr (' %' ) && bufloaded (i )
945+ exe i . ' bunload'
946+ endif
947+ let i += 1
948+ endwhile
949+ endfunc
950+ au BufUnload * call UnloadAllBufs ()
951+ au VimLeave * call writefile ([' Test Finished' ], ' Xout' )
952+ edit Xxx1
953+ split Xxx2
954+ q
955+ [CODE]
956+
951957 call writefile (content, ' Xtest' )
952958
953959 call delete (' Xout' )
0 commit comments