710 lines
20 KiB
Plaintext
710 lines
20 KiB
Plaintext
let s:expect = themis#helper('expect')
|
|
|
|
function! s:expect_selection(s, e) abort
|
|
if &selection ==# 'exclusive' && &virtualedit ==# ''
|
|
return
|
|
endif
|
|
|
|
call s:expect(getpos("'<")[1 : 2]).to_equal([a:s[0], a:s[1]])
|
|
if &selection ==# 'exclusive'
|
|
let l:text = getline('.')
|
|
let l:char = strcharpart(l:text, charidx(l:text, a:e[1] - 1), 1)
|
|
let a:e[1] = a:e[1] + strlen(l:char)
|
|
endif
|
|
call s:expect(getpos("'>")[1 : 2]).to_equal([a:e[0], a:e[1]])
|
|
endfunction
|
|
|
|
Describe vsnip
|
|
|
|
After each
|
|
call vsnip#deactivate()
|
|
End
|
|
|
|
Context expand
|
|
|
|
It should expand when prefix start col is 1
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec1')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 8])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should expand when prefix is in middle of line
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, '(spec1)')
|
|
call cursor([1, 6])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['(snippet)'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should expand when prefix was selected in select-mode
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec1')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("v$\<C-g>\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should not expand when prefix is word and it does not separate by word boundary
|
|
enew!
|
|
set filetype=integration
|
|
set iskeyword=@,48-57,_,192-255
|
|
call setline(1, '(aspec1)')
|
|
call cursor([1, 7])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['(aspec1', ')'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should jump to first placeholder when expanded snippet
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec2')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 1])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
End
|
|
|
|
Context jump
|
|
|
|
It should jump to first of snippet
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec2')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 1])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should jump to middle of snippet
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec3')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 4])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should jump to last of snippet
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec4')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 8])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 1 length first of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec5')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 1], [1, 1])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 1 length middle of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec6')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 3], [1, 3])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 1 length last of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec7')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 7], [1, 7])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 3 length first of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec8')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 1], [1, 3])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 3 length middle of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec9')
|
|
call cursor([1, 5])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 3], [1, 5])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 3 length last of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'spec10')
|
|
call cursor([1, 6])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 5], [1, 7])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['snippet'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
End
|
|
|
|
Context multibyte
|
|
|
|
It should jump to middle of snippet
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'マルチ1')
|
|
call cursor([1, 10])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 7])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['あいう'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should select 4 length middle of snippet text
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'マルチ2')
|
|
call cursor([1, 10])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 7], [1, 12])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['あいかkaかう'])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Tab>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
End
|
|
|
|
Context g:vsnip_deactivate_on
|
|
It should deactivate snippet on edit the outside of snippet
|
|
enew!
|
|
set filetype=integration
|
|
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
|
|
|
call setline(1, [
|
|
\ 'outside',
|
|
\ 'deactivate',
|
|
\ 'outside',
|
|
\ ])
|
|
call cursor([2, 11])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(vsnip#get_session()).not.to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(vsnip#get_session()).not.to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "funcname\<Plug>(vsnip-assert)"
|
|
|
|
function g:vsnip_assert.step3()
|
|
call s:expect(vsnip#get_session()).not.to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "\<Tab>return 1\<Plug>(vsnip-assert)"
|
|
|
|
function g:vsnip_assert.step4()
|
|
call s:expect(vsnip#get_session()).to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "\<Cmd>call cursor([1, 1])\<CR>modified\<Esc>"
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
|
|
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
|
End
|
|
|
|
It should deactivate snippet on edit the outside of current tabstop
|
|
enew!
|
|
set filetype=integration
|
|
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfCurrentTabstop
|
|
|
|
call setline(1, [
|
|
\ 'outside',
|
|
\ 'deactivate',
|
|
\ 'outside',
|
|
\ ])
|
|
call cursor([2, 11])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(vsnip#get_session()).not.to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(vsnip#get_session()).not.to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "funcname\<Plug>(vsnip-assert)"
|
|
|
|
function g:vsnip_assert.step3()
|
|
call s:expect(vsnip#get_session()).to_be_empty()
|
|
endfunction
|
|
let l:sequence .= "\<Right>arguments\<Plug>(vsnip-assert)"
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
|
|
let g:vsnip_deactivate_on = g:vsnip#DeactivateOn.OutsideOfSnippet
|
|
End
|
|
End
|
|
|
|
Context realworld
|
|
|
|
It should work (complex example)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'realworld1')
|
|
call cursor([1, 10])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
" expand and jump
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ '/** @class ClassName */',
|
|
\ 'class ClassName extends ParentClassName {',
|
|
\ ' public constructor() {',
|
|
\ ' ',
|
|
\ ' }',
|
|
\ '}',
|
|
\ ])
|
|
endfunction
|
|
|
|
" sync placeholder
|
|
let l:sequence .= "ModifiedClassName\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ '/** @class ModifiedClassName */',
|
|
\ 'class ModifiedClassName extends ParentClassName {',
|
|
\ ' public constructor() {',
|
|
\ ' ',
|
|
\ ' }',
|
|
\ '}',
|
|
\ ])
|
|
endfunction
|
|
|
|
" edit nested placeholder
|
|
let l:sequence .= "\<Tab>\<Tab>ModifiedParentClassName\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step3()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ '/** @class ModifiedClassName */',
|
|
\ 'class ModifiedClassName extends ModifiedParentClassName {',
|
|
\ ' public constructor() {',
|
|
\ ' ',
|
|
\ ' }',
|
|
\ '}',
|
|
\ ])
|
|
endfunction
|
|
|
|
" remove nested placeholder by <BS>
|
|
let l:sequence .= "\<S-Tab>\<BS>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step4()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ '/** @class ModifiedClassName */',
|
|
\ 'class ModifiedClassName {',
|
|
\ ' public constructor() {',
|
|
\ ' ',
|
|
\ ' }',
|
|
\ '}',
|
|
\ ])
|
|
endfunction
|
|
|
|
" jump to final tabstop
|
|
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step5()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([4, 5])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ '/** @class ModifiedClassName */',
|
|
\ 'class ModifiedClassName {',
|
|
\ ' public constructor() {',
|
|
\ ' ',
|
|
\ ' }',
|
|
\ '}',
|
|
\ ])
|
|
endfunction
|
|
call feedkeys(l:sequence, 'x')
|
|
End
|
|
|
|
It should work ($VIM variable)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'realworld2')
|
|
call cursor([1, 10])
|
|
|
|
let g:vsnip_assert = {}
|
|
function! g:vsnip_assert.step1() abort
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ $USER
|
|
\ ])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should work (indented $TM_SELECTED_TEXT char-wise)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, [
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>'
|
|
\ ])
|
|
let g:vsnip_assert = {}
|
|
function! g:vsnip_assert.step1() abort
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ ' <div>',
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>',
|
|
\ ' </div>'
|
|
\ ])
|
|
endfunction
|
|
call feedkeys("1G3|v3G7|\<Plug>(vsnip-cut-text)realworld3\<C-j>", 'x')
|
|
End
|
|
|
|
It should work (indented $TM_SELECTED_TEXT line-wise)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, [
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>'
|
|
\ ])
|
|
let g:vsnip_assert = {}
|
|
function! g:vsnip_assert.step1() abort
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ ' <div>',
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>',
|
|
\ ' </div>'
|
|
\ ])
|
|
endfunction
|
|
call feedkeys("1GV3G\<Plug>(vsnip-cut-text)realworld3\<C-j>", 'x')
|
|
End
|
|
|
|
It should work (no indented $TM_SELECTED_TEXT char-wise)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, [
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>'
|
|
\ ])
|
|
let g:vsnip_assert = {}
|
|
function! g:vsnip_assert.step1() abort
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ ' <div><div>',
|
|
\ ' <span />',
|
|
\ ' </div></div>'
|
|
\ ])
|
|
endfunction
|
|
call feedkeys("1G3|v3G7|\<Plug>(vsnip-cut-text)realworld4\<C-j>", 'x')
|
|
End
|
|
|
|
It should work (no indented $TM_SELECTED_TEXT line-wise)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, [
|
|
\ ' <div>',
|
|
\ ' <span />',
|
|
\ ' </div>'
|
|
\ ])
|
|
let g:vsnip_assert = {}
|
|
function! g:vsnip_assert.step1() abort
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ ' <div><div>',
|
|
\ ' <span />',
|
|
\ ' </div></div>'
|
|
\ ])
|
|
endfunction
|
|
call feedkeys("1GV3G\<Plug>(vsnip-cut-text)realworld4\<C-j>", 'x')
|
|
End
|
|
|
|
It should work (modify follower placeholder manually)
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'realworld5')
|
|
call cursor([1, 10])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
" expand and jump
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ ', ________'
|
|
\ ])
|
|
endfunction
|
|
|
|
" edit $1
|
|
let l:sequence .= "foobar\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'foobar, ____foobar____'
|
|
\ ])
|
|
endfunction
|
|
|
|
" edit $1's follower
|
|
let l:sequence .= "\<Esc>1G16|dt_ibaz\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step3()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'foobar, ____foobaz____'
|
|
\ ])
|
|
endfunction
|
|
|
|
" edit $1 again
|
|
let l:sequence .= "\<Esc>1G1|dt,imodified\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step4()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'modified, ____foobaz____'
|
|
\ ])
|
|
endfunction
|
|
|
|
" can jump to $2
|
|
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step5()
|
|
call s:expect_selection([1, 11], [1, 24])
|
|
endfunction
|
|
|
|
" can jump to $3
|
|
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step6()
|
|
call s:expect_selection([1, 12], [1, 23])
|
|
endfunction
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
End
|
|
|
|
End
|
|
|
|
Context issue
|
|
|
|
It should work issue82
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, "'")
|
|
call cursor([1, 1])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 2])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(["''"])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should work issue85
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, 'issue85')
|
|
call cursor([1, 7])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['for i=1,10', ' print(i)'])
|
|
call s:expect_selection([1, 5], [1, 5])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should work issue106
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, ['foo', 'issue106'])
|
|
call cursor([2, 8])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(vsnip#get_session()).to_be_empty()
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Esc>gg0i_\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should work issue122
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, ['foo', 'issue122>'])
|
|
call cursor([2, 9])
|
|
|
|
let g:vsnip_assert = {}
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(['foo', ''])
|
|
endfunction
|
|
call feedkeys("a\<C-j>\<Plug>(vsnip-assert)", 'x')
|
|
End
|
|
|
|
It should work issue129
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, ['issue129'])
|
|
call cursor([1, 8])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
" expand
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(["console.log('', );"])
|
|
endfunction
|
|
|
|
" modify
|
|
let l:sequence .= "\<Esc>1G13|dt,iMODIFY\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal(["console.log(MODIFY, );"])
|
|
endfunction
|
|
|
|
" jump
|
|
let l:sequence .= "\<Tab>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step3()
|
|
call s:expect(getcurpos()[1 : 2]).to_equal([1, 21])
|
|
endfunction
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
End
|
|
|
|
It should work issue139
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, ['issue139'])
|
|
call cursor([1, 8])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
" expand
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step1()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'for (size_t i=0; i < count; i++) {',
|
|
\ ' ',
|
|
\ '}'
|
|
\ ])
|
|
endfunction
|
|
|
|
" modify
|
|
let l:sequence .= "\<BS>\<Tab>variable\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step2()
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'for (variable=0; variable < count; variable++) {',
|
|
\ ' ',
|
|
\ '}'
|
|
\ ])
|
|
endfunction
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
End
|
|
|
|
It should work issue249
|
|
enew!
|
|
set filetype=integration
|
|
call setline(1, ['issue249'])
|
|
call cursor([1, 8])
|
|
|
|
let g:vsnip_assert = {}
|
|
let l:sequence = ''
|
|
|
|
" expand
|
|
let l:sequence .= "a\<C-j>\<Plug>(vsnip-assert)"
|
|
function g:vsnip_assert.step1()
|
|
call s:expect_selection([1, 1], [1, 3])
|
|
call s:expect(getbufline('%', '^', '$')).to_equal([
|
|
\ 'FOO',
|
|
\ '',
|
|
\ ])
|
|
endfunction
|
|
|
|
call feedkeys(l:sequence, 'x')
|
|
End
|
|
|
|
End
|
|
|
|
End
|
|
|