vim-patch:9.0.0702: incomplete testing cursor position with 'linebreak' set

Problem:    Incomplete testing cursor position after change with 'linebreak'
            set.
Solution:   Add a test and move test cases together. (closes vim/vim#11313)
30c0c467d6
This commit is contained in:
zeertzjq 2022-10-09 18:57:22 +08:00
parent c93fd83df2
commit 7cdaa74b36
3 changed files with 120 additions and 40 deletions

View File

@ -134,22 +134,41 @@ func Test_linebreak_with_visual_operations()
call s:close_windows()
endfunc
" Test that cursor is drawn at correct position after an operator when
" 'linebreak' is enabled.
func Test_linebreak_reset_restore()
CheckScreendump
" f_wincol() calls validate_cursor()
let lines =<< trim END
vim9script
&linebreak = true
&showcmd = true
&showmode = false
('a'->repeat(&columns - 10) .. ' ' .. 'b'->repeat(10) .. ' c')->setline(1)
set linebreak showcmd noshowmode formatexpr=wincol()-wincol()
call setline(1, repeat('a', &columns - 10) .. ' bbbbbbbbbb c')
END
call writefile(lines, 'XlbrResetRestore', 'D')
let buf = RunVimInTerminal('-S XlbrResetRestore', {'rows': 8})
call term_sendkeys(buf, '$v$s')
call term_sendkeys(buf, '$v$')
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 'zo')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call term_sendkeys(buf, '$v$')
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 'gq')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call term_sendkeys(buf, "$\<C-V>$")
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 'I')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call term_sendkeys(buf, "\<Esc>$v$")
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 's')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call VerifyScreenDump(buf, 'Test_linebreak_reset_restore_1', {})
" clean up
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
endfunc

View File

@ -1492,37 +1492,4 @@ func Test_switch_buffer_ends_visual_mode()
exe 'bwipe!' buf2
endfunc
" Test that cursor is drawn at correct position after an operator in Visual
" mode when 'linebreak' and 'showcmd' are enabled.
func Test_visual_operator_with_linebreak()
CheckRunVimInTerminal
let lines =<< trim END
set linebreak showcmd noshowmode
call setline(1, repeat('a', &columns - 10) .. ' bbbbbbbbbb c')
END
call writefile(lines, 'XTest_visual_op_linebreak', 'D')
let buf = RunVimInTerminal('-S XTest_visual_op_linebreak', {'rows': 6})
call term_sendkeys(buf, '$v$')
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 'zo')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call term_sendkeys(buf, "$\<C-V>$")
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 'I')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
call term_sendkeys(buf, "\<Esc>$v$")
call WaitForAssert({-> assert_equal(13, term_getcursor(buf)[1])})
call term_sendkeys(buf, 's')
call WaitForAssert({-> assert_equal(12, term_getcursor(buf)[1])})
" clean up
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1,11 +1,12 @@
-- Test for linebreak and list option (non-utf8)
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
describe('listlbr', function()
setup(clear)
before_each(clear)
-- luacheck: ignore 621 (Indentation)
-- luacheck: ignore 611 (Line contains only whitespaces)
@ -195,4 +196,97 @@ describe('listlbr', function()
aa>-----a-$
~ ]])
end)
-- oldtest: Test_linebreak_reset_restore()
it('cursor position is drawn correctly after operator', function()
local screen = Screen.new(60, 6)
screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[1] = {background = Screen.colors.LightGrey}, -- Visual
[2] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg
})
screen:attach()
-- f_wincol() calls validate_cursor()
source([[
set linebreak showcmd noshowmode formatexpr=wincol()-wincol()
call setline(1, repeat('a', &columns - 10) .. ' bbbbbbbbbb c')
]])
feed('$v$')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb {1:c}^ |
{0:~ }|
{0:~ }|
{0:~ }|
2 |
]])
feed('zo')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb ^c |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} |
]])
feed('$v$')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb {1:c}^ |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} 2 |
]])
feed('gq')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb ^c |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} |
]])
feed('$<C-V>$')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb {1:c}^ |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} 1x2 |
]])
feed('I')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb ^c |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} |
]])
feed('<Esc>$v$')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb {1:c}^ |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} 2 |
]])
feed('s')
screen:expect([[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
bbbbbbbbbb ^ |
{0:~ }|
{0:~ }|
{0:~ }|
{2:E490: No fold found} |
]])
end)
end)