aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-01 01:02:17 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-01 01:02:17 +1200
commit441ddd1ef80d4c8285c32d78bb53f3194822f45e (patch)
treeae6d56bedf92aa802b69a9190c198bac386dcd49
parentMerge branch 'release/v1.0.0' into develop (diff)
downloadvim-write-mkpath-441ddd1ef80d4c8285c32d78bb53f3194822f45e.tar.gz
vim-write-mkpath-441ddd1ef80d4c8285c32d78bb53f3194822f45e.zip
Clean up alternate file buffer on :file
-rw-r--r--autoload/write_mkpath.vim10
1 files changed, 9 insertions, 1 deletions
diff --git a/autoload/write_mkpath.vim b/autoload/write_mkpath.vim
index bfe45bd..6b1855d 100644
--- a/autoload/write_mkpath.vim
+++ b/autoload/write_mkpath.vim
@@ -18,9 +18,17 @@ function! write_mkpath#New(path) abort
endif
" Set filename to absolute path using :file {name}; do it silently so that
- " the nice name remains displayed to the user
+ " the nice name remains displayed to the user. Record the name of the
+ " alternate buffer first, so we can put it back after :file messes with it.
+ let alt = @#
execute 'silent file '.fnameescape(getcwd().'/'.a:path)
+ " That :file command will have set the alternate buffer to an unlisted
+ " buffer of the same name, which we don't want. Wipe it, and restore the
+ " previous alternative buffer.
+ bwipe #
+ let @# = alt
+
endfunction
" Handle a :write operation; prompt for directory creation if needed with