neovim

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

test_searchpos.vim (910B)


      1 " Tests for searchpos()
      2 
      3 func Test_searchpos()
      4  new one
      5  0put ='1a3'
      6  1put ='123xyz'
      7  call cursor(1, 1)
      8  call assert_equal([1, 1, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
      9  call cursor(1, 2)
     10  call assert_equal([2, 1, 1], '\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW'))
     11  set cpo-=c
     12  call cursor(1, 2)
     13  call assert_equal([1, 2, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
     14  call cursor(1, 3)
     15  call assert_equal([1, 3, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
     16 
     17  " Now with \zs, first match is in column 0, "a" is matched.
     18  call cursor(1, 3)
     19  call assert_equal([2, 4, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW'))
     20  " With z flag start at cursor column, don't see the "a".
     21  call cursor(1, 3)
     22  call assert_equal([2, 4, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz'))
     23 
     24  set cpo+=c
     25  " close the window
     26  q!
     27 
     28 endfunc
     29 
     30 " vim: shiftwidth=2 sts=2 expandtab