patch 9.1.0192: drop: don't rewind when editing the same file

Commit: 
https://github.com/vim/vim/commit/978178823b7c62a0249411f3d1f584f8a3144c5d
Author: Christian Brabandt <c...@256bit.org>
Date:   Wed Mar 20 20:19:47 2024 +0100

    patch 9.1.0192: drop: don't rewind when editing the same file
    
    Problem:  :drop tries to :rewind the argumentlist, which results in E37
              (after v9.1.0046)
    Solution: instead of calling ex_rewind(), call open_buffer() only when
              re-using the initial empty buffer
    
    fixes: #14219
    closes: #14220
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index d0fc928e6..2527476a2 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -5503,7 +5503,8 @@ ex_drop(exarg_T *eap)
                buf_check_timestamp(curbuf, FALSE);
                curbuf->b_p_ar = save_ar;
            }
-           ex_rewind(eap);
+           if (buf->b_ml.ml_flags & ML_EMPTY)
+               open_buffer(FALSE, eap, 0);
            return;
        }
     }
diff --git a/src/testdir/dumps/Test_drop_modified_1.dump 
b/src/testdir/dumps/Test_drop_modified_1.dump
new file mode 100644
index 000000000..bbd60c088
--- /dev/null
+++ b/src/testdir/dumps/Test_drop_modified_1.dump
@@ -0,0 +1,10 @@
+>T+0&#ffffff0|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|e|d| |o|v|e|r| 
|t|h|e| |l|a|z|y| |d|o|g|s| @29
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|d|r|o|p| |X|d|r|o|p|_|m|o|d|i|f|i|e|d|.|t|x|t| @32|1|,|1| 
@10|A|l@1| 
diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim
index 6a7829b78..221ceb0f0 100644
--- a/src/testdir/test_excmd.vim
+++ b/src/testdir/test_excmd.vim
@@ -3,6 +3,7 @@
 source check.vim
 source shared.vim
 source term_util.vim
+source screendump.vim
 
 func Test_ex_delete()
   new
@@ -738,4 +739,19 @@ func Test_ex_address_range_overflow()
   call assert_fails(':--+foobar', 'E492:')
 endfunc
 
+func Test_drop_modified_file()
+  CheckScreendump
+  let lines =<< trim END
+  call setline(1, 'The quick brown fox jumped over the lazy dogs')
+  END
+  call writefile([''], 'Xdrop_modified.txt', 'D')
+  call writefile(lines, 'Xtest_drop_modified', 'D')
+  let buf = RunVimInTerminal('-S Xtest_drop_modified Xdrop_modified.txt', 
{'rows': 10,'columns': 40})
+  call term_sendkeys(buf, ":drop Xdrop_modified.txt\<CR>")
+  call VerifyScreenDump(buf, 'Test_drop_modified_1', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 348ec1176..dc97d9bda 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    192,
 /**/
     191,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rn1dX-00DUXj-MM%40256bit.org.

Raspunde prin e-mail lui