diff --git a/spec/runtime/helpers/spy_reader.cc b/spec/runtime/helpers/spy_reader.cc index bc71df74..8af2cfd6 100644 --- a/spec/runtime/helpers/spy_reader.cc +++ b/spec/runtime/helpers/spy_reader.cc @@ -64,8 +64,7 @@ const char * SpyReader::read(size_t *bytes_read) { } int SpyReader::seek(size_t pos) { - if (position != pos) - strings_read.push_back(""); + strings_read.push_back(""); position = pos; return 0; } diff --git a/src/runtime/lexer.c b/src/runtime/lexer.c index ff6277ef..3d3cbb26 100644 --- a/src/runtime/lexer.c +++ b/src/runtime/lexer.c @@ -9,7 +9,8 @@ static const char *empty_chunk = ""; static void ts_lexer_read_next_chunk(TSLexer *lexer) { TSInput input = lexer->input; - input.seek_fn(input.data, lexer->current_position); + if (lexer->current_position.bytes != lexer->chunk_start + lexer->chunk_size) + input.seek_fn(input.data, lexer->current_position); lexer->chunk_start = lexer->current_position.bytes; lexer->chunk = input.read_fn(input.data, &lexer->chunk_size); if (!lexer->chunk_size)