aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-09-15 14:54:42 +0800
committerGitHub <noreply@github.com>2023-09-15 14:54:42 +0800
commitb65cd7ff1a0ab037daffd95d5c537898a32ea038 (patch)
tree65b913e9eafb67f8f0bae581bc38570b330bcded
parentb52bd8a2dea829f23721c15ee9ce51ccf766df43 (diff)
downloadrneovim-b65cd7ff1a0ab037daffd95d5c537898a32ea038.tar.gz
rneovim-b65cd7ff1a0ab037daffd95d5c537898a32ea038.tar.bz2
rneovim-b65cd7ff1a0ab037daffd95d5c537898a32ea038.zip
fix(extmarks): fix wrong virt_text position after wrapped TAB (#25168)
-rw-r--r--src/nvim/drawline.c4
-rw-r--r--test/functional/ui/decorations_spec.lua51
2 files changed, 52 insertions, 3 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index b22699231d..f9ddeeb94b 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -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))) {
// At the end of screen line: might need to peek for decorations just after
// 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
// 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);
- } else {
+ } else if (has_fold || !wp->w_p_wrap) {
// Without wrapping, we might need to display right_align and win_col
// virt_text for the entire text line.
decor_redraw_col(wp, MAXCOL, -1, true, &decor_state);
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 8a94eaef1b..5f9ac2265c 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -894,6 +894,16 @@ describe('extmark decorations', function()
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)
it('virt_text_hide hides overlay virtual text when extmark is off-screen', function()
@@ -1265,6 +1275,44 @@ describe('extmark decorations', function()
{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)
it('can have virtual text on folded line', function()
@@ -1273,7 +1321,6 @@ describe('extmark decorations', function()
22222
33333]])
command('1,2fold')
- command('set nowrap')
screen:try_resize(50, 3)
feed('zb')
-- XXX: the behavior of overlay virtual text at non-zero column is strange:
@@ -1287,6 +1334,8 @@ describe('extmark decorations', function()
3333^3 |
|
]]}
+ command('set nowrap')
+ screen:expect_unchanged()
feed('zl')
screen:expect{grid=[[
{29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}|