Patch 8.2.2695

6 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 3, 2021, 7:20:08 AM4/3/21
to vim...@googlegroups.com

Patch 8.2.2695
Problem: Cursor position reset with nested autocommands.
Solution: Only check and reset line numbers for not nested autocommands.
(closes #5820)
Files: src/autocmd.c, src/testdir/test_terminal.vim


*** ../vim-8.2.2694/src/autocmd.c 2021-03-13 15:47:51.573753561 +0100
--- src/autocmd.c 2021-04-03 13:18:38.546931429 +0200
***************
*** 2116,2129 ****
ap->last = FALSE;
ap->last = TRUE;

! // make sure cursor and topline are valid
! check_lnums(TRUE);

do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);

! // restore cursor and topline, unless they were changed
! reset_lnums();

#ifdef FEAT_EVAL
if (eap != NULL)
--- 2116,2131 ----
ap->last = FALSE;
ap->last = TRUE;

! if (nesting == 1)
! // make sure cursor and topline are valid
! check_lnums(TRUE);

do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);

! if (nesting == 1)
! // restore cursor and topline, unless they were changed
! reset_lnums();

#ifdef FEAT_EVAL
if (eap != NULL)
*** ../vim-8.2.2694/src/testdir/test_terminal.vim 2021-03-23 16:25:05.910822743 +0100
--- src/testdir/test_terminal.vim 2021-04-03 13:17:35.003097520 +0200
***************
*** 2002,2006 ****
--- 2002,2033 ----
call delete('Xcolorscript')
endfunc

+ function On_BufFilePost()
+ doautocmd <nomodeline> User UserEvent
+ endfunction
+
+ func Test_terminal_nested_autocmd()
+ new
+ call setline(1, range(500))
+ $
+ let lastline = line('.')
+
+ augroup TermTest
+ autocmd BufFilePost * call On_BufFilePost()
+ autocmd User UserEvent silent
+ augroup END
+
+ let cmd = Get_cat_123_cmd()
+ let buf = term_start(cmd, #{term_finish: 'close', hidden: 1})
+ call assert_equal(lastline, line('.'))
+
+ call TermWait(buf)
+ exe buf . 'bwipe'
+ call delete('Xtext')
+ augroup TermTest
+ au!
+ augroup END
+ endfunc
+

" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2694/src/version.c 2021-04-02 18:55:52.062322762 +0200
--- src/version.c 2021-04-03 13:09:53.956267704 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2695,
/**/

--
Microsoft is to software what McDonalds is to gourmet cooking

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages