mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:9.0.1828: cursor wrong with virt text before double-width char (#24967)
Problem: Wrong cursor position with virtual text before double-width
char at window edge.
Solution: Check for double-width char before adding virtual text size.
closes: vim/vim#12977
ac2d8815ae
This commit is contained in:
@@ -216,6 +216,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
if (*s == NUL && !has_lcs_eol) {
|
if (*s == NUL && !has_lcs_eol) {
|
||||||
size = 0; // NUL is not displayed
|
size = 0; // NUL is not displayed
|
||||||
}
|
}
|
||||||
|
bool is_doublewidth = size == 2 && MB_BYTE2LEN((uint8_t)(*s)) > 1;
|
||||||
|
|
||||||
if (cts->cts_has_virt_text) {
|
if (cts->cts_has_virt_text) {
|
||||||
int tab_size = size;
|
int tab_size = size;
|
||||||
@@ -247,8 +248,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == 2 && MB_BYTE2LEN((uint8_t)(*s)) > 1
|
if (is_doublewidth && wp->w_p_wrap && in_win_border(wp, vcol + size - 2)) {
|
||||||
&& wp->w_p_wrap && in_win_border(wp, vcol)) {
|
|
||||||
// Count the ">" in the last column.
|
// Count the ">" in the last column.
|
||||||
size++;
|
size++;
|
||||||
mb_added = 1;
|
mb_added = 1;
|
||||||
|
@@ -3244,6 +3244,19 @@ describe('decorations: inline virtual text', function()
|
|||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('before double-width char that wraps', function()
|
||||||
|
exec([[
|
||||||
|
call setline(1, repeat('a', 40) .. '口' .. '12345')
|
||||||
|
normal! $
|
||||||
|
]])
|
||||||
|
meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' })
|
||||||
|
screen:expect{grid=[[
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
|
||||||
|
口1234^5 |
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('decorations: virtual lines', function()
|
describe('decorations: virtual lines', function()
|
||||||
|
Reference in New Issue
Block a user