summaryrefslogtreecommitdiffstats
path: root/src/autocmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-25 22:22:01 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-25 22:22:01 +0200
commita68e59590905da9b4448ff1fcac929ad1a18da9e (patch)
tree34c79c9572424b3daf7d6be1d968d675c674cf10 /src/autocmd.c
parenta561a41a70db7a9367f883c1dbb14e69b3364d08 (diff)
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to movev8.1.1205
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)
Diffstat (limited to 'src/autocmd.c')
-rw-r--r--src/autocmd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 2ea23ccc4f..e6cdb361ed 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -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)
{