fix(snippet): adjacent tabstops without placeholders (#35167)

* fix(snippet): adjacent tabstops without placeholders

* test(snippet): add tests for directly adjacent tabstops
This commit is contained in:
TheBlob42
2025-08-13 20:51:43 +02:00
committed by GitHub
parent 7b9512e613
commit 6f904cfef1
2 changed files with 123 additions and 33 deletions

View File

@@ -163,6 +163,48 @@ describe('vim.snippet', function()
eq({ 'class Foo() {', ' // Inside', '}' }, buf_lines(0))
end)
it('handles directly adjacent tabstops (ascending order)', function()
test_expand_success({ '${1:one}${2:-two}${3:-three}' }, { 'one-two-three' })
feed('1')
feed('<Tab>')
poke_eventloop()
feed('2')
feed('<Tab>')
poke_eventloop()
feed('3')
feed('<Tab>')
poke_eventloop()
eq({ '123' }, buf_lines(0))
end)
it('handles directly adjacent tabstops (descending order)', function()
test_expand_success({ '${3:three}${2:-two}${1:-one}' }, { 'three-two-one' })
feed('1')
feed('<Tab>')
poke_eventloop()
feed('2')
feed('<Tab>')
poke_eventloop()
feed('3')
feed('<Tab>')
poke_eventloop()
eq({ '321' }, buf_lines(0))
end)
it('handles directly adjacent tabstops (mixed order)', function()
test_expand_success({ '${3:three}${1:-one}${2:-two}' }, { 'three-one-two' })
feed('1')
feed('<Tab>')
poke_eventloop()
feed('2')
feed('<Tab>')
poke_eventloop()
feed('3')
feed('<Tab>')
poke_eventloop()
eq({ '312' }, buf_lines(0))
end)
it('handles multiline placeholders', function()
test_expand_success(
{ 'public void foo() {', ' ${0:// TODO Auto-generated', ' throw;}', '}' },