about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-20 20:32:55 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-20 20:32:55 -0700
commitec5706e1ea387ab70a90e53fca17e03b6d8defdb (patch)
treeedb4a396217ecfa0f22ee31f57a0c35662ab54a8 /text.lua
parente223df41bcfa54e5eb2c8ae3942e302bf1ec73a4 (diff)
downloadtext.love-ec5706e1ea387ab70a90e53fca17e03b6d8defdb.tar.gz
stop recomputing Cursor_x now that we're saving it
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/text.lua b/text.lua
index c7a7d74..95cec4f 100644
--- a/text.lua
+++ b/text.lua
@@ -236,10 +236,9 @@ function Text.keychord_pressed(chord)
       while new_cursor_line > 1 do
         new_cursor_line = new_cursor_line-1
         if Lines[new_cursor_line].mode == 'text' then
-          local old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)
           Cursor_line = new_cursor_line
           if Lines[Cursor_line].screen_line_starting_pos == nil then
-            Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)
+            Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
             break
           end
           -- previous text line found, pick its final screen line
@@ -251,7 +250,7 @@ function Text.keychord_pressed(chord)
             print('pos of top of screen is also '..tostring(Top_screen_line_starting_pos)..' of the same line')
           end
           local s = string.sub(Lines[Cursor_line].data, screen_line_starting_pos)
-          Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, old_x) - 1
+          Cursor_pos = screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
           break
         end
       end
@@ -279,9 +278,8 @@ function Text.keychord_pressed(chord)
     while new_cursor_line < #Lines do
       new_cursor_line = new_cursor_line+1
       if Lines[new_cursor_line].mode == 'text' then
-        local old_x = Text.cursor_x(Lines[new_cursor_line].data, Cursor_pos)
         Cursor_line = new_cursor_line
-        Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, old_x)
+        Cursor_pos = Text.nearest_cursor_pos(Lines[Cursor_line].data, Cursor_x)
         break
       end
     end