mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
feat(treesitter): async parsing
**Problem:** Parsing can be slow for large files, and it is a blocking operation which can be disruptive and annoying. **Solution:** Provide a function for asynchronous parsing, which accepts a callback to be run after parsing completes. Co-authored-by: Lewis Russell <lewis6991@gmail.com> Co-authored-by: Luuk van Baal <luukvbaal@gmail.com> Co-authored-by: VanaIgr <vanaigranov@gmail.com>
This commit is contained in:
@@ -489,7 +489,11 @@ static int parser_parse(lua_State *L)
|
||||
// Sometimes parsing fails (timeout, or wrong parser ABI)
|
||||
// In those case, just return an error.
|
||||
if (!new_tree) {
|
||||
return luaL_error(L, "An error occurred when parsing.");
|
||||
if (ts_parser_timeout_micros(p) == 0) {
|
||||
// No timeout set, must have had an error
|
||||
return luaL_error(L, "An error occurred when parsing.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The new tree will be pushed to the stack, without copy, ownership is now to the lua GC.
|
||||
|
Reference in New Issue
Block a user