fix(treesitter): escape "\" in :InspectTree #28613

Some parsers for, e.g., LaTeX or PHP have anonymous nodes like `"\"` or `"\text"` that behave wonkily (especially the first example) in the `InspectTree` window, so this PR escapes them by adding another backslash in front of them
This commit is contained in:
Riley Bruins 2024-05-03 09:34:02 -07:00 committed by GitHub
parent d50596e1e3
commit 3a8265266e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -226,7 +226,7 @@ function TSTreeView:draw(bufnr)
text = string.format('(%s', item.node:type())
end
else
text = string.format('"%s"', item.node:type():gsub('\n', '\\n'):gsub('"', '\\"'))
text = string.format('%q', item.node:type()):gsub('\n', 'n')
end
local next = self:get(i + 1)