mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
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
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user