Merge pull request #23435 from neovim/backport-23430-to-release-0.9

[Backport release-0.9] Fix bugs with ext_multigrid resized grid
This commit is contained in:
zeertzjq 2023-05-02 12:38:53 +08:00 committed by GitHub
commit 49092de818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 241 additions and 9 deletions

View File

@ -168,7 +168,7 @@ static void margin_columns_win(win_T *wp, int *left_col, int *right_col)
return;
}
width1 = wp->w_width - cur_col_off;
width1 = wp->w_width_inner - cur_col_off;
width2 = width1 + win_col_off2(wp);
*left_col = 0;

View File

@ -966,18 +966,18 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
// similar to what is done in validate_cursor_col()
colnr_T col = scol;
col += off;
int width = wp->w_width - off + win_col_off2(wp);
int width = wp->w_width_inner - off + win_col_off2(wp);
// long line wrapping, adjust row
if (wp->w_p_wrap && col >= (colnr_T)wp->w_width && width > 0) {
if (wp->w_p_wrap && col >= (colnr_T)wp->w_width_inner && width > 0) {
// use same formula as what is used in curs_columns()
rowoff = visible_row ? ((col - wp->w_width) / width + 1) : 0;
rowoff = visible_row ? ((col - wp->w_width_inner) / width + 1) : 0;
col -= rowoff * width;
}
col -= wp->w_leftcol;
if (col >= 0 && col < wp->w_width && row + rowoff <= wp->w_height) {
if (col >= 0 && col < wp->w_width_inner && row + rowoff <= wp->w_height_inner) {
coloff = col - scol + (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1;
row += local ? 0 : wp->w_winrow + wp->w_winrow_off;
} else {

View File

@ -5348,7 +5348,7 @@ static void nv_g_dollar_cmd(cmdarg_T *cap)
colnr_T vcol;
getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol);
if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) {
if (vcol >= curwin->w_leftcol + curwin->w_width_inner - col_off) {
curwin->w_cursor.col--;
}
}

View File

@ -37,6 +37,9 @@ describe('ext_multigrid', function()
[18] = {bold = true, foreground = Screen.colors.Magenta},
[19] = {foreground = Screen.colors.Brown},
[20] = {background = Screen.colors.LightGrey},
[21] = {background = Screen.colors.LightMagenta},
[22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue},
[23] = {background = Screen.colors.Grey90},
})
end)
@ -884,7 +887,6 @@ describe('ext_multigrid', function()
it('gets written till grid width', function()
insert(('a'):rep(60).."\n")
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
@ -927,8 +929,95 @@ describe('ext_multigrid', function()
]]}
end)
it('"g$" works correctly with double-width characters and no wrapping', function()
command('set nowrap')
insert(('a'):rep(58) .. (''):rep(3))
feed('0')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa哦|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
]]}
feed('g$')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
]]}
end)
it('wraps with grid width', function()
insert(('b'):rep(80).."\n")
insert(('b'):rep(160).."\n")
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
@ -947,7 +1036,8 @@ describe('ext_multigrid', function()
[3:-----------------------------------------------------]|
## grid 2
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
bbbbbbbbbbbbbbbbbbbb |
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
^ |
{1:~ }|
{1:~ }|
@ -965,6 +1055,47 @@ describe('ext_multigrid', function()
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
]]}
feed('2gk')
command('setlocal cursorline cursorlineopt=screenline')
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
{23:^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}|
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
@ -1060,6 +1191,107 @@ describe('ext_multigrid', function()
|
]]}
end)
it('anchored float window "bufpos"', function()
insert(('c'):rep(1111))
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccc^c |
{1:~ }|
## grid 3
|
]]}
local float_buf = meths.create_buf(false, false)
meths.open_win(float_buf, false, {
relative = 'win',
win = curwin(),
bufpos = {0, 1018},
anchor = 'SE',
width = 5,
height = 5,
})
screen:expect{grid=[[
## grid 1
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
[2:-----------------------------------------------------]|
{11:[No Name] [+] }|
[3:-----------------------------------------------------]|
## grid 2
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|
cccccccccccccccccccccccccccccc^c |
{1:~ }|
## grid 3
|
## grid 4
{21: }|
{22:~ }|
{22:~ }|
{22:~ }|
{22:~ }|
]], float_pos={
[4] = {{id = 1001}, "SE", 2, 16, 58, true, 50};
}}
end)
end)
it('multiline messages scroll over windows', function()