diff src/autocmd.c @ 24309:f8619a303e9d v8.2.2695

patch 8.2.2695: cursor position reset with nested autocommands Commit: https://github.com/vim/vim/commit/1e6bbfb5607c82d872070219c26e2aae20db68ed Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 3 13:19:26 2021 +0200 patch 8.2.2695: cursor position reset with nested autocommands Problem: Cursor position reset with nested autocommands. Solution: Only check and reset line numbers for not nested autocommands. (closes #5820)
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Apr 2021 13:30:15 +0200
parents 03438d77d8ab
children 05f9e8f2016c
line wrap: on
line diff
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -2116,14 +2116,16 @@ apply_autocmds_group(
 	    ap->last = FALSE;
 	ap->last = TRUE;
 
-	// make sure cursor and topline are valid
-	check_lnums(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);
 
-	// restore cursor and topline, unless they were changed
-	reset_lnums();
+	if (nesting == 1)
+	    // restore cursor and topline, unless they were changed
+	    reset_lnums();
 
 #ifdef FEAT_EVAL
 	if (eap != NULL)