From dcdaf078ce3b15d2229b0528bec8a9cd6a4ee4f1 Mon Sep 17 00:00:00 2001 From: Grant Horner Date: Tue, 12 May 2026 10:29:12 -0400 Subject: [PATCH] remove cursor_index --- edit.jai | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/edit.jai b/edit.jai index a3541b2..8f0bf73 100644 --- a/edit.jai +++ b/edit.jai @@ -292,14 +292,14 @@ handle_arrow :: (using state: *State, using event: Input.Event) { } get_visible_lines :: (using state: State) -> [][..]u8 { - #import "Print_vars"; + #import "Print_Vars"; if line_height <= 1 || window_height == 0 return .[]; num_lines_in_screen := window_height / line_height - 1; result := array_view(lines, first_line, num_lines_in_screen); return result; } -string_to_line :: (str: string, cursor_char_index := -1) -> string, string { +string_to_line :: (str: string, cursor_x := -1) -> string, string { prefix_builder: String_Builder; prefix_builder.allocator = temporary_allocator; @@ -311,7 +311,6 @@ string_to_line :: (str: string, cursor_char_index := -1) -> string, string { start := 0; char_index := 0; - cursor_index := 0; current_builder := *prefix_builder; @@ -327,15 +326,12 @@ string_to_line :: (str: string, cursor_char_index := -1) -> string, string { // start = char_index + 1; // cursor_index += 4; - } else { - cursor_index += 1; } - - if cursor_index == cursor_char_index { - s := string.{data=str.data + start, count=(char_index + 1) - start}; + if char_index == cursor_x { + s := string.{data=str.data + start, count=char_index - start}; append(current_builder, s); current_builder = *suffix_builder; - start = char_index + 1; + start = char_index; } }