diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-04-15 16:48:10 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-04-18 09:19:21 +0200 |
commit | 727040c9530c6bca1b2d9ce70a5c968bef576469 (patch) | |
tree | b20718feaaf2f4c3906c5b28539e86c3d838a2ba /src/tree_sitter/parser.c | |
parent | fb4c7a53cfe4d4c8a786c8a5dc3c4b999c2df815 (diff) | |
download | rneovim-727040c9530c6bca1b2d9ce70a5c968bef576469.tar.gz rneovim-727040c9530c6bca1b2d9ce70a5c968bef576469.tar.bz2 rneovim-727040c9530c6bca1b2d9ce70a5c968bef576469.zip |
treesitter: update vendor code
Update treesitter vendor code to commit
35f82ce301951315e08de3b7e44a18c9170b28b8
Diffstat (limited to 'src/tree_sitter/parser.c')
-rw-r--r-- | src/tree_sitter/parser.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tree_sitter/parser.c b/src/tree_sitter/parser.c index 0fa0c4195b..d4b227308b 100644 --- a/src/tree_sitter/parser.c +++ b/src/tree_sitter/parser.c @@ -324,6 +324,12 @@ static bool ts_parser__can_reuse_first_leaf( TSStateId leaf_state = ts_subtree_leaf_parse_state(tree); TSLexMode leaf_lex_mode = self->language->lex_modes[leaf_state]; + // At the end of a non-terminal extra node, the lexer normally returns + // NULL, which indicates that the parser should look for a reduce action + // at symbol `0`. Avoid reusing tokens in this situation to ensure that + // the same thing happens when incrementally reparsing. + if (current_lex_mode.lex_state == (uint16_t)(-1)) return false; + // If the token was created in a state with the same set of lookaheads, it is reusable. if ( table_entry->action_count > 0 && @@ -593,6 +599,10 @@ static Subtree ts_parser__reuse_node( uint32_t byte_offset = reusable_node_byte_offset(&self->reusable_node); uint32_t end_byte_offset = byte_offset + ts_subtree_total_bytes(result); + // Do not reuse an EOF node if the included ranges array has changes + // later on in the file. + if (ts_subtree_is_eof(result)) end_byte_offset = UINT32_MAX; + if (byte_offset > position) { LOG("before_reusable_node symbol:%s", TREE_NAME(result)); break; @@ -1605,8 +1615,8 @@ static unsigned ts_parser__condense_stack(TSParser *self) { static bool ts_parser_has_outstanding_parse(TSParser *self) { return ( - self->lexer.current_position.bytes > 0 || - ts_stack_state(self->stack, 0) != 1 + ts_stack_state(self->stack, 0) != 1 || + ts_stack_node_count_since_error(self->stack, 0) != 0 ); } |