neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_curswant.vim (2006B)


      1 " Tests for not changing curswant
      2 
      3 source check.vim
      4 source term_util.vim
      5 
      6 func Test_curswant()
      7  new
      8  call append(0, ['1234567890', '12345'])
      9 
     10  normal! ggf8j
     11  call assert_equal(7, winsaveview().curswant)
     12  let &tabstop=&tabstop
     13  call assert_equal(4, winsaveview().curswant)
     14 
     15  normal! ggf8j
     16  call assert_equal(7, winsaveview().curswant)
     17  let &timeoutlen=&timeoutlen
     18  call assert_equal(7, winsaveview().curswant)
     19 
     20  normal! ggf8j
     21  call assert_equal(7, winsaveview().curswant)
     22  let &ttimeoutlen=&ttimeoutlen
     23  call assert_equal(7, winsaveview().curswant)
     24 
     25  bw!
     26 endfunc
     27 
     28 func Test_normal_gm()
     29  CheckRunVimInTerminal
     30  let lines =<< trim END
     31    call setline(1, repeat(["  abcd\tefgh\tij"], 10))
     32    call cursor(1, 1)
     33  END
     34  call writefile(lines, 'XtestCurswant', 'D')
     35  let buf = RunVimInTerminal('-S XtestCurswant', #{rows: 10})
     36  if has("folding")
     37    call term_sendkeys(buf, "jVjzf")
     38    " gm
     39    call term_sendkeys(buf, "gmk")
     40    call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     41    call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
     42    " g0
     43    call term_sendkeys(buf, "jg0k")
     44    call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     45    call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
     46    " g^
     47    call term_sendkeys(buf, "jg^k")
     48    call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     49    call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
     50  endif
     51  call term_sendkeys(buf, ":call cursor(10, 1)\<cr>")
     52  " gm
     53  call term_sendkeys(buf, "gmk")
     54  call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     55  call term_wait(buf)
     56  call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
     57  " g0
     58  call term_sendkeys(buf, "g0k")
     59  call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     60  call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
     61  " g^
     62  call term_sendkeys(buf, "g^k")
     63  call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
     64  call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
     65  " clean up
     66  call StopVimInTerminal(buf)
     67  wincmd p
     68  wincmd c
     69 endfunc
     70 
     71 " vim: shiftwidth=2 sts=2 expandtab