neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 60af1a1db285e1cf2b73d1e5934b044b697287f1
parent b8763cb21525b026de4a39b508de07d57cac6faa
Author: Riley Bruins <ribru17@hotmail.com>
Date:   Sat, 12 Apr 2025 15:51:29 -0700

fix(treesitter): clear parse options state #33437

Apparently after parsing with options in tree-sitter, the options data
persists in the parser object, and thus successive calls to
`ts_parser_parse()` will act like `ts_parser_parse_with_options()`. This
is problematic because `languagetree.lua` makes coroutine-environment
assumptions based on if a nullptr has been returned by the parser
function. This commit makes it so that the parse options state is reset
upon a regular parse (would be nice if this was done upstream).

Fixes #33277
Diffstat:
Msrc/nvim/lua/treesitter.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c @@ -545,7 +545,8 @@ static int parser_parse(lua_State *L) .progress_callback = on_parser_progress }; new_tree = ts_parser_parse_with_options(p, old_tree, input, parse_options); } else { - new_tree = ts_parser_parse(p, old_tree, input); + // Tree-sitter retains parse options after use, so we must explicitly reset them here. + new_tree = ts_parser_parse_with_options(p, old_tree, input, (TSParseOptions) { 0 }); } break;