summaryrefslogtreecommitdiffstats
path: root/runtime/autoload
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2024-06-04 18:15:57 +0200
committerChristian Brabandt <cb@256bit.org>2024-06-04 18:18:16 +0200
commit98b73eb645b68b6e197b63bbbae777b388d47612 (patch)
treeae4bba5c03cd1f1421a626e6197f6a26052cddcf /runtime/autoload
parent60c8743ab6c90e402e6ed49d27455ef7e5698abe (diff)
runtime(netrw): prevent accidental data loss
fixes: #14915 Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/netrw.vim4
1 files changed, 4 insertions, 0 deletions
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index a9c88f0398..300729eba8 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -13,6 +13,7 @@
" 2024 May 09 by Vim Project: remove hard-coded private.ppk
" 2024 May 10 by Vim Project: recursively delete directories by default
" 2024 May 13 by Vim Project: prefer scp over pscp
+" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@@ -5724,6 +5725,9 @@ fun! s:NetrwEditFile(cmd,opt,fname)
exe "NetrwKeepj keepalt ".a:opt." ".a:cmd." ".fnameescape(a:fname)
else
" call Decho("exe NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname))
+ if a:cmd =~# 'e\%[new]!' && !&hidden && getbufvar(bufname('%'), '&modified', 0)
+ call setbufvar(bufname('%'), '&bufhidden', 'hide')
+ endif
exe "NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname)
endif
" call Dret("s:NetrwEditFile")