fix(plines): cursor position with 'showbreak' and resized grid (#28067)

This commit is contained in:
zeertzjq 2024-03-28 14:12:54 +08:00 committed by GitHub
parent 981301d11f
commit a0cbf1d8d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 67 additions and 13 deletions

View File

@ -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) {

View File

@ -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()