Skip to content

Commit

Permalink
fix(snipmate): correctly escape backtick
Browse files Browse the repository at this point in the history
chore: squash commits
  • Loading branch information
danilshvalov committed Sep 20, 2022
1 parent d049b3d commit 1cdeee3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*luasnip.txt* For NVIM v0.5.0 Last change: 2022 September 18
*luasnip.txt* For NVIM v0.5.0 Last change: 2022 September 20

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
2 changes: 1 addition & 1 deletion lua/luasnip/util/parser/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ local function backticks_to_variable(body)
end

-- append remaining characters.
var_string = var_string .. body:sub(processed_to, -1)
var_string = var_string .. body:sub(processed_to, -1):gsub("\\`", "`")

return var_map, var_string
end
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/parser_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,17 @@ describe("Parser", function()
{2:-- INSERT --} |]],
})
end)

it("correctly parses escaped characters.", function()
ls_helpers.session_setup_luasnip()
local snip = [["\\`\\`\\` `'abc' . '\\`lel'`"]]

exec_lua("ls.snip_expand(ls.parser.parse_snipmate('', " .. snip .. "))")
screen:expect({
grid = [[
``` abc\`lel^ |
{0:~ }|
{2:-- INSERT --} |]],
})
end)
end)

0 comments on commit 1cdeee3

Please sign in to comment.