From 2dd22e4847b7bc239f129c5ed2e7d0bdff38006e Mon Sep 17 00:00:00 2001 From: dam Date: Wed, 8 May 2024 16:20:07 +0100 Subject: Improved code readability. --- modules/TUI/module.jai | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/TUI') diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 612f93e..112c666 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -560,9 +560,12 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { case; if is_escape_code(key) continue; - buff_idx := get_byte_idx(str, idx); key_str := to_string(key,, allocator = temporary_allocator); + // Get the buffer index to insert the next character. + buff_idx, success := get_byte_index(str, idx); + if success == false then buff_idx = str.count; + // Make sure we have space to append the new character at the end (in case we're trying to do it). if buff_idx > count_limit - key_str.count then continue; -- cgit v1.2.3