Patch 8.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)
Files: src/ex_cmds.c, src/testdir/test_undo.vim,
src/testdir/test_cmdline.vim, src/testdir/test_vim9_builtin.vim,
src/testdir/test_vim9_script.vim
*** ../vim-8.2.3362/src/ex_cmds.c 2021-08-05 20:39:59.350053671 +0200
--- src/ex_cmds.c 2021-08-21 16:47:34.971260514 +0200
***************
*** 2648,2653 ****
--- 2648,2655 ----
*/
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,2696 ****
--- 2693,2702 ----
}
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;
*** ../vim-8.2.3362/src/testdir/test_undo.vim 2021-03-22 19:37:02.545019774
+0100
--- src/testdir/test_undo.vim 2021-08-21 17:04:48.518279705 +0200
***************
*** 582,588 ****
" add 10 lines, delete 6 lines, undo 3
set undofile
! call setbufline(0, 1, ['one', 'two', 'three', 'four', 'five', 'six',
\ 'seven', 'eight', 'nine', 'ten'])
set undolevels=100
normal 3Gdd
--- 582,588 ----
" add 10 lines, delete 6 lines, undo 3
set undofile
! call setbufline('%', 1, ['one', 'two', 'three', 'four', 'five', 'six',
\ 'seven', 'eight', 'nine', 'ten'])
set undolevels=100
normal 3Gdd
*** ../vim-8.2.3362/src/testdir/test_cmdline.vim 2021-08-19
21:20:36.705042718 +0200
--- src/testdir/test_cmdline.vim 2021-08-21 17:05:43.566188728 +0200
***************
*** 1365,1371 ****
" Test for expanding special keywords in cmdline
func Test_cmdline_expand_special()
%bwipe!
! call assert_fails('e #', 'E499:')
call assert_fails('e <afile>', 'E495:')
call assert_fails('e <abuf>', 'E496:')
call assert_fails('e <amatch>', 'E497:')
--- 1365,1371 ----
" Test for expanding special keywords in cmdline
func Test_cmdline_expand_special()
%bwipe!
! call assert_fails('e #', 'E194:')
call assert_fails('e <afile>', 'E495:')
call assert_fails('e <abuf>', 'E496:')
call assert_fails('e <amatch>', 'E497:')
*** ../vim-8.2.3362/src/testdir/test_vim9_builtin.vim 2021-08-16
21:38:38.131122584 +0200
--- src/testdir/test_vim9_builtin.vim 2021-08-21 17:01:23.762600180 +0200
***************
*** 1268,1274 ****
def Test_getbufline()
e SomeFile
var buf = bufnr()
! e #
var lines = ['aaa', 'bbb', 'ccc']
setbufline(buf, 1, lines)
getbufline('#', 1, '$')->assert_equal(lines)
--- 1268,1274 ----
def Test_getbufline()
e SomeFile
var buf = bufnr()
! sp Otherfile
var lines = ['aaa', 'bbb', 'ccc']
setbufline(buf, 1, lines)
getbufline('#', 1, '$')->assert_equal(lines)
*** ../vim-8.2.3362/src/testdir/test_vim9_script.vim 2021-08-20
20:54:20.558119674 +0200
--- src/testdir/test_vim9_script.vim 2021-08-21 16:44:21.359091852 +0200
***************
*** 3495,3501 ****
CheckScriptFailure([
'vim9script',
'gui -f#comment'
! ], 'E499:')
enddef
def Test_vim9_comment_not_compiled()
--- 3495,3501 ----
CheckScriptFailure([
'vim9script',
'gui -f#comment'
! ], 'E194:')
enddef
def Test_vim9_comment_not_compiled()
*** ../vim-8.2.3362/src/version.c 2021-08-21 16:21:14.662455461 +0200
--- src/version.c 2021-08-21 17:12:07.361517377 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3363,
/**/
--
Behold the warranty! The bold print giveth and the fine print taketh.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202108211513.17LFDhVq1130819%40masaka.moolenaar.net.