Replace current buffer if unchanged

This commit is contained in:
Shy 2017-03-28 17:50:56 +02:00
parent a1edf556d0
commit 6d88ca4fa1

View file

@ -47,7 +47,11 @@ function C4ctrl(cmd, ...)
if stridx("get", a:cmd) == 0 if stridx("get", a:cmd) == 0
" Read current status into new buffer " Read current status into new buffer
new if getbufinfo("%")[0].changed
vnew
else
enew
endif
set filetype=conf set filetype=conf
silent execute "0 read !" s:c4ctrl "-o -" silent execute "0 read !" s:c4ctrl "-o -"
@ -67,7 +71,13 @@ function C4ctrl(cmd, ...)
echoerr "Error: could not open file" s:fn echoerr "Error: could not open file" s:fn
return return
endif endif
execute "new" fnameescape(s:fn)
if getbufinfo("%")[0].changed
vnew
else
enew
endif
execute "edit" fnameescape(s:fn)
elseif stridx("set", a:cmd) == 0 elseif stridx("set", a:cmd) == 0
" Set preset from current buffer " Set preset from current buffer