mirror of
https://github.com/neovim/neovim.git
synced 2025-12-08 15:42:52 +00:00
vim-patch:9.1.1922: Wrong virtcol('$') with virtual text at EOL (#36643)
Problem: Wrong virtcol('$') with virtual text at EOL (rickhowe).
Solution: Also add 1 to end virtcol when there is virtual text.
(zeertzjq)
fixes: vim/vim#18761
closes: vim/vim#18762
d434f6c2a5
This commit is contained in:
@@ -551,9 +551,10 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
} else {
|
} else {
|
||||||
while (true) {
|
while (true) {
|
||||||
char_size = charsize_regular(&csarg, ci.ptr, vcol, ci.chr.value);
|
char_size = charsize_regular(&csarg, ci.ptr, vcol, ci.chr.value);
|
||||||
|
// make sure we don't go past the end of the line
|
||||||
if (*ci.ptr == NUL) {
|
if (*ci.ptr == NUL) {
|
||||||
// if cursor is at NUL, it is treated like 1 cell char unless there is virtual text
|
// NUL at end of line only takes one column unless there is virtual text
|
||||||
char_size.width = MAX(1, csarg.cur_text_width_left + csarg.cur_text_width_right);
|
char_size.width = 1 + csarg.cur_text_width_left + csarg.cur_text_width_right;
|
||||||
on_NUL = true;
|
on_NUL = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5872,6 +5872,17 @@ describe('decorations: inline virtual text', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("virtcol('$') is correct with inline virt text at EOL", function()
|
||||||
|
insert(('1234567890\n'):rep(6))
|
||||||
|
for _, v in ipairs({ { 2, 'a' }, { 3, 'ab' }, { 4, 'abc' }, { 5, 'abcd' }, { 6, 'αβγ口' } }) do
|
||||||
|
local ln, tx = unpack(v)
|
||||||
|
local co = fn.col({ ln, '$' })
|
||||||
|
eq(11, fn.virtcol({ ln, '$' }))
|
||||||
|
api.nvim_buf_set_extmark(0, ns, ln - 1, co - 1, { virt_text = { { tx } }, virt_text_pos = 'inline' })
|
||||||
|
eq(11 + fn.strwidth(tx), fn.virtcol({ ln, '$' }))
|
||||||
|
end
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('decorations: virtual lines', function()
|
describe('decorations: virtual lines', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user