Skip to content

Commit

Permalink
fix: detect eof as end of parsing in scanner (#37)
Browse files Browse the repository at this point in the history
Fixes: #36
  • Loading branch information
gbprod authored May 15, 2023
1 parent 735f02b commit b265e20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions corpus/subject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,14 @@ feat!: allow provided config object to extend other configs
(type))
(overflow)))

================================================================================
fix #36
================================================================================
feat(test):
--------------------------------------------------------------------------------

(source
(ERROR
(prefix
(type)
(scope))))
7 changes: 6 additions & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ bool tree_sitter_gitcommit_external_scanner_scan(void *payload, TSLexer *lexer,
if (valid_symbols[CONVENTIONNAL_SUBJECT]) {
lexer->result_symbol = CONVENTIONNAL_SUBJECT;

if (lexer->lookahead == '\n' || lexer->lookahead == '\r' ||
lexer->lookahead == '\0') {
return false;
}

while (lexer->lookahead != '\n' && lexer->lookahead != '\r' &&
50 > lexer->get_column(lexer)) {
lexer->lookahead != '\0' && 50 > lexer->get_column(lexer)) {
lexer->advance(lexer, false);
}

Expand Down

0 comments on commit b265e20

Please sign in to comment.