changeset 30513:ea15dfc9c155 v9.0.0592

patch 9.0.0592: display not cleared when scrolling back in messages Commit: https://github.com/vim/vim/commit/838b746cce7ea863acdb81e3f44eec2ea90de92a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 26 15:19:56 2022 +0100 patch 9.0.0592: display not cleared when scrolling back in messages 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)
author Bram Moolenaar <Bram@vim.org>
date Mon, 26 Sep 2022 16:30:03 +0200
parents 3541f0fe850c
children fa144142b452
files src/message.c src/proto/screen.pro src/screen.c src/testdir/dumps/Test_more_scrollback_1.dump src/testdir/dumps/Test_more_scrollback_2.dump src/testdir/test_messages.vim src/version.c
diffstat 7 files changed, 75 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/message.c
+++ b/src/message.c
@@ -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;
@@ -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;
@@ -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;
 			}
 		    }
@@ -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;
 		}
 	    }
--- a/src/proto/screen.pro
+++ b/src/proto/screen.pro
@@ -30,7 +30,7 @@ void check_for_delay(int check_msg_scrol
 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);
--- a/src/screen.c
+++ b/src/screen.c
@@ -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);
@@ -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
@@ -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
+ * 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
 }
 
 /*
@@ -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)
@@ -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;
     }
@@ -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;
 }
 
 /*
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_more_scrollback_1.dump
@@ -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
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_more_scrollback_2.dump
@@ -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
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -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})
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    592,
+/**/
     591,
 /**/
     590,