mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.1.0176: Cursor column wrong with 'virtualedit' and conceal
Problem: Cursor column wrong with 'virtualedit' and conceal.
Solution: Correct cursor column at end of line if never reached.
(zeertzjq)
closes: vim/vim#14190
253ff4dece
This commit is contained in:
@@ -2451,11 +2451,17 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
|
||||
|
||||
// In the cursor line and we may be concealing characters: correct
|
||||
// the cursor column when we reach its position.
|
||||
// With 'virtualedit' we may never reach cursor position, but we still
|
||||
// need to correct the cursor column, so do that at end of line.
|
||||
if (!did_wcol
|
||||
&& wp == curwin && lnum == wp->w_cursor.lnum
|
||||
&& conceal_cursor_line(wp)
|
||||
&& (int)wp->w_virtcol <= wlv.vcol + wlv.skip_cells) {
|
||||
&& (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) {
|
||||
wp->w_wcol = wlv.col - wlv.boguscols;
|
||||
if (wlv.vcol + wlv.skip_cells < wp->w_virtcol) {
|
||||
// Cursor beyond end of the line with 'virtualedit'.
|
||||
wp->w_wcol += wp->w_virtcol - wlv.vcol - wlv.skip_cells;
|
||||
}
|
||||
wp->w_wrow = wlv.row;
|
||||
did_wcol = true;
|
||||
wp->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
|
||||
|
@@ -632,4 +632,92 @@ describe('Conceal', function()
|
||||
feed('$')
|
||||
expect_pos(9, 26)
|
||||
end)
|
||||
|
||||
-- oldtest: Test_conceal_virtualedit_after_eol()
|
||||
it('cursor drawn at correct column with virtualedit', function()
|
||||
local screen = Screen.new(75, 3)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
||||
})
|
||||
screen:attach()
|
||||
exec([[
|
||||
call setline(1, 'abcdefgh|hidden|ijklmnpop')
|
||||
syntax match test /|hidden|/ conceal
|
||||
set conceallevel=2 concealcursor=n virtualedit=all
|
||||
normal! $
|
||||
]])
|
||||
screen:expect([[
|
||||
abcdefghijklmnpo^p |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('l')
|
||||
screen:expect([[
|
||||
abcdefghijklmnpop^ |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('l')
|
||||
screen:expect([[
|
||||
abcdefghijklmnpop ^ |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('l')
|
||||
screen:expect([[
|
||||
abcdefghijklmnpop ^ |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('rr')
|
||||
screen:expect([[
|
||||
abcdefghijklmnpop ^r |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
-- oldtest: Test_conceal_virtualedit_after_eol_rightleft()
|
||||
it('cursor drawn correctly with virtualedit and rightleft', function()
|
||||
local screen = Screen.new(75, 3)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
||||
})
|
||||
screen:attach()
|
||||
exec([[
|
||||
call setline(1, 'abcdefgh|hidden|ijklmnpop')
|
||||
syntax match test /|hidden|/ conceal
|
||||
set conceallevel=2 concealcursor=n virtualedit=all rightleft
|
||||
normal! $
|
||||
]])
|
||||
screen:expect([[
|
||||
^popnmlkjihgfedcba|
|
||||
{0: ~}|
|
||||
|
|
||||
]])
|
||||
feed('h')
|
||||
screen:expect([[
|
||||
^ popnmlkjihgfedcba|
|
||||
{0: ~}|
|
||||
|
|
||||
]])
|
||||
feed('h')
|
||||
screen:expect([[
|
||||
^ popnmlkjihgfedcba|
|
||||
{0: ~}|
|
||||
|
|
||||
]])
|
||||
feed('h')
|
||||
screen:expect([[
|
||||
^ popnmlkjihgfedcba|
|
||||
{0: ~}|
|
||||
|
|
||||
]])
|
||||
feed('rr')
|
||||
screen:expect([[
|
||||
^r popnmlkjihgfedcba|
|
||||
{0: ~}|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
@@ -460,4 +460,58 @@ func Test_conceal_mouse_click()
|
||||
set mouse& virtualedit&
|
||||
endfunc
|
||||
|
||||
" Test that cursor is drawn at the correct column when it is after end of the
|
||||
" line with 'virtualedit' and concealing.
|
||||
func Test_conceal_virtualedit_after_eol()
|
||||
CheckScreendump
|
||||
|
||||
let code =<< trim [CODE]
|
||||
call setline(1, 'abcdefgh|hidden|ijklmnpop')
|
||||
syntax match test /|hidden|/ conceal
|
||||
set conceallevel=2 concealcursor=n virtualedit=all
|
||||
normal! $
|
||||
[CODE]
|
||||
call writefile(code, 'XTest_conceal_ve_after_eol', 'D')
|
||||
let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol', {'rows': 3})
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_1', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_2', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_3', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_4', {})
|
||||
call term_sendkeys(buf, "rr")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_5', {})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" Same as Test_conceal_virtualedit_after_eol(), but with 'rightleft' set.
|
||||
func Test_conceal_virtualedit_after_eol_rightleft()
|
||||
CheckFeature rightleft
|
||||
CheckScreendump
|
||||
|
||||
let code =<< trim [CODE]
|
||||
call setline(1, 'abcdefgh|hidden|ijklmnpop')
|
||||
syntax match test /|hidden|/ conceal
|
||||
set conceallevel=2 concealcursor=n virtualedit=all rightleft
|
||||
normal! $
|
||||
[CODE]
|
||||
call writefile(code, 'XTest_conceal_ve_after_eol_rl', 'D')
|
||||
let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol_rl', {'rows': 3})
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_1', {})
|
||||
call term_sendkeys(buf, "h")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_2', {})
|
||||
call term_sendkeys(buf, "h")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_3', {})
|
||||
call term_sendkeys(buf, "h")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_4', {})
|
||||
call term_sendkeys(buf, "rr")
|
||||
call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_5', {})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user