Skip to content

Commit ab9fc7e

Browse files
committed
patch 7.4.1266
Problem: A BufAdd autocommand may cause an ml_get error (Christian Brabandt) Solution: Increment RedrawingDisabled earlier.
1 parent f416086 commit ab9fc7e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/ex_cmds.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,6 +3268,7 @@ do_ecmd(
32683268
int did_get_winopts = FALSE;
32693269
#endif
32703270
int readfile_flags = 0;
3271+
int did_inc_redrawing_disabled = FALSE;
32713272

32723273
if (eap != NULL)
32733274
command = eap->do_ecmd_cmd;
@@ -3600,6 +3601,11 @@ do_ecmd(
36003601
oldbuf = (flags & ECMD_OLDBUF);
36013602
}
36023603

3604+
/* Don't redraw until the cursor is in the right line, otherwise
3605+
* autocommands may cause ml_get errors. */
3606+
++RedrawingDisabled;
3607+
did_inc_redrawing_disabled = TRUE;
3608+
36033609
#ifdef FEAT_AUTOCMD
36043610
buf = curbuf;
36053611
#endif
@@ -3697,9 +3703,6 @@ do_ecmd(
36973703
/*
36983704
* If we get here we are sure to start editing
36993705
*/
3700-
/* don't redraw until the cursor is in the right line */
3701-
++RedrawingDisabled;
3702-
37033706
/* Assume success now */
37043707
retval = OK;
37053708

@@ -3899,6 +3902,7 @@ do_ecmd(
38993902
#endif
39003903

39013904
--RedrawingDisabled;
3905+
did_inc_redrawing_disabled = FALSE;
39023906
if (!skip_redraw)
39033907
{
39043908
n = p_so;
@@ -3933,6 +3937,8 @@ do_ecmd(
39333937
#endif
39343938

39353939
theend:
3940+
if (did_inc_redrawing_disabled)
3941+
--RedrawingDisabled;
39363942
#ifdef FEAT_AUTOCMD
39373943
if (did_set_swapcommand)
39383944
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
1266,
745747
/**/
746748
1265,
747749
/**/

0 commit comments

Comments
 (0)