Mercurial > vim
diff src/autocmd.c @ 16401:3b2db762a509 v8.1.1205
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
commit https://github.com/vim/vim/commit/a68e59590905da9b4448ff1fcac929ad1a18da9e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 25 22:22:01 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Apr 2019 22:30:05 +0200 |
parents | 0f65f2808470 |
children | ef00b6bc186b |
line wrap: on
line diff
--- 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) {