aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-05-23 22:42:34 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-05-23 22:42:34 +0200
commit3eb6d78ea9c2b67ca2bbcd4b775c70ab0558ab29 (patch)
treed3030f2640919bca58b7bbc8abeb9eb88c90389f /src/common
parent745fb0ec579c59d154e4394afbab8828185259bf (diff)
parenta2f333bfbdd187aa7463ae230f7a617f6bccb611 (diff)
Merge remote-tracking branch 'origin/master' into rename
Diffstat (limited to 'src/common')
-rw-r--r--src/common/position.odin7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/common/position.odin b/src/common/position.odin
index b222086..739f3aa 100644
--- a/src/common/position.odin
+++ b/src/common/position.odin
@@ -4,6 +4,7 @@ import "core:strings"
import "core:unicode/utf8"
import "core:fmt"
import "core:odin/ast"
+import "core:log"
/*
This file handles the conversion between utf-16 and utf-8 offsets in the text document
@@ -129,12 +130,16 @@ go_backwards_to_endline :: proc(offset: int, document_text: []u8) -> int {
get_token_range :: proc(node: ast.Node, document_text: string) -> Range {
range: Range
-
pos_offset := min(len(document_text) - 1, node.pos.offset)
end_offset := min(len(document_text) - 1, node.end.offset)
offset := go_backwards_to_endline(pos_offset, transmute([]u8)document_text)
+ if offset < 0 {
+ offset := 0
+ log.errorf("Failed to find offset in get_token_range: %v", node)
+ }
+
range.start.line = node.pos.line - 1
range.start.character = get_character_offset_u8_to_u16(
node.pos.column - 1,