1
0
forked from aniani/vim

patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move

Problem:    A BufReadPre autocommand may cause the cursor to move.
Solution:   Restore the cursor position after executing the autocommand,
            unless the autocommand moved it. (Christian Brabandt,
            closes #4302, closes #4294)
This commit is contained in:
Bram Moolenaar
2019-04-25 22:22:01 +02:00
parent a561a41a70
commit a68e595909
6 changed files with 97 additions and 1 deletions

View File

@@ -2123,9 +2123,16 @@ apply_autocmds_group(
for (ap = patcmd.curpat; ap->next != NULL; ap = ap->next)
ap->last = FALSE;
ap->last = TRUE;
check_lnums(TRUE); // make sure cursor and topline are valid
// 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)
{