comparison 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
comparison
equal deleted inserted replaced
16400:73200ce89e05 16401:3b2db762a509
2121 // mark the last pattern, to avoid an endless loop when more patterns 2121 // mark the last pattern, to avoid an endless loop when more patterns
2122 // are added when executing autocommands 2122 // are added when executing autocommands
2123 for (ap = patcmd.curpat; ap->next != NULL; ap = ap->next) 2123 for (ap = patcmd.curpat; ap->next != NULL; ap = ap->next)
2124 ap->last = FALSE; 2124 ap->last = FALSE;
2125 ap->last = TRUE; 2125 ap->last = TRUE;
2126 check_lnums(TRUE); // make sure cursor and topline are valid 2126
2127 // make sure cursor and topline are valid
2128 check_lnums(TRUE);
2129
2127 do_cmdline(NULL, getnextac, (void *)&patcmd, 2130 do_cmdline(NULL, getnextac, (void *)&patcmd,
2128 DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT); 2131 DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
2132
2133 // restore cursor and topline, unless they were changed
2134 reset_lnums();
2135
2129 #ifdef FEAT_EVAL 2136 #ifdef FEAT_EVAL
2130 if (eap != NULL) 2137 if (eap != NULL)
2131 { 2138 {
2132 (void)set_cmdarg(NULL, save_cmdarg); 2139 (void)set_cmdarg(NULL, save_cmdarg);
2133 set_vim_var_nr(VV_CMDBANG, save_cmdbang); 2140 set_vim_var_nr(VV_CMDBANG, save_cmdbang);