summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-21 17:13:14 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-21 17:13:14 +0200
commitb8bd2e6ebab03baf2672067067a599df69a278c0 (patch)
treec0a490909a31bc6ab7ede44e1c490ef289f949e3 /src
parent489d60996deb5e7c1a3b4633412d54632e6def42 (diff)
downloadvim-git-b8bd2e6ebab03baf2672067067a599df69a278c0.tar.gz
patch 8.2.3363: when :edit reuses the current buffer the alternate file is setv8.2.3363
Problem: When :edit reuses the current buffer the alternate file is set to the same buffer. Solution: Only set the alternate file when not reusing the buffer. (closes #8783)
Diffstat (limited to 'src')
-rw-r--r--src/ex_cmds.c6
-rw-r--r--src/testdir/test_cmdline.vim2
-rw-r--r--src/testdir/test_undo.vim2
-rw-r--r--src/testdir/test_vim9_builtin.vim2
-rw-r--r--src/testdir/test_vim9_script.vim2
-rw-r--r--src/version.c2
6 files changed, 12 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index d30db9195..021296d38 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2648,6 +2648,8 @@ do_ecmd(
*/
if (other_file)
{
+ int prev_alt_fnum = curwin->w_alt_fnum;
+
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF)))
{
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
@@ -2691,6 +2693,10 @@ do_ecmd(
}
if (buf == NULL)
goto theend;
+ if (curwin->w_alt_fnum == buf->b_fnum && prev_alt_fnum != 0)
+ // reusing the buffer, keep the old alternate file
+ curwin->w_alt_fnum = prev_alt_fnum;
+
if (buf->b_ml.ml_mfp == NULL) // no memfile yet
{
oldbuf = FALSE;
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index d04bb4c8c..bd2ca03b6 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -1365,7 +1365,7 @@ endfunc
" Test for expanding special keywords in cmdline
func Test_cmdline_expand_special()
%bwipe!
- call assert_fails('e #', 'E499:')
+ call assert_fails('e #', 'E194:')
call assert_fails('e <afile>', 'E495:')
call assert_fails('e <abuf>', 'E496:')
call assert_fails('e <amatch>', 'E497:')
diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim
index 2621412fa..bfcc538d9 100644
--- a/src/testdir/test_undo.vim
+++ b/src/testdir/test_undo.vim
@@ -582,7 +582,7 @@ func Test_undofile_2()
" add 10 lines, delete 6 lines, undo 3
set undofile
- call setbufline(0, 1, ['one', 'two', 'three', 'four', 'five', 'six',
+ call setbufline('%', 1, ['one', 'two', 'three', 'four', 'five', 'six',
\ 'seven', 'eight', 'nine', 'ten'])
set undolevels=100
normal 3Gdd
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 00d021fe1..434f47748 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1268,7 +1268,7 @@ enddef
def Test_getbufline()
e SomeFile
var buf = bufnr()
- e #
+ sp Otherfile
var lines = ['aaa', 'bbb', 'ccc']
setbufline(buf, 1, lines)
getbufline('#', 1, '$')->assert_equal(lines)
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index ffea2acb2..fd93c3a8b 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -3495,7 +3495,7 @@ def Test_vim9_comment_gui()
CheckScriptFailure([
'vim9script',
'gui -f#comment'
- ], 'E499:')
+ ], 'E194:')
enddef
def Test_vim9_comment_not_compiled()
diff --git a/src/version.c b/src/version.c
index dfe949d9d..25e0d82ff 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3363,
+/**/
3362,
/**/
3361,