Skip to content

Commit 698bb1a

Browse files
committed
fix: freeze on error recovery (#34)
1 parent 76a70a8 commit 698bb1a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tree-sitter-org"
33
description = "org grammar for the tree-sitter parsing library"
4-
version = "1.3.0"
4+
version = "1.3.1"
55
keywords = ["incremental", "parsing", "org"]
66
categories = ["parsing", "text-editors"]
77
repository = "https://github.com/milisims/tree-sitter-org"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tree-sitter-org",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Org grammar for tree-sitter",
55
"main": "bindings/node",
66
"keywords": [

src/scanner.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ struct Scanner {
105105
return true;
106106
}
107107

108+
bool in_error_recovery(const bool *valid_symbols) {
109+
return (valid_symbols[LISTSTART] &&
110+
valid_symbols[LISTEND] &&
111+
valid_symbols[LISTITEMEND] &&
112+
valid_symbols[BULLET] &&
113+
valid_symbols[HLSTARS] &&
114+
valid_symbols[SECTIONEND] &&
115+
valid_symbols[ENDOFFILE]);
116+
}
117+
108118
Bullet getbullet(TSLexer *lexer) {
109119
if (lexer->lookahead == '-') {
110120
advance(lexer);
@@ -150,6 +160,10 @@ struct Scanner {
150160

151161
bool scan(TSLexer *lexer, const bool *valid_symbols) {
152162

163+
if (in_error_recovery(valid_symbols))
164+
return false;
165+
166+
153167
// - Section ends
154168
int16_t indent_length = 0;
155169
lexer->mark_end(lexer);

0 commit comments

Comments
 (0)