Skip to content

Commit 79cdf02

Browse files
committed
patch 9.0.1571: RedrawingDisabled not used consistently
Problem: RedrawingDisabled not used consistently. Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in win_split_ins(). (closes #11961)
1 parent bf63011 commit 79cdf02

File tree

16 files changed

+86
-65
lines changed

16 files changed

+86
-65
lines changed

src/autocmd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,10 +1602,7 @@ aucmd_prepbuf(
16021602
p_acd = FALSE;
16031603
#endif
16041604

1605-
// no redrawing and don't set the window title
1606-
++RedrawingDisabled;
16071605
(void)win_split_ins(0, WSP_TOP, auc_win, 0);
1608-
--RedrawingDisabled;
16091606
(void)win_comp_pos(); // recompute window positions
16101607
p_ea = save_ea;
16111608
#ifdef FEAT_AUTOCHDIR
@@ -2334,7 +2331,8 @@ apply_autocmds_group(
23342331
active_apc_list = patcmd.next;
23352332
}
23362333

2337-
--RedrawingDisabled;
2334+
if (RedrawingDisabled > 0)
2335+
--RedrawingDisabled;
23382336
autocmd_busy = save_autocmd_busy;
23392337
filechangeshell_busy = FALSE;
23402338
autocmd_nested = save_autocmd_nested;

src/buffer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,11 +2506,10 @@ buflist_getfile(
25062506
}
25072507

25082508
++RedrawingDisabled;
2509+
int retval = FAIL;
25092510
if (GETFILE_SUCCESS(getfile(buf->b_fnum, NULL, NULL,
25102511
(options & GETF_SETMARK), lnum, forceit)))
25112512
{
2512-
--RedrawingDisabled;
2513-
25142513
// cursor is at to BOL and w_cursor.lnum is checked due to getfile()
25152514
if (!p_sol && col != 0)
25162515
{
@@ -2519,10 +2518,12 @@ buflist_getfile(
25192518
curwin->w_cursor.coladd = 0;
25202519
curwin->w_set_curswant = TRUE;
25212520
}
2522-
return OK;
2521+
retval = OK;
25232522
}
2524-
--RedrawingDisabled;
2525-
return FAIL;
2523+
2524+
if (RedrawingDisabled > 0)
2525+
--RedrawingDisabled;
2526+
return retval;
25262527
}
25272528

25282529
/*

src/cmdexpand.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,14 +3937,12 @@ wildmenu_process_key(cmdline_info_T *cclp, int key, expand_T *xp)
39373937
wildmenu_cleanup(cmdline_info_T *cclp UNUSED)
39383938
{
39393939
int skt = KeyTyped;
3940-
#ifdef FEAT_EVAL
3941-
int old_RedrawingDisabled = RedrawingDisabled;
3942-
#endif
39433940

39443941
if (!p_wmnu || wild_menu_showing == 0)
39453942
return;
39463943

39473944
#ifdef FEAT_EVAL
3945+
int save_RedrawingDisabled = RedrawingDisabled;
39483946
if (cclp->input_fn)
39493947
RedrawingDisabled = 0;
39503948
#endif
@@ -3974,7 +3972,7 @@ wildmenu_cleanup(cmdline_info_T *cclp UNUSED)
39743972
wild_menu_showing = 0;
39753973
#ifdef FEAT_EVAL
39763974
if (cclp->input_fn)
3977-
RedrawingDisabled = old_RedrawingDisabled;
3975+
RedrawingDisabled = save_RedrawingDisabled;
39783976
#endif
39793977
}
39803978

src/debugger.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ do_debug(char_u *cmd)
287287
}
288288
vim_free(cmdline);
289289

290-
--RedrawingDisabled;
290+
if (RedrawingDisabled > 0)
291+
--RedrawingDisabled;
291292
--no_wait_return;
292293
redraw_all_later(UPD_NOT_VALID);
293294
need_wait_return = FALSE;

src/edit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3613,7 +3613,8 @@ ins_esc(
36133613
temp = curwin->w_cursor.col;
36143614
if (disabled_redraw)
36153615
{
3616-
--RedrawingDisabled;
3616+
if (RedrawingDisabled > 0)
3617+
--RedrawingDisabled;
36173618
disabled_redraw = FALSE;
36183619
}
36193620
if (!arrow_used)

src/ex_cmds.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,7 +3219,8 @@ do_ecmd(
32193219
(void)keymap_init();
32203220
#endif
32213221

3222-
--RedrawingDisabled;
3222+
if (RedrawingDisabled > 0)
3223+
--RedrawingDisabled;
32233224
did_inc_redrawing_disabled = FALSE;
32243225
if (!skip_redraw)
32253226
{
@@ -3263,7 +3264,7 @@ do_ecmd(
32633264
#endif
32643265

32653266
theend:
3266-
if (did_inc_redrawing_disabled)
3267+
if (did_inc_redrawing_disabled && RedrawingDisabled > 0)
32673268
--RedrawingDisabled;
32683269
#if defined(FEAT_EVAL)
32693270
if (did_set_swapcommand)
@@ -3735,7 +3736,6 @@ ex_substitute(exarg_T *eap)
37353736
int sublen;
37363737
int got_quit = FALSE;
37373738
int got_match = FALSE;
3738-
int temp;
37393739
int which_pat;
37403740
char_u *cmd;
37413741
int save_State;
@@ -4316,7 +4316,7 @@ ex_substitute(exarg_T *eap)
43164316
#endif
43174317
// Invert the matched string.
43184318
// Remove the inversion afterwards.
4319-
temp = RedrawingDisabled;
4319+
int save_RedrawingDisabled = RedrawingDisabled;
43204320
RedrawingDisabled = 0;
43214321

43224322
// avoid calling update_screen() in vgetorpeek()
@@ -4386,7 +4386,7 @@ ex_substitute(exarg_T *eap)
43864386
msg_scroll = i;
43874387
showruler(TRUE);
43884388
windgoto(msg_row, msg_col);
4389-
RedrawingDisabled = temp;
4389+
RedrawingDisabled = save_RedrawingDisabled;
43904390

43914391
#ifdef USE_ON_FLY_SCROLL
43924392
dont_scroll = FALSE; // allow scrolling here

src/ex_docmd.c

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ do_exmode(
550550
#ifdef FEAT_GUI
551551
--hold_gui_events;
552552
#endif
553-
--RedrawingDisabled;
553+
if (RedrawingDisabled > 0)
554+
--RedrawingDisabled;
554555
--no_wait_return;
555556
update_screen(UPD_CLEAR);
556557
need_wait_return = FALSE;
@@ -631,7 +632,7 @@ do_cmdline(
631632
static int recursive = 0; // recursive depth
632633
int msg_didout_before_start = 0;
633634
int count = 0; // line number count
634-
int did_inc = FALSE; // incremented RedrawingDisabled
635+
int did_inc_RedrawingDisabled = FALSE;
635636
int retval = OK;
636637
#ifdef FEAT_EVAL
637638
cstack_T cstack; // conditional stack
@@ -977,7 +978,7 @@ do_cmdline(
977978
msg_scroll = TRUE; // put messages below each other
978979
++no_wait_return; // don't wait for return until finished
979980
++RedrawingDisabled;
980-
did_inc = TRUE;
981+
did_inc_RedrawingDisabled = TRUE;
981982
}
982983
}
983984

@@ -1336,9 +1337,10 @@ do_cmdline(
13361337
* hit return before redrawing the screen. With the ":global" command we do
13371338
* this only once after the command is finished.
13381339
*/
1339-
if (did_inc)
1340+
if (did_inc_RedrawingDisabled)
13401341
{
1341-
--RedrawingDisabled;
1342+
if (RedrawingDisabled > 0)
1343+
--RedrawingDisabled;
13421344
--no_wait_return;
13431345
msg_scroll = FALSE;
13441346

@@ -7170,7 +7172,7 @@ do_exedit(
71707172

71717173
if (exmode_was != EXMODE_VIM)
71727174
settmode(TMODE_RAW);
7173-
int save_rd = RedrawingDisabled;
7175+
int save_RedrawingDisabled = RedrawingDisabled;
71747176
RedrawingDisabled = 0;
71757177
int save_nwr = no_wait_return;
71767178
no_wait_return = 0;
@@ -7187,7 +7189,7 @@ do_exedit(
71877189
main_loop(FALSE, TRUE);
71887190

71897191
pending_exmode_active = FALSE;
7190-
RedrawingDisabled = save_rd;
7192+
RedrawingDisabled = save_RedrawingDisabled;
71917193
no_wait_return = save_nwr;
71927194
msg_scroll = save_ms;
71937195
#ifdef FEAT_GUI
@@ -8438,11 +8440,12 @@ ex_redraw(exarg_T *eap)
84388440
void
84398441
redraw_cmd(int clear)
84408442
{
8441-
int r = RedrawingDisabled;
8442-
int p = p_lz;
8443-
8443+
int save_RedrawingDisabled = RedrawingDisabled;
84448444
RedrawingDisabled = 0;
8445+
8446+
int save_p_lz = p_lz;
84458447
p_lz = FALSE;
8448+
84468449
validate_cursor();
84478450
update_topline();
84488451
update_screen(clear ? UPD_CLEAR : VIsual_active ? UPD_INVERTED : 0);
@@ -8454,8 +8457,8 @@ redraw_cmd(int clear)
84548457
# endif
84558458
resize_console_buf();
84568459
#endif
8457-
RedrawingDisabled = r;
8458-
p_lz = p;
8460+
RedrawingDisabled = save_RedrawingDisabled;
8461+
p_lz = save_p_lz;
84598462

84608463
// After drawing the statusline screen_attr may still be set.
84618464
screen_stop_highlight();
@@ -8480,24 +8483,25 @@ redraw_cmd(int clear)
84808483
static void
84818484
ex_redrawstatus(exarg_T *eap UNUSED)
84828485
{
8483-
int r = RedrawingDisabled;
8484-
int p = p_lz;
8485-
84868486
if (eap->forceit)
84878487
status_redraw_all();
84888488
else
84898489
status_redraw_curbuf();
84908490
if (msg_scrolled && (State & MODE_CMDLINE))
84918491
return; // redraw later
84928492

8493+
int save_RedrawingDisabled = RedrawingDisabled;
84938494
RedrawingDisabled = 0;
8495+
8496+
int save_p_lz = p_lz;
84948497
p_lz = FALSE;
8498+
84958499
if (State & MODE_CMDLINE)
84968500
redraw_statuslines();
84978501
else
84988502
update_screen(VIsual_active ? UPD_INVERTED : 0);
8499-
RedrawingDisabled = r;
8500-
p_lz = p;
8503+
RedrawingDisabled = save_RedrawingDisabled;
8504+
p_lz = save_p_lz;
85018505
out_flush();
85028506
}
85038507

@@ -8507,16 +8511,16 @@ ex_redrawstatus(exarg_T *eap UNUSED)
85078511
static void
85088512
ex_redrawtabline(exarg_T *eap UNUSED)
85098513
{
8510-
int r = RedrawingDisabled;
8511-
int p = p_lz;
8512-
8514+
int save_RedrawingDisabled = RedrawingDisabled;
85138515
RedrawingDisabled = 0;
8516+
8517+
int save_p_lz = p_lz;
85148518
p_lz = FALSE;
85158519

85168520
draw_tabline();
85178521

8518-
RedrawingDisabled = r;
8519-
p_lz = p;
8522+
RedrawingDisabled = save_RedrawingDisabled;
8523+
p_lz = save_p_lz;
85208524
out_flush();
85218525
}
85228526

src/ex_getln.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4545,15 +4545,15 @@ open_cmdwin(void)
45454545
if (restart_edit != 0) // autocmd with ":startinsert"
45464546
stuffcharReadbuff(K_NOP);
45474547

4548-
i = RedrawingDisabled;
4548+
int save_RedrawingDisabled = RedrawingDisabled;
45494549
RedrawingDisabled = 0;
45504550

45514551
/*
45524552
* Call the main loop until <CR> or CTRL-C is typed.
45534553
*/
45544554
main_loop(TRUE, FALSE);
45554555

4556-
RedrawingDisabled = i;
4556+
RedrawingDisabled = save_RedrawingDisabled;
45574557

45584558
# ifdef FEAT_FOLDING
45594559
save_KeyTyped = KeyTyped;

src/insexpand.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,12 +2969,13 @@ f_complete_add(typval_T *argvars, typval_T *rettv)
29692969
void
29702970
f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
29712971
{
2972-
int saved = RedrawingDisabled;
2973-
2972+
int save_RedrawingDisabled = RedrawingDisabled;
29742973
RedrawingDisabled = 0;
2974+
29752975
ins_compl_check_keys(0, TRUE);
29762976
rettv->vval.v_number = ins_compl_interrupted();
2977-
RedrawingDisabled = saved;
2977+
2978+
RedrawingDisabled = save_RedrawingDisabled;
29782979
}
29792980

29802981
/*
@@ -5079,8 +5080,7 @@ ins_complete(int c, int enable_pum)
50795080
show_pum(int prev_w_wrow, int prev_w_leftcol)
50805081
{
50815082
// RedrawingDisabled may be set when invoked through complete().
5082-
int n = RedrawingDisabled;
5083-
5083+
int save_RedrawingDisabled = RedrawingDisabled;
50845084
RedrawingDisabled = 0;
50855085

50865086
// If the cursor moved or the display scrolled we need to remove the pum
@@ -5091,7 +5091,8 @@ show_pum(int prev_w_wrow, int prev_w_leftcol)
50915091

50925092
ins_compl_show_pum();
50935093
setcursor();
5094-
RedrawingDisabled = n;
5094+
5095+
RedrawingDisabled = save_RedrawingDisabled;
50955096
}
50965097

50975098
/*

src/os_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4594,7 +4594,7 @@ mch_call_shell_terminal(
45944594

45954595
// Only require pressing Enter when redrawing, to avoid that system() gets
45964596
// the hit-enter prompt even though it didn't output anything.
4597-
if (!RedrawingDisabled)
4597+
if (RedrawingDisabled == 0)
45984598
wait_return(TRUE);
45994599
do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE);
46004600

0 commit comments

Comments
 (0)