about summary refs log tree commit diff stats
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
parente223df41bcfa54e5eb2c8ae3942e302bf1ec73a4 (diff)
downloadtext.love-ec5706e1ea387ab70a90e53fca17e03b6d8defdb.tar.gz
stop recomputing Cursor_x now that we're saving it
-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
h=v1.9.3&id=e21fb9b5b6eac911f9061425826b05de97211549'>^
f027adc0 ^
08f08fb9 ^
654af129 ^
08f08fb9 ^
d8084b41 ^

99400080 ^
08f08fb9 ^

654af129 ^

d1a1173d ^
d8084b41 ^
cba63cf3 ^
b4250dbc ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39