about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-19 09:03:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-19 09:06:41 -0700
commit703ed905c13a837c683aed0bf09bb68b0d7c9430 (patch)
tree646003b6fe6ec9d54581174c17062b9c2e12475c /main.lua
parentb6fa2aae6e9b0793280139ad7e5edd2468eac494 (diff)
downloadtext.love-703ed905c13a837c683aed0bf09bb68b0d7c9430.tar.gz
bugfix: crash in Text.up() after return
Let's just make all the utf8.offset calculations more defensive.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/main.lua b/main.lua
index 196ef5a..e5dde61 100644
--- a/main.lua
+++ b/main.lua
@@ -422,7 +422,7 @@ function App.keychord_pressed(chord)
       Search_backup = nil
     elseif chord == 'backspace' then
       local len = utf8.len(Search_term)
-      local byte_offset = utf8.offset(Search_term, len)
+      local byte_offset = Text.offset(Search_term, len)
       Search_term = string.sub(Search_term, 1, byte_offset-1)
       Search_text = nil
     elseif chord == 'down' then
@@ -537,7 +537,7 @@ function App.keychord_pressed(chord)
         p.name = nil
       elseif chord == 'backspace' then
         local len = utf8.len(p.name)
-        local byte_offset = utf8.offset(p.name, len-1)
+        local byte_offset = Text.offset(p.name, len-1)
         p.name = string.sub(p.name, 1, byte_offset)
       end
       record_undo_event({before=before, after=snapshot(Lines.current_drawing_index)})