diff --git a/corpus/subject.txt b/corpus/subject.txt index 1e0a7f5..747c2ae 100644 --- a/corpus/subject.txt +++ b/corpus/subject.txt @@ -136,3 +136,14 @@ feat!: allow provided config object to extend other configs (type)) (overflow))) +================================================================================ +fix #36 +================================================================================ +feat(test): +-------------------------------------------------------------------------------- + +(source + (ERROR + (prefix + (type) + (scope)))) diff --git a/src/scanner.c b/src/scanner.c index 92d391f..a122193 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -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); }