diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index b5f86270..4ba92db4 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -26,10 +26,15 @@ typedef enum { TSSymbolTypeAuxiliary, } TSSymbolType; +typedef struct { + uint32_t row; + uint32_t column; +} TSPoint; + typedef struct { void *payload; const char *(*read)(void *payload, uint32_t *bytes_read); - int (*seek)(void *payload, uint32_t byte_index); + int (*seek)(void *payload, uint32_t byte_index, TSPoint position); TSInputEncoding encoding; } TSInput; @@ -43,11 +48,6 @@ typedef struct { void (*log)(void *payload, TSLogType, const char *); } TSLogger; -typedef struct { - uint32_t row; - uint32_t column; -} TSPoint; - typedef struct { uint32_t start_byte; uint32_t bytes_removed; diff --git a/src/runtime/lexer.c b/src/runtime/lexer.c index 65da088e..157276a1 100644 --- a/src/runtime/lexer.c +++ b/src/runtime/lexer.c @@ -20,7 +20,7 @@ static void ts_lexer__get_chunk(Lexer *self) { TSInput input = self->input; if (!self->chunk || self->current_position.bytes != self->chunk_start + self->chunk_size) { - input.seek(input.payload, self->current_position.bytes); + input.seek(input.payload, self->current_position.bytes, self->current_position.extent); } self->chunk_start = self->current_position.bytes; diff --git a/src/runtime/string_input.c b/src/runtime/string_input.c index 2f2d49e2..53f69ee5 100644 --- a/src/runtime/string_input.c +++ b/src/runtime/string_input.c @@ -20,7 +20,7 @@ static const char *ts_string_input__read(void *payload, uint32_t *bytes_read) { return input->string + previous_position; } -static int ts_string_input__seek(void *payload, uint32_t byte) { +static int ts_string_input__seek(void *payload, uint32_t byte, TSPoint _) { TSStringInput *input = (TSStringInput *)payload; input->position = byte; return (byte < input->length); diff --git a/test/helpers/spy_input.cc b/test/helpers/spy_input.cc index 4ccde383..889dcdf0 100644 --- a/test/helpers/spy_input.cc +++ b/test/helpers/spy_input.cc @@ -70,7 +70,7 @@ const char * SpyInput::read(void *payload, uint32_t *bytes_read) { return spy->buffer; } -int SpyInput::seek(void *payload, uint32_t byte) { +int SpyInput::seek(void *payload, uint32_t byte, TSPoint position) { auto spy = static_cast(payload); spy->byte_offset = byte; return 0; diff --git a/test/helpers/spy_input.h b/test/helpers/spy_input.h index fb77b5ae..e066ab1c 100644 --- a/test/helpers/spy_input.h +++ b/test/helpers/spy_input.h @@ -17,7 +17,7 @@ class SpyInput { std::vector undo_stack; static const char * read(void *, uint32_t *); - static int seek(void *, uint32_t); + static int seek(void *, uint32_t, TSPoint); std::pair swap_substr(size_t, size_t, std::string); public: