diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 22:50:18 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 22:50:18 +0200 |
| commit | 4dcbd44dbf63f2b365c315f481b70ecc946e9f56 (patch) | |
| tree | ab7bf9872e4b70490cbdf97e0edc5435e12aac91 /src/common | |
| parent | 70d5bcf8eca474440020c31239cd827cf3bb3415 (diff) | |
Fix hover bug
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/position.odin | 15 | ||||
| -rw-r--r-- | src/common/types.odin | 1 |
2 files changed, 4 insertions, 12 deletions
diff --git a/src/common/position.odin b/src/common/position.odin index 3a600ab..e8c5ff2 100644 --- a/src/common/position.odin +++ b/src/common/position.odin @@ -64,7 +64,6 @@ get_relative_token_position :: proc(offset: int, document_text: []u8, current_st position: Position for i + start_index < offset { - r, w := utf8.decode_rune(data[i:]) if r == '\n' { //\r? @@ -94,7 +93,6 @@ get_token_range :: proc(node: ast.Node, document_text: string) -> Range { range: Range go_backwards_to_endline :: proc(offset: int, document_text: []u8) -> int { - index := offset for index > 0 && document_text[index] != '\n' && document_text[index] != '\r' { @@ -113,19 +111,18 @@ get_token_range :: proc(node: ast.Node, document_text: string) -> Range { offset := go_backwards_to_endline(pos_offset, transmute([]u8)document_text) - range.start.line = node.pos.line - 1 + range.start.line = node.pos.line - 1 range.start.character = get_character_offset_u8_to_u16(node.pos.column - 1, transmute([]u8)document_text[offset:]) - offset = go_backwards_to_endline(end_offset, transmute([]u8)document_text) + offset = go_backwards_to_endline(end_offset - 1, transmute([]u8)document_text) - range.end.line = node.end.line - 1 + range.end.line = node.end.line - 1 range.end.character = get_character_offset_u8_to_u16(node.end.column - 1, transmute([]u8)document_text[offset:]) return range } get_absolute_range :: proc(range: Range, document_text: []u8) -> (AbsoluteRange, bool) { - absolute: AbsoluteRange if len(document_text) == 0 { @@ -160,7 +157,6 @@ get_absolute_range :: proc(range: Range, document_text: []u8) -> (AbsoluteRange, } get_index_at_line :: proc(current_index: ^int, current_line: ^int, last: ^u8, document_text: []u8, end_line: int) -> bool { - if end_line == 0 { current_index^ = 0 return true @@ -171,7 +167,6 @@ get_index_at_line :: proc(current_index: ^int, current_line: ^int, last: ^u8, do } for ; current_index^ < len(document_text); current_index^ += 1 { - current := document_text[current_index^] if last^ == '\r' { @@ -199,12 +194,10 @@ get_index_at_line :: proc(current_index: ^int, current_line: ^int, last: ^u8, do } get_character_offset_u16_to_u8 :: proc(character_offset: int, document_text: []u8) -> int { - utf8_idx := 0 utf16_idx := 0 for utf16_idx < character_offset { - r, w := utf8.decode_rune(document_text[utf8_idx:]) if r == '\n' || r == '\r' { @@ -224,12 +217,10 @@ get_character_offset_u16_to_u8 :: proc(character_offset: int, document_text: []u } get_character_offset_u8_to_u16 :: proc(character_offset: int, document_text: []u8) -> int { - utf8_idx := 0 utf16_idx := 0 for utf8_idx < character_offset { - r, w := utf8.decode_rune(document_text[utf8_idx:]) if r == '\n' || r == '\r' { diff --git a/src/common/types.odin b/src/common/types.odin index 51affaa..231a42b 100644 --- a/src/common/types.odin +++ b/src/common/types.odin @@ -30,6 +30,7 @@ Package :: struct { Document :: struct { uri: Uri, + fullpath: string, text: []u8, used_text: int, //allow for the text to be reallocated with more data than needed client_owned: bool, |