From f6e2720334d98790847865b224c19c0793033aa3 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Mon, 11 Sep 2017 14:19:49 +0200 Subject: [PATCH] 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(). --- autoload/ingo/buffer/scratch.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autoload/ingo/buffer/scratch.vim b/autoload/ingo/buffer/scratch.vim index ef87ca8..884e3d8 100644 --- a/autoload/ingo/buffer/scratch.vim +++ b/autoload/ingo/buffer/scratch.vim @@ -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 :