Mercurial > vim
changeset 29487:4f52a21f41f3 v9.0.0085
patch 9.0.0085: ":write" fails after ":file name" and the ":edit"
Commit: https://github.com/vim/vim/commit/1f0dc5e84f5cc530c0fb9d0789e3d42d644429d7
Author: ii14 <ii14@users.noreply.github.com>
Date: Tue Jul 26 19:44:56 2022 +0100
patch 9.0.0085: ":write" fails after ":file name" and the ":edit"
Problem: ":write" fails after ":file name" and the ":edit".
Solution: Reset BF_NOTEDITED when using ":edit". (closes https://github.com/vim/vim/issues/10790)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Jul 2022 21:00:03 +0200 |
parents | 1781af579a97 |
children | 0bca7d819ae5 |
files | src/ex_cmds.c src/testdir/test_excmd.vim src/version.c |
diffstat | 3 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2973,6 +2973,11 @@ do_ecmd( // Assume success now retval = OK; + // If the file name was changed, reset the not-edit flag so that ":write" + // works. + if (!other_file) + curbuf->b_flags &= ~BF_NOTEDITED; + /* * Check if we are editing the w_arg_idx file in the argument list. */
--- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -725,5 +725,21 @@ func Test_using_zero_in_range() bwipe! endfunc +" Test :write after changing name with :file and loading it with :edit +func Test_write_after_rename() + call writefile(['text'], 'Xfile') + + enew + file Xfile + call assert_fails('write', 'E13: File exists (add ! to override)') + + " works OK after ":edit" + edit + write + + call delete('Xfile') + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab