mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit (#29793)
Problem: Wrong cursor position with 'breakindent' when a double-width character doesn't fit in a screen line (mikoto2000) Solution: Include the width of the 'breakindent' properly. (zeertzjq) fixes: vim/vim#15289 closes: vim/vim#15290b5d6b5caac
(cherry picked from commit35b35cb93c
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
0389472961
commit
804a94d300
@@ -267,7 +267,7 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco
|
|||||||
head += (max_head_vcol - (vcol + head_prev + prev_rem)
|
head += (max_head_vcol - (vcol + head_prev + prev_rem)
|
||||||
+ width2 - 1) / width2 * head_mid;
|
+ width2 - 1) / width2 * head_mid;
|
||||||
} else if (max_head_vcol < 0) {
|
} else if (max_head_vcol < 0) {
|
||||||
int off = virt_text_cursor_off(csarg, *cur == NUL);
|
int off = mb_added + virt_text_cursor_off(csarg, *cur == NUL);
|
||||||
if (off >= prev_rem) {
|
if (off >= prev_rem) {
|
||||||
if (size > off) {
|
if (size > off) {
|
||||||
head += (1 + (off - prev_rem) / width) * head_mid;
|
head += (1 + (off - prev_rem) / width) * head_mid;
|
||||||
|
@@ -4027,11 +4027,23 @@ describe('decorations: inline virtual text', function()
|
|||||||
normal! $
|
normal! $
|
||||||
]])
|
]])
|
||||||
api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' })
|
api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' })
|
||||||
screen:expect{grid=[[
|
screen:expect([[
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
|
||||||
口1234^5 |
|
口1234^5 |
|
||||||
|
|
|
|
||||||
]]}
|
]])
|
||||||
|
feed('g0')
|
||||||
|
screen:expect([[
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
|
||||||
|
^口12345 |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
command('set showbreak=+++')
|
||||||
|
screen:expect([[
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}|
|
||||||
|
{1:+++}^口12345 |
|
||||||
|
|
|
||||||
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -1205,4 +1205,15 @@ func Test_breakindent_min_with_signcol()
|
|||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_breakindent_with_double_width_wrap()
|
||||||
|
50vnew
|
||||||
|
setlocal tabstop=8 breakindent nolist
|
||||||
|
call setline(1, "\t" .. repeat('a', winwidth(0) - 9) .. '口口口')
|
||||||
|
normal! $g0
|
||||||
|
call assert_equal(2, winline())
|
||||||
|
call assert_equal(9, wincol())
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -280,6 +280,9 @@ func Test_chinese_char_on_wrap_column()
|
|||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
call assert_equal(len(expect), winline())
|
call assert_equal(len(expect), winline())
|
||||||
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
|
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
|
||||||
|
norm! g0
|
||||||
|
call assert_equal(len(expect), winline())
|
||||||
|
call assert_equal(1, wincol())
|
||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -315,6 +318,9 @@ func Test_chinese_char_on_wrap_column_sbr()
|
|||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
call assert_equal(len(expect), winline())
|
call assert_equal(len(expect), winline())
|
||||||
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
|
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
|
||||||
|
norm! g0
|
||||||
|
call assert_equal(len(expect), winline())
|
||||||
|
call assert_equal(4, wincol())
|
||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user