]> granicus.if.org Git - vim/commitdiff
patch 9.0.0085: ":write" fails after ":file name" and the ":edit" v9.0.0085
authorii14 <ii14@users.noreply.github.com>
Tue, 26 Jul 2022 18:44:56 +0000 (19:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Jul 2022 18:44:56 +0000 (19:44 +0100)
Problem:    ":write" fails after ":file name" and the ":edit".
Solution:   Reset BF_NOTEDITED when using ":edit". (closes #10790)

src/ex_cmds.c
src/testdir/test_excmd.vim
src/version.c

index 5253863c871f98f6d638dbe472e2025e90ce95bf..6e5e09fbf113c798adf086bdaee62a3320035eaa 100644 (file)
@@ -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.
      */
index f55e6a51cf9fc86bad49178c823c82f9b9c5e2a1..7b270ff6fb1338d6e839af6d32477f885a5a1073 100644 (file)
@@ -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
index 03b65d2472e320dd12f17d9d0df6cfc8ee0dd672..a0caf3e9c3b51d2f04d50d92d47307a8fa91c2c8 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    85,
 /**/
     84,
 /**/