Skip to content

Commit cf0995d

Browse files
committed
patch 9.0.0447: using :echowin while at the hit-enter prompt causes problems
Problem: Using :echowin while at the hit-enter prompt causes problems. Solution: Do not prompt for :echowin. Postpone showing the message window. Start the timer when the window is displayed.
1 parent 87e74d0 commit cf0995d

File tree

8 files changed

+85
-7
lines changed

8 files changed

+85
-7
lines changed

src/ex_getln.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,8 @@ redrawcmd(void)
38903890
void
38913891
compute_cmdrow(void)
38923892
{
3893-
if (exmode_active || msg_scrolled != 0)
3893+
// ignore "msg_scrolled" in update_screen(), it will be reset soon.
3894+
if (exmode_active || (msg_scrolled != 0 && !updating_screen))
38943895
cmdline_row = Rows - 1;
38953896
else
38963897
cmdline_row = W_WINROW(lastwin) + lastwin->w_height

src/message.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,10 @@ wait_return(int redraw)
11571157
// need_wait_return to do it later.
11581158
if (msg_silent != 0)
11591159
return;
1160+
#ifdef HAS_MESSAGE_WINDOW
1161+
if (in_echowindow)
1162+
return;
1163+
#endif
11601164

11611165
/*
11621166
* When inside vgetc(), we can't wait for a typed character at all.

src/popupwin.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ static poppos_entry_T poppos_entries[] = {
3131
#ifdef HAS_MESSAGE_WINDOW
3232
// Window used for ":echowindow"
3333
static win_T *message_win = NULL;
34+
35+
// Flag set when a message is added to the message window, timer is started
36+
// when the message window is drawn. This might be after pressing Enter at the
37+
// hit-enter prompt.
38+
static int start_message_win_timer = FALSE;
39+
40+
static void may_start_message_win_timer(win_T *wp);
3441
#endif
3542

3643
static void popup_adjust_position(win_T *wp);
@@ -4268,6 +4275,11 @@ update_popups(void (*win_update)(win_T *wp))
42684275

42694276
// Back to the normal zindex.
42704277
screen_zindex = 0;
4278+
4279+
#ifdef HAS_MESSAGE_WINDOW
4280+
// if this was the message window popup may start the timer now
4281+
may_start_message_win_timer(wp);
4282+
#endif
42714283
}
42724284

42734285
#if defined(FEAT_SEARCH_EXTRA)
@@ -4513,8 +4525,18 @@ popup_show_message_win(void)
45134525
popup_update_color(message_win, TYPE_MESSAGE_WIN);
45144526
popup_show(message_win);
45154527
}
4528+
start_message_win_timer = TRUE;
4529+
}
4530+
}
4531+
4532+
static void
4533+
may_start_message_win_timer(win_T *wp)
4534+
{
4535+
if (wp == message_win && start_message_win_timer)
4536+
{
45164537
if (message_win->w_popup_timer != NULL)
45174538
timer_start(message_win->w_popup_timer);
4539+
start_message_win_timer = FALSE;
45184540
}
45194541
}
45204542

@@ -4552,8 +4574,9 @@ end_echowindow(void)
45524574
{
45534575
in_echowindow = FALSE;
45544576

4555-
// show the message window now
4556-
redraw_cmd(FALSE);
4577+
if ((State & MODE_HITRETURN) == 0)
4578+
// show the message window now
4579+
redraw_cmd(FALSE);
45574580

45584581
// do not overwrite messages
45594582
// TODO: only for message window

src/screen.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,18 +3038,18 @@ screenclear2(int doclear)
30383038
screen_cleared = TRUE; // can use contents of ScreenLines now
30393039

30403040
win_rest_invalid(firstwin); // redraw all regular windows
3041-
#ifdef FEAT_PROP_POPUP
3042-
popup_redraw_all(); // redraw all popup windows
3043-
#endif
30443041
redraw_cmdline = TRUE;
30453042
redraw_tabline = TRUE;
30463043
if (must_redraw == UPD_CLEAR) // no need to clear again
30473044
must_redraw = UPD_NOT_VALID;
3045+
msg_scrolled = 0; // compute_cmdrow() uses this
30483046
compute_cmdrow();
3047+
#ifdef FEAT_PROP_POPUP
3048+
popup_redraw_all(); // redraw all popup windows
3049+
#endif
30493050
msg_row = cmdline_row; // put cursor on last line for messages
30503051
msg_col = 0;
30513052
screen_start(); // don't know where cursor is now
3052-
msg_scrolled = 0; // can't scroll back
30533053
msg_didany = FALSE;
30543054
msg_didout = FALSE;
30553055
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|~+0#4040ff13#ffffff0| @73
2+
|~| @73
3+
|~| @73
4+
|~| @73
5+
|o+0#0000000&|n|e| @71
6+
|t|w|o| @71
7+
|t|h|r|e@1| @69
8+
|P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| |c|o|n|t|i|n|u|e> +0#0000000&@35
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
2+
|~+0#4040ff13&| @73
3+
|~| @73
4+
|~| @73
5+
|═+0#e000002&@74
6+
|l|a|t|e|r| |m|e|s@1|a|g|e| @61
7+
| +0#0000000&@74
8+
@57|1|,|1| @10|A|l@1|

src/testdir/test_messages.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,28 @@ func Test_echowindow()
401401
echowindow 'line' n
402402
endfor
403403
endfunc
404+
405+
def TwoMessages()
406+
popup_clear()
407+
set cmdheight=2
408+
redraw
409+
timer_start(100, (_) => {
410+
echowin 'message'
411+
})
412+
echo 'one'
413+
echo 'two'
414+
enddef
415+
416+
def ThreeMessages()
417+
popup_clear()
418+
redraw
419+
timer_start(100, (_) => {
420+
echowin 'later message'
421+
})
422+
echo 'one'
423+
echo 'two'
424+
echo 'three'
425+
enddef
404426
END
405427
call writefile(lines, 'XtestEchowindow')
406428
let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
@@ -415,6 +437,16 @@ func Test_echowindow()
415437
call term_sendkeys(buf, ":call ManyMessages()\<CR>")
416438
call VerifyScreenDump(buf, 'Test_echowindow_4', {})
417439

440+
call term_sendkeys(buf, ":call TwoMessages()\<CR>")
441+
call VerifyScreenDump(buf, 'Test_echowindow_5', {})
442+
443+
call term_sendkeys(buf, ":call ThreeMessages()\<CR>")
444+
sleep 120m
445+
call VerifyScreenDump(buf, 'Test_echowindow_6', {})
446+
447+
call term_sendkeys(buf, "\<CR>")
448+
call VerifyScreenDump(buf, 'Test_echowindow_7', {})
449+
418450
" clean up
419451
call StopVimInTerminal(buf)
420452
call delete('XtestEchowindow')

src/version.c

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

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
447,
706708
/**/
707709
446,
708710
/**/

0 commit comments

Comments
 (0)