neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 289256337a5de9993e592ad0adaea7fef14af86c
parent 7e939ddb874b66414fc09bb1b33c34838b45b184
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Wed, 27 Jul 2022 05:58:27 +0800

Merge pull request #19523 from ii14/vim-9.0.0085

vim-patch:9.0.0085: ":write" fails after ":file name" and the ":edit"
Diffstat:
Msrc/nvim/ex_cmds.c | 6++++++
Msrc/nvim/testdir/test_excmd.vim | 16++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c @@ -2725,6 +2725,12 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum // 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. */ diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim @@ -696,5 +696,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