diff src/testdir/test_listlbr.vim @ 30735:09a61a174259 v9.0.0702

patch 9.0.0702: incomplete testing cursor position with 'linebreak' set Commit: https://github.com/vim/vim/commit/30c0c467d6cc2a7af960ccb9002b50115b0e55cf Author: zeertzjq <zeertzjq@outlook.com> Date: Sun Oct 9 11:44:28 2022 +0100 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 #11313)
author Bram Moolenaar <Bram@vim.org>
date Sun, 09 Oct 2022 12:45:05 +0200
parents 1cbb01bc75c3
children fe1550f920d8
line wrap: on
line diff
--- a/src/testdir/test_listlbr.vim
+++ b/src/testdir/test_listlbr.vim
@@ -134,22 +134,41 @@ func Test_linebreak_with_visual_operatio
   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