diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-10 04:50:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-10 04:50:49 +0800 |
commit | 2a2c4e191f5c2cb70bafaa213b5697308dc6f850 (patch) | |
tree | a766cd43496484591a86d1d74db86f94a6e47a27 | |
parent | 61bd5426f4ef0d8f45d0972f7da870131ae278ba (diff) | |
download | rneovim-2a2c4e191f5c2cb70bafaa213b5697308dc6f850.tar.gz rneovim-2a2c4e191f5c2cb70bafaa213b5697308dc6f850.tar.bz2 rneovim-2a2c4e191f5c2cb70bafaa213b5697308dc6f850.zip |
vim-patch:8.2.4718: @@@ in the last line sometimes drawn in the wrong place (#18055)
Problem: @@@ in the last line sometimes drawn in the wrong place.
Solution: Make sure the column is valid. (closes vim/vim#10130)
https://github.com/vim/vim/commit/cee9c844f27bceaba90362a3fa27a04d4d06c0fd
-rw-r--r-- | src/nvim/screen.c | 12 | ||||
-rw-r--r-- | src/nvim/testdir/test_display.vim | 27 | ||||
-rw-r--r-- | test/functional/legacy/display_spec.lua | 56 |
3 files changed, 83 insertions, 12 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index baeb2fcb03..296255ed8c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1639,16 +1639,18 @@ static void win_update(win_T *wp, DecorProviders *providers) int scr_row = wp->w_grid.Rows - 1; // Last line isn't finished: Display "@@@" in the last screen line. - grid_puts_len(&wp->w_grid, (char_u *)"@@", 2, scr_row, 0, at_attr); + grid_puts_len(&wp->w_grid, (char_u *)"@@", MIN(wp->w_grid.Columns, 2), scr_row, 0, at_attr); grid_fill(&wp->w_grid, scr_row, scr_row + 1, 2, wp->w_grid.Columns, '@', ' ', at_attr); set_empty_rows(wp, srow); wp->w_botline = lnum; } else if (dy_flags & DY_LASTLINE) { // 'display' has "lastline" + int start_col = wp->w_grid.Columns - 3; + // Last line isn't finished: Display "@@@" at the end. grid_fill(&wp->w_grid, wp->w_grid.Rows - 1, wp->w_grid.Rows, - wp->w_grid.Columns - 3, wp->w_grid.Columns, '@', '@', at_attr); + MAX(start_col, 0), wp->w_grid.Columns, '@', '@', at_attr); set_empty_rows(wp, srow); wp->w_botline = lnum; } else { @@ -6001,9 +6003,9 @@ static void end_search_hl(void) } -/// Fill the grid 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 grid 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 grid_fill(ScreenGrid *grid, int start_row, int end_row, int start_col, int end_col, int c1, int c2, int attr) { diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim index 094283a3a3..6938abbc28 100644 --- a/src/nvim/testdir/test_display.vim +++ b/src/nvim/testdir/test_display.vim @@ -325,4 +325,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/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua index 59ba170e33..4c7915403c 100644 --- a/test/functional/legacy/display_spec.lua +++ b/test/functional/legacy/display_spec.lua @@ -2,23 +2,21 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear -local poke_eventloop = helpers.poke_eventloop local exec = helpers.exec local feed = helpers.feed -local feed_command = helpers.feed_command +local command = helpers.command describe('display', function() before_each(clear) - it('scroll when modified at topline', function() + it('scroll when modified at topline vim-patch:8.2.1488', function() local screen = Screen.new(20, 4) screen:attach() screen:set_default_attr_ids({ [1] = {bold = true}, }) - feed_command([[call setline(1, repeat('a', 21))]]) - poke_eventloop() + command([[call setline(1, repeat('a', 21))]]) feed('O') screen:expect([[ ^ | @@ -28,7 +26,7 @@ describe('display', function() ]]) end) - it('scrolling when modified at topline in Visual mode', function() + it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function() local screen = Screen.new(60, 8) screen:attach() screen:set_default_attr_ids({ @@ -57,5 +55,49 @@ describe('display', function() {1:-- VISUAL LINE --} | ]]) end) -end) + it('@@@ in the last line shows correctly in a narrow window vim-patch:8.2.4718', function() + local screen = Screen.new(60, 10) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {bold = true, reverse = true}, -- StatusLine + [3] = {reverse = true}, -- VertSplit, StatusLineNC + }) + screen:attach() + exec([[ + call setline(1, ['aaa', 'b'->repeat(100)]) + set display=truncate + vsplit + 100wincmd < + ]]) + screen:expect([[ + ^a{3:│}aaa | + a{3:│}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + a{3:│}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + b{3:│}{1:~ }| + b{3:│}{1:~ }| + b{3:│}{1:~ }| + b{3:│}{1:~ }| + {1:@}{3:│}{1:~ }| + {2:< }{3:[No Name] [+] }| + | + ]]) + command('set display=lastline') + screen:expect_unchanged() + command('100wincmd >') + screen:expect([[ + ^aaa {3:│}a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb{3:│}a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {3:│}a| + {1:~ }{3:│}b| + {1:~ }{3:│}b| + {1:~ }{3:│}b| + {1:~ }{3:│}b| + {1:~ }{3:│}{1:@}| + {2:[No Name] [+] }{3:<}| + | + ]]) + command('set display=truncate') + screen:expect_unchanged() + end) +end) |