diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 1d5b043907..dae9de48c6 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -236,7 +236,7 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco wcol += col_off_prev; } - if (wcol + size > wp->w_width) { + if (wcol + size > wp->w_width_inner) { // cells taken by 'showbreak'/'breakindent' halfway current char int head_mid = csarg->indent_width; if (head_mid == INT_MIN) { diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index c1d3af085f..4b11a881ed 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -412,9 +412,23 @@ describe('ext_multigrid', function() end) describe('grid of smaller inner size', function() - it('is rendered correctly', function() - screen:try_resize_grid(2, 8, 5) + before_each(function() + screen:try_resize_grid(2, 20, 5) + end) + it('is rendered correctly', function() + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]|*12 + {11:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + ^ | + {1:~ }|*4 + ## grid 3 + | + ]]} + screen:try_resize_grid(2, 8, 5) screen:expect{grid=[[ ## grid 1 [2:-----------------------------------------------------]|*12 @@ -427,12 +441,43 @@ describe('ext_multigrid', function() | ]]} end) + + it("cursor draws correctly with double-width char and 'showbreak'", function() + insert(('a'):rep(19) .. '哦bbbb') + command('setlocal showbreak=++') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]|*12 + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + aaaaaaaaaaaaaaaaaaa{1:>}| + {1:++}哦bbb^b | + {1:~ }|*3 + ## grid 3 + | + ]]} + end) end) describe('grid of bigger inner size', function() - it('is rendered correctly', function() - screen:try_resize_grid(2, 80, 20) + before_each(function() + screen:try_resize_grid(2, 60, 20) + end) + it('is rendered correctly', function() + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]|*12 + {11:[No Name] }| + [3:-----------------------------------------------------]| + ## grid 2 + ^ | + {1:~ }|*19 + ## grid 3 + | + ]]} + screen:try_resize_grid(2, 80, 20) screen:expect{grid=[[ ## grid 1 [2:-----------------------------------------------------]|*12 @@ -445,13 +490,6 @@ describe('ext_multigrid', function() | ]]} end) - end) - - - describe('with resized grid', function() - before_each(function() - screen:try_resize_grid(2, 60, 20) - end) it('winwidth() winheight() getwininfo() return inner width and height #19743', function() eq(60, fn.winwidth(0)) @@ -483,7 +521,7 @@ describe('ext_multigrid', function() ]]} end) - it('"g$" works correctly with double-width characters and no wrapping', function() + it('g$ works correctly with double-width chars and no wrapping', function() command('set nowrap') insert(('a'):rep(58) .. ('哦'):rep(3)) feed('0') @@ -543,6 +581,22 @@ describe('ext_multigrid', function() ## grid 3 | ]]} + command('setlocal breakindent breakindentopt=shift:8') + feed('g$') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]|*12 + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {23:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^b}| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + | + {1:~ }|*16 + ## grid 3 + | + ]]} end) it('displays messages with default grid width', function()