FIX: Must not :set readonly if no scratch contents

The previous split of ingo#buffer#generate#Create() subtly changed the behavior with empty scratch contents. We must not :setlocal readonly if the scratch buffer is still empty.
Add a:isInitialized argument to ingo#buffer#scratch#SetLocal().
This commit is contained in:
Ingo Karkat
2017-09-11 14:19:49 +02:00
parent f32794bcd8
commit f6e2720334
+6 -3
View File
@@ -64,13 +64,16 @@ function! ingo#buffer#scratch#Create( scratchDirspec, scratchFilename, scratchIs
"*******************************************************************************
let l:status = ingo#buffer#generate#Create(a:scratchDirspec, a:scratchFilename, a:scratchIsFile, a:scratchCommand, a:windowOpenCommand)
if l:status != 0
call ingo#buffer#scratch#SetLocal(a:scratchIsFile)
call ingo#buffer#scratch#SetLocal(a:scratchIsFile, ! empty(a:scratchCommand))
endif
return l:status
endfunction
function! ingo#buffer#scratch#SetLocal( isFile )
function! ingo#buffer#scratch#SetLocal( isFile, isInitialized )
execute 'setlocal buftype=' . ingo#buffer#generate#BufType(a:isFile)
setlocal bufhidden=wipe nobuflisted noswapfile readonly
setlocal bufhidden=wipe nobuflisted noswapfile
if a:isInitialized
setlocal readonly
endif
endfunction
" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax :