mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(extmarks): fix wrong virt_text position after wrapped TAB (#25168)
This commit is contained in:
parent
b52bd8a2de
commit
b65cd7ff1a
@ -3085,11 +3085,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
|
|||||||
if (has_decor && (wp->w_p_rl ? (wlv.col < 0) : (wlv.col >= grid->cols))) {
|
if (has_decor && (wp->w_p_rl ? (wlv.col < 0) : (wlv.col >= grid->cols))) {
|
||||||
// At the end of screen line: might need to peek for decorations just after
|
// At the end of screen line: might need to peek for decorations just after
|
||||||
// this position.
|
// this position.
|
||||||
if (wp->w_p_wrap) {
|
if (!has_fold && wp->w_p_wrap && wlv.n_extra == 0) {
|
||||||
// FIXME: virt_text_hide doesn't work for overlay virt_text at the next char
|
// FIXME: virt_text_hide doesn't work for overlay virt_text at the next char
|
||||||
// as it's not easy to check if the next char is inside Visual selection.
|
// as it's not easy to check if the next char is inside Visual selection.
|
||||||
decor_redraw_col(wp, (int)(ptr - line), -3, false, &decor_state);
|
decor_redraw_col(wp, (int)(ptr - line), -3, false, &decor_state);
|
||||||
} else {
|
} else if (has_fold || !wp->w_p_wrap) {
|
||||||
// Without wrapping, we might need to display right_align and win_col
|
// Without wrapping, we might need to display right_align and win_col
|
||||||
// virt_text for the entire text line.
|
// virt_text for the entire text line.
|
||||||
decor_redraw_col(wp, MAXCOL, -1, true, &decor_state);
|
decor_redraw_col(wp, MAXCOL, -1, true, &decor_state);
|
||||||
|
@ -894,6 +894,16 @@ describe('extmark decorations', function()
|
|||||||
aba^b |
|
aba^b |
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
|
feed('0g$hi<Tab>')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{2: 1 }ababababababababababababababababababababab{4:01} |
|
||||||
|
{4:^23456789}abababababababababababababababababababa{4:0}|
|
||||||
|
{4:123456789}babababababababababababababababababababab|
|
||||||
|
ababababababababababababababababababababababababab|
|
||||||
|
abababab |
|
||||||
|
{24:-- INSERT --} |
|
||||||
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('virt_text_hide hides overlay virtual text when extmark is off-screen', function()
|
it('virt_text_hide hides overlay virtual text when extmark is off-screen', function()
|
||||||
@ -1265,6 +1275,44 @@ describe('extmark decorations', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
|
feed('fhi<Tab>')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{2: 1 }n ipairs(items) do |
|
||||||
|
{2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}|
|
||||||
|
{2: 3 } |
|
||||||
|
{2: 4 }= nil then {4:Much} {4:MUCH}|
|
||||||
|
{2: 5 }- -- -- -- -- -- -- -- -- -- --{4:Error}^hl_id{4:ERROR}|
|
||||||
|
{2: 6 } |
|
||||||
|
{2: 7 }1, (count or 1) do |
|
||||||
|
{2: 8 }l cell = line[colpos] |
|
||||||
|
{2: 9 }.tex{1:-} = text {1:-}|
|
||||||
|
{2: 10 }.hl_id = hl_id |
|
||||||
|
{2: 11 }os = colpos+1 |
|
||||||
|
{2: 12 } |
|
||||||
|
{2: 13 } |
|
||||||
|
{1:~ }|
|
||||||
|
{24:-- INSERT --} |
|
||||||
|
]]}
|
||||||
|
|
||||||
|
feed('<Esc>0')
|
||||||
|
screen:expect{grid=[[
|
||||||
|
{2: 1 }for _,item in ipairs(items) do |
|
||||||
|
{2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}|
|
||||||
|
{2: 3 } if |
|
||||||
|
{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
||||||
|
{2: 5 }^ -- -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}|
|
||||||
|
{2: 6 } end |
|
||||||
|
{2: 7 } for _ = 1, (count or 1) do |
|
||||||
|
{2: 8 } local cell = line[colpos] |
|
||||||
|
{2: 9 } {1:-} cell.text = text {1:-}|
|
||||||
|
{2: 10 } cell.hl_id = hl_id |
|
||||||
|
{2: 11 } colpos = colpos+1 |
|
||||||
|
{2: 12 } end |
|
||||||
|
{2: 13 }end |
|
||||||
|
{1:~ }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can have virtual text on folded line', function()
|
it('can have virtual text on folded line', function()
|
||||||
@ -1273,7 +1321,6 @@ describe('extmark decorations', function()
|
|||||||
22222
|
22222
|
||||||
33333]])
|
33333]])
|
||||||
command('1,2fold')
|
command('1,2fold')
|
||||||
command('set nowrap')
|
|
||||||
screen:try_resize(50, 3)
|
screen:try_resize(50, 3)
|
||||||
feed('zb')
|
feed('zb')
|
||||||
-- XXX: the behavior of overlay virtual text at non-zero column is strange:
|
-- XXX: the behavior of overlay virtual text at non-zero column is strange:
|
||||||
@ -1287,6 +1334,8 @@ describe('extmark decorations', function()
|
|||||||
3333^3 |
|
3333^3 |
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
command('set nowrap')
|
||||||
|
screen:expect_unchanged()
|
||||||
feed('zl')
|
feed('zl')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
|
{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|
|
||||||
|
Loading…
Reference in New Issue
Block a user