summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-04-09 12:40:13 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-09 12:40:13 +0100
commitcee9c844f27bceaba90362a3fa27a04d4d06c0fd (patch)
tree1904095957e43d03004d20826b501e258de0a823
parenta016eeba7a5777ba1f2ec2dbcda7c96823bf9ab1 (diff)
downloadvim-git-cee9c844f27bceaba90362a3fa27a04d4d06c0fd.tar.gz
patch 8.2.4718: @@@ in the last line sometimes drawn in the wrong placev8.2.4718
Problem: @@@ in the last line sometimes drawn in the wrong place. Solution: Make sure the column is valid. (closes #10130)
-rw-r--r--src/drawscreen.c9
-rw-r--r--src/screen.c6
-rw-r--r--src/testdir/dumps/Test_display_lastline_1.dump10
-rw-r--r--src/testdir/dumps/Test_display_lastline_2.dump10
-rw-r--r--src/testdir/dumps/Test_display_lastline_3.dump10
-rw-r--r--src/testdir/dumps/Test_display_lastline_4.dump10
-rw-r--r--src/testdir/test_display.vim26
-rw-r--r--src/version.c2
8 files changed, 77 insertions, 6 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 9f9cb0960..135df1ea5 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -2617,8 +2617,8 @@ win_update(win_T *wp)
int scr_row = W_WINROW(wp) + wp->w_height - 1;
// Last line isn't finished: Display "@@@" in the last screen line.
- screen_puts_len((char_u *)"@@", 2, scr_row, wp->w_wincol,
- HL_ATTR(HLF_AT));
+ screen_puts_len((char_u *)"@@", wp->w_width > 2 ? 2 : wp->w_width,
+ scr_row, wp->w_wincol, HL_ATTR(HLF_AT));
screen_fill(scr_row, scr_row + 1,
(int)wp->w_wincol + 2, (int)W_ENDCOL(wp),
'@', ' ', HL_ATTR(HLF_AT));
@@ -2627,10 +2627,13 @@ win_update(win_T *wp)
}
else if (dy_flags & DY_LASTLINE) // 'display' has "lastline"
{
+ int start_col = (int)W_ENDCOL(wp) - 3;
+
// Last line isn't finished: Display "@@@" at the end.
screen_fill(W_WINROW(wp) + wp->w_height - 1,
W_WINROW(wp) + wp->w_height,
- (int)W_ENDCOL(wp) - 3, (int)W_ENDCOL(wp),
+ start_col < wp->w_wincol ? wp->w_wincol : start_col,
+ (int)W_ENDCOL(wp),
'@', '@', HL_ATTR(HLF_AT));
set_empty_rows(wp, srow);
wp->w_botline = lnum;
diff --git a/src/screen.c b/src/screen.c
index 7caf2995f..1a5cb1556 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2331,9 +2331,9 @@ space_to_screenline(int off, int attr)
}
/*
- * Fill the screen from 'start_row' to 'end_row', from 'start_col' to 'end_col'
- * with character 'c1' in first column followed by 'c2' in the other columns.
- * Use attributes 'attr'.
+ * Fill the screen from "start_row" to "end_row" (exclusive), from "start_col"
+ * to "end_col" (exclusive) with character "c1" in first column followed by
+ * "c2" in the other columns. Use attributes "attr".
*/
void
screen_fill(
diff --git a/src/testdir/dumps/Test_display_lastline_1.dump b/src/testdir/dumps/Test_display_lastline_1.dump
new file mode 100644
index 000000000..b0e34ead4
--- /dev/null
+++ b/src/testdir/dumps/Test_display_lastline_1.dump
@@ -0,0 +1,10 @@
+>a+0&#ffffff0||+1&&|a+0&&@2| @69
+|a||+1&&|b+0&&@72
+|a||+1&&|b+0&&@26| @45
+|b||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|@||+1#0000000&|~+0#4040ff13&| @71
+|<+3#0000000&| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @41|1|,|1| @11|A|l@1
+| +0&&@74
diff --git a/src/testdir/dumps/Test_display_lastline_2.dump b/src/testdir/dumps/Test_display_lastline_2.dump
new file mode 100644
index 000000000..2bd330947
--- /dev/null
+++ b/src/testdir/dumps/Test_display_lastline_2.dump
@@ -0,0 +1,10 @@
+>a+0&#ffffff0||+1&&|a+0&&@2| @69
+|a||+1&&|b+0&&@72
+|a||+1&&|b+0&&@26| @45
+|b||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|b+0#0000000&||+1&&|~+0#4040ff13&| @71
+|@||+1#0000000&|~+0#4040ff13&| @71
+|<+3#0000000&| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @41|1|,|1| @11|A|l@1
+|:+0&&|s|e|t| |d|i|s|p|l|a|y|=|l|a|s|t|l|i|n|e| @53
diff --git a/src/testdir/dumps/Test_display_lastline_3.dump b/src/testdir/dumps/Test_display_lastline_3.dump
new file mode 100644
index 000000000..a0b6e09ba
--- /dev/null
+++ b/src/testdir/dumps/Test_display_lastline_3.dump
@@ -0,0 +1,10 @@
+>a+0&#ffffff0@2| @69||+1&&|a+0&&
+|b@72||+1&&|a+0&&
+|b@26| @45||+1&&|a+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|@+0#4040ff13&
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @41|1|,|1| @11|A|l@1| |<+1&&
+|:+0&&|1|0@1|w|i|n|c|m|d| |>| @62
diff --git a/src/testdir/dumps/Test_display_lastline_4.dump b/src/testdir/dumps/Test_display_lastline_4.dump
new file mode 100644
index 000000000..e34e7c766
--- /dev/null
+++ b/src/testdir/dumps/Test_display_lastline_4.dump
@@ -0,0 +1,10 @@
+>a+0&#ffffff0@2| @69||+1&&|a+0&&
+|b@72||+1&&|a+0&&
+|b@26| @45||+1&&|a+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|b+0&&
+|~+0#4040ff13&| @71||+1#0000000&|@+0#4040ff13&
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @41|1|,|1| @11|A|l@1| |<+1&&
+|:+0&&|s|e|t| |d|i|s|p|l|a|y|=|t|r|u|n|c|a|t|e| @53
diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim
index a000521d0..f5c8dc51e 100644
--- a/src/testdir/test_display.vim
+++ b/src/testdir/test_display.vim
@@ -372,5 +372,31 @@ func Test_display_linebreak_breakat()
let &breakat=_breakat
endfunc
+func Test_display_lastline()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, ['aaa', 'b'->repeat(100)])
+ set display=truncate
+ vsplit
+ 100wincmd <
+ END
+ call writefile(lines, 'XdispLastline')
+ let buf = RunVimInTerminal('-S XdispLastline', #{rows: 10})
+ call VerifyScreenDump(buf, 'Test_display_lastline_1', {})
+
+ call term_sendkeys(buf, ":set display=lastline\<CR>")
+ call VerifyScreenDump(buf, 'Test_display_lastline_2', {})
+
+ call term_sendkeys(buf, ":100wincmd >\<CR>")
+ call VerifyScreenDump(buf, 'Test_display_lastline_3', {})
+
+ call term_sendkeys(buf, ":set display=truncate\<CR>")
+ call VerifyScreenDump(buf, 'Test_display_lastline_4', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XdispLastline')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 1830d5f69..f4eb4d14c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4718,
+/**/
4717,
/**/
4716,