Skip to content

Commit

Permalink
patch 9.0.0592: display not cleared when scrolling back in messages
Browse files Browse the repository at this point in the history
Problem:    Display not cleared when scrolling back in messages, a background
            color is set and t_ut is empty.
Solution:   Clear to the end of the display if needed. (closes #8973)
  • Loading branch information
brammool committed Sep 26, 2022
1 parent 4569020 commit 838b746
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 12 deletions.
18 changes: 13 additions & 5 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -2913,10 +2913,11 @@ msg_sb_eol(void)

/*
* Display a screen line from previously displayed text at row "row".
* When "clear_to_eol" is set clear the rest of the screen line.
* Returns a pointer to the text for the next line (can be NULL).
*/
static msgchunk_T *
disp_sb_line(int row, msgchunk_T *smp)
disp_sb_line(int row, msgchunk_T *smp, int clear_to_eol)
{
msgchunk_T *mp = smp;
char_u *p;
Expand All @@ -2929,6 +2930,12 @@ disp_sb_line(int row, msgchunk_T *smp)
if (*p == '\n') // don't display the line break
++p;
msg_puts_display(p, -1, mp->sb_attr, TRUE);

// If clearing the screen did not work (e.g. because of a background
// color and t_ut isn't set) clear until the last column here.
if (clear_to_eol)
screen_fill(row, row + 1, msg_col, (int)Columns, ' ', ' ', 0);

if (mp->sb_eol || mp->sb_next == NULL)
break;
mp = mp->sb_next;
Expand Down Expand Up @@ -3279,15 +3286,16 @@ do_more_prompt(int typed_char)
(int)Rows, 0, NULL) == OK)
{
// display line at top
(void)disp_sb_line(0, mp);
(void)disp_sb_line(0, mp, FALSE);
}
else
{
int did_clear = screenclear();

// redisplay all lines
screenclear();
for (i = 0; mp != NULL && i < Rows - 1; ++i)
{
mp = disp_sb_line(i, mp);
mp = disp_sb_line(i, mp, !did_clear);
++msg_scrolled;
}
}
Expand All @@ -3304,7 +3312,7 @@ do_more_prompt(int typed_char)
inc_msg_scrolled();
screen_fill((int)Rows - 2, (int)Rows - 1, 0,
(int)Columns, ' ', ' ', 0);
mp_last = disp_sb_line((int)Rows - 2, mp_last);
mp_last = disp_sb_line((int)Rows - 2, mp_last, FALSE);
--toscroll;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/proto/screen.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void check_for_delay(int check_msg_scroll);
int screen_valid(int doclear);
void screenalloc(int doclear);
void free_screenlines(void);
void screenclear(void);
int screenclear(void);
void redraw_as_cleared(void);
void line_was_clobbered(int screen_lnum);
int can_clear(char_u *p);
Expand Down
19 changes: 13 additions & 6 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
static int screen_attr = 0;

static void screen_char_2(unsigned off, int row, int col);
static void screenclear2(int doclear);
static int screenclear2(int doclear);
static void lineclear(unsigned off, int width, int attr);
static void lineinvalid(unsigned off, int width);
static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr);
Expand Down Expand Up @@ -2473,6 +2473,7 @@ screen_fill(
|| (enc_utf8 && (int)ScreenLinesUC[off]
!= (c >= 0x80 ? c : 0))
|| ScreenAttrs[off] != attr
|| must_redraw == UPD_CLEAR // screen clear pending
#if defined(FEAT_GUI) || defined(UNIX)
|| force_next
#endif
Expand Down Expand Up @@ -2975,13 +2976,15 @@ free_screenlines(void)
* Clear the screen.
* May delay if there is something the user should read.
* Allocated the screen for resizing if needed.
* Returns TRUE when the screen was actually claared, FALSE if all display

This comment has been minimized.

Copy link
@lacygoill

lacygoill Sep 26, 2022

Typo in src/screen.c, line 2979 ("claared" should be replaced with "cleared"):

diff --git a/src/screen.c b/src/screen.c
index e44da0216..c8d82cde7 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2976,7 +2976,7 @@ free_screenlines(void)
  * Clear the screen.
  * May delay if there is something the user should read.
  * Allocated the screen for resizing if needed.
- * Returns TRUE when the screen was actually claared, FALSE if all display
+ * Returns TRUE when the screen was actually cleared, FALSE if all display
  * cells were marked for updating.
  */
     int

This comment has been minimized.

Copy link
@brammool

brammool via email Sep 26, 2022

Author Contributor
* cells were marked for updating.
*/
void
int
screenclear(void)
{
check_for_delay(FALSE);
screenalloc(FALSE); // allocate screen buffers if size changed
screenclear2(TRUE); // clear the screen
screenalloc(FALSE); // allocate screen buffers if size changed
return screenclear2(TRUE); // clear the screen
}

/*
Expand All @@ -2993,17 +2996,18 @@ redraw_as_cleared(void)
screenclear2(FALSE);
}

static void
static int
screenclear2(int doclear)
{
int i;
int did_clear = FALSE;

if (starting == NO_SCREEN || ScreenLines == NULL
#ifdef FEAT_GUI
|| (gui.in_use && gui.starting)
#endif
)
return;
return FALSE;

#ifdef FEAT_GUI
if (!gui.in_use)
Expand All @@ -3026,6 +3030,7 @@ screenclear2(int doclear)
if (doclear && can_clear(T_CL))
{
out_str(T_CL); // clear the display
did_clear = TRUE;
clear_cmdline = FALSE;
mode_displayed = FALSE;
}
Expand Down Expand Up @@ -3054,6 +3059,8 @@ screenclear2(int doclear)
screen_start(); // don't know where cursor is now
msg_didany = FALSE;
msg_didout = FALSE;

return did_clear;
}

/*
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/dumps/Test_more_scrollback_1.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
|0+0#ffffff16#0000001| @73
|1| @73
|2| @73
|3| @73
|4| @73
|5| @73
|6| @73
|7| @73
|8| @73
|-+0#00e0003&@1| |M|o|r|e| |-@1> +0#ffffff16&@64
10 changes: 10 additions & 0 deletions src/testdir/dumps/Test_more_scrollback_2.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
|0+0#ffffff16#0000001| @73
|1| @73
|2| @73
|3| @73
|4| @73
|5| @73
|6| @73
|7| @73
|8| @73
|-+0#00e0003&@1| |M|o|r|e| |-@1> +0#ffffff16&@64
26 changes: 26 additions & 0 deletions src/testdir/test_messages.vim
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,32 @@ func Test_message_more()
call StopVimInTerminal(buf)
endfunc

" Test more-prompt scrollback
func Test_message_more_scrollback()
CheckRunVimInTerminal

let lines =<< trim END
set t_ut=
hi Normal ctermfg=15 ctermbg=0
for i in range(100)
echo i
endfor
END
call writefile(lines, 'XmoreScrollback', 'D')
let buf = RunVimInTerminal('-S XmoreScrollback', {'rows': 10})
call VerifyScreenDump(buf, 'Test_more_scrollback_1', {})

call term_sendkeys(buf, 'f')
call TermWait(buf)
call term_sendkeys(buf, 'b')
call VerifyScreenDump(buf, 'Test_more_scrollback_2', {})

call term_sendkeys(buf, 'q')
call TermWait(buf)
call StopVimInTerminal(buf)
endfunc


func Test_ask_yesno()
CheckRunVimInTerminal
let buf = RunVimInTerminal('', {'rows': 6})
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
592,
/**/
591,
/**/
Expand Down

0 comments on commit 838b746

Please sign in to comment.