mirror of
https://github.com/neovim/neovim.git
synced 2026-05-06 16:29:57 -04:00
fix(treesitter): TSNode:id() with NUL byte causes unreliable select() #39134
Problem:
`TSNode:id()` returns the underlying c pointer as a string, which may include
NUL bytes. In PUC Lua, `('%s'):format('\0a\0')` returns `''` and not `'\0a\0'`
(i.e. treats the string as a c-string (which terminates at the NUL byte)).
This resulted in two different nodes being able to have the same id.
Solution:
Use concatenation `..` instead of `string.format()`.
(cherry picked from commit bb2284d75e)
This commit is contained in:
committed by
github-actions[bot]
parent
b08c289a45
commit
111c7f434e
@@ -36,7 +36,7 @@ local M = {}
|
||||
--- @param node vim.treesitter.select.node
|
||||
--- @return string
|
||||
local function node_id(node)
|
||||
return ('%s:%s'):format(table.concat({ unpack(node.top.region) }, ':'), node.node:id())
|
||||
return table.concat({ unpack(node.top.region) }, ':') .. ':' .. node.node:id()
|
||||
end
|
||||
|
||||
--- @param node vim.treesitter.select.node
|
||||
|
||||
@@ -81,10 +81,6 @@ describe('treesitter incremental-selection', function()
|
||||
treeselect('select_next', 3)
|
||||
eq('4', get_selected())
|
||||
|
||||
if t.skip(jit == nil, 'sometimes fails on PUC lua') then
|
||||
return
|
||||
end
|
||||
|
||||
treeselect('select_prev', 2)
|
||||
eq('2', get_selected())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user