aboutsummaryrefslogtreecommitdiff
path: root/modules/TUI/module.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2024-05-08 16:20:07 +0100
committerdam <dam@gudinoff>2024-05-08 16:20:07 +0100
commit2dd22e4847b7bc239f129c5ed2e7d0bdff38006e (patch)
tree4e3b49a120ca99acc0708fb0a3cefddc659829c4 /modules/TUI/module.jai
parent89157d00fc4110055d5816cd1897e4def120bcaf (diff)
downloadtask-time-tracker-2dd22e4847b7bc239f129c5ed2e7d0bdff38006e.tar.zst
task-time-tracker-2dd22e4847b7bc239f129c5ed2e7d0bdff38006e.zip
Improved code readability.
Diffstat (limited to 'modules/TUI/module.jai')
-rw-r--r--modules/TUI/module.jai5
1 files changed, 4 insertions, 1 deletions
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;