Skip to content

Commit 917e32b

Browse files
committed
patch 8.1.0244: no redraw when using a STOP signal on Vim and then CONT
Problem: No redraw when using a STOP signal on Vim and then a CONT signal. Solution: Catch the CONT signal and force a redraw. (closes #3285)
1 parent 5db7eec commit 917e32b

4 files changed

Lines changed: 69 additions & 17 deletions

File tree

src/os_unix.c

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,23 @@ deathtrap SIGDEFARG(sigarg)
12271227
SIGRETURN;
12281228
}
12291229

1230-
#if defined(_REENTRANT) && defined(SIGCONT)
1230+
static void
1231+
after_sigcont(void)
1232+
{
1233+
# ifdef FEAT_TITLE
1234+
// Set oldtitle to NULL, so the current title is obtained again.
1235+
VIM_CLEAR(oldtitle);
1236+
# endif
1237+
settmode(TMODE_RAW);
1238+
need_check_timestamps = TRUE;
1239+
did_check_timestamps = FALSE;
1240+
}
1241+
1242+
#if defined(SIGCONT)
1243+
static RETSIGTYPE sigcont_handler SIGPROTOARG;
1244+
static int in_mch_suspend = FALSE;
1245+
1246+
# if defined(_REENTRANT) && defined(SIGCONT)
12311247
/*
12321248
* On Solaris with multi-threading, suspending might not work immediately.
12331249
* Catch the SIGCONT signal, which will be used as an indication whether the
@@ -1239,15 +1255,46 @@ deathtrap SIGDEFARG(sigarg)
12391255
* volatile because it is used in signal handler sigcont_handler().
12401256
*/
12411257
static volatile int sigcont_received;
1242-
static RETSIGTYPE sigcont_handler SIGPROTOARG;
1258+
# endif
12431259

12441260
/*
12451261
* signal handler for SIGCONT
12461262
*/
12471263
static RETSIGTYPE
12481264
sigcont_handler SIGDEFARG(sigarg)
12491265
{
1250-
sigcont_received = TRUE;
1266+
if (in_mch_suspend)
1267+
{
1268+
# if defined(_REENTRANT) && defined(SIGCONT)
1269+
sigcont_received = TRUE;
1270+
# endif
1271+
}
1272+
else
1273+
{
1274+
// We didn't suspend ourselves, assume we were stopped by a SIGSTOP
1275+
// signal (which can't be intercepted) and get a SIGCONT. Need to get
1276+
// back to a sane mode and redraw.
1277+
after_sigcont();
1278+
1279+
update_screen(CLEAR);
1280+
if (State & CMDLINE)
1281+
redrawcmdline();
1282+
else if (State == HITRETURN || State == SETWSIZE || State == ASKMORE
1283+
|| State == EXTERNCMD || State == CONFIRM || exmode_active)
1284+
repeat_message();
1285+
else if (redrawing())
1286+
setcursor();
1287+
#if defined(FEAT_INS_EXPAND)
1288+
if (pum_visible())
1289+
{
1290+
redraw_later(NOT_VALID);
1291+
ins_compl_show_pum();
1292+
}
1293+
#endif
1294+
cursor_on_force();
1295+
out_flush();
1296+
}
1297+
12511298
SIGRETURN;
12521299
}
12531300
#endif
@@ -1330,6 +1377,8 @@ mch_suspend(void)
13301377
{
13311378
/* BeOS does have SIGTSTP, but it doesn't work. */
13321379
#if defined(SIGTSTP) && !defined(__BEOS__)
1380+
in_mch_suspend = TRUE;
1381+
13331382
out_flush(); /* needed to make cursor visible on some systems */
13341383
settmode(TMODE_COOK);
13351384
out_flush(); /* needed to disable mouse on some systems */
@@ -1361,16 +1410,9 @@ mch_suspend(void)
13611410
mch_delay(wait_time, FALSE);
13621411
}
13631412
# endif
1413+
in_mch_suspend = FALSE;
13641414

1365-
# ifdef FEAT_TITLE
1366-
/*
1367-
* Set oldtitle to NULL, so the current title is obtained again.
1368-
*/
1369-
VIM_CLEAR(oldtitle);
1370-
# endif
1371-
settmode(TMODE_RAW);
1372-
need_check_timestamps = TRUE;
1373-
did_check_timestamps = FALSE;
1415+
after_sigcont();
13741416
#else
13751417
suspend_shell();
13761418
#endif
@@ -1410,7 +1452,7 @@ set_signals(void)
14101452
#ifdef SIGTSTP
14111453
signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
14121454
#endif
1413-
#if defined(_REENTRANT) && defined(SIGCONT)
1455+
#if defined(SIGCONT)
14141456
signal(SIGCONT, sigcont_handler);
14151457
#endif
14161458

src/proto/term.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void setmouse(void);
5050
int mouse_has(int c);
5151
int mouse_model_popup(void);
5252
void scroll_start(void);
53+
void cursor_on_force(void);
5354
void cursor_on(void);
5455
void cursor_off(void);
5556
void term_cursor_mode(int forced);

src/term.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3788,17 +3788,24 @@ scroll_start(void)
37883788

37893789
static int cursor_is_off = FALSE;
37903790

3791+
/*
3792+
* Enable the cursor without checking if it's already enabled.
3793+
*/
3794+
void
3795+
cursor_on_force(void)
3796+
{
3797+
out_str(T_VE);
3798+
cursor_is_off = FALSE;
3799+
}
3800+
37913801
/*
37923802
* Enable the cursor.
37933803
*/
37943804
void
37953805
cursor_on(void)
37963806
{
37973807
if (cursor_is_off)
3798-
{
3799-
out_str(T_VE);
3800-
cursor_is_off = FALSE;
3801-
}
3808+
cursor_on_force();
38023809
}
38033810

38043811
/*

src/version.c

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

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
244,
797799
/**/
798800
243,
799801
/**/

0 commit comments

Comments
 (0)