feat(snippet): highlight active tabstop (#35378)

This commit is contained in:
TheBlob42
2025-08-19 15:21:32 +02:00
committed by GitHub
parent 25bc41847e
commit 701258921e
7 changed files with 31 additions and 5 deletions

View File

@@ -116,6 +116,20 @@ describe('vim.snippet', function()
test_expand_success({ 'print($UNKNOWN)' }, { 'print(UNKNOWN)' })
end)
it('highlights active tabstop with SnippetTabstopActive', function()
local function get_extmark_details(col, end_col)
return api.nvim_buf_get_extmarks(0, -1, { 0, col }, { 0, end_col }, { details = true })[1][4]
end
test_expand_success({ 'local ${1:name} = ${2:value}' }, { 'local name = value' })
eq('SnippetTabstopActive', get_extmark_details(6, 10).hl_group)
eq('SnippetTabstop', get_extmark_details(13, 18).hl_group)
feed('<Tab>')
poke_eventloop()
eq('SnippetTabstop', get_extmark_details(6, 10).hl_group)
eq('SnippetTabstopActive', get_extmark_details(13, 18).hl_group)
end)
it('does not jump outside snippet range', function()
test_expand_success({ 'function $1($2)', ' $0', 'end' }, { 'function ()', ' ', 'end' })
eq(false, exec_lua('return vim.snippet.active({ direction = -1 })'))