about summary refs log tree commit diff stats
path: root/source_text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-03-17 21:52:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-03-17 21:52:35 -0700
commit675d1cbbdf026313d682086e1652a69540f18334 (patch)
treef607830c93515e050e5e740f4b1a132d002ce0d5 /source_text.lua
parent8c373fdb60620747c7997819538037df190335c0 (diff)
downloadlines.love-675d1cbbdf026313d682086e1652a69540f18334.tar.gz
bugfix
Thanks Mikoláš Štrajt.
Diffstat (limited to 'source_text.lua')
-rw-r--r--source_text.lua23
1 files changed, 14 insertions, 9 deletions
diff --git a/source_text.lua b/source_text.lua
index 4cf3edd..1c91f28 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -247,9 +247,10 @@ function Text.keychord_press(State, chord)
       local line_cache = State.line_cache[#State.line_cache]
       State.screen_top1 = {line=#State.lines, pos=line_cache.screen_line_starting_pos[#line_cache.screen_line_starting_pos]}
     elseif Text.lt1(State.cursor1, State.screen_top1) then
-      local top2 = Text.to2(State, State.screen_top1)
-      top2 = Text.previous_screen_line(State, top2, State.left, State.right)
-      State.screen_top1 = Text.to1(State, top2)
+      State.screen_top1 = {
+        line=State.cursor1.line,
+        pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
+      }
       Text.redraw_all(State)  -- if we're scrolling, reclaim all fragments to avoid memory leaks
     end
     Text.clear_screen_line_cache(State, State.cursor1.line)
@@ -465,9 +466,11 @@ function Text.up(State)
 --?     print('cursor pos is now '..tostring(State.cursor1.pos))
   end
   if Text.lt1(State.cursor1, State.screen_top1) then
-    local top2 = Text.to2(State, State.screen_top1)
-    top2 = Text.previous_screen_line(State, top2)
-    State.screen_top1 = Text.to1(State, top2)
+    State.screen_top1 = {
+      line=State.cursor1.line,
+      pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
+    }
+    Text.redraw_all(State)  -- if we're scrolling, reclaim all fragments to avoid memory leaks
   end
 end
 
@@ -606,9 +609,11 @@ function Text.left(State)
     end
   end
   if Text.lt1(State.cursor1, State.screen_top1) then
-    local top2 = Text.to2(State, State.screen_top1)
-    top2 = Text.previous_screen_line(State, top2)
-    State.screen_top1 = Text.to1(State, top2)
+    State.screen_top1 = {
+      line=State.cursor1.line,
+      pos=Text.pos_at_start_of_screen_line(State, State.cursor1),
+    }
+    Text.redraw_all(State)  -- if we're scrolling, reclaim all fragments to avoid memory leaks
   end
 end