about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-05 08:00:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-05 08:11:33 -0700
commit3f07ac51d269581c0107e7b89181f01a6fd9db0e (patch)
treed28e8a0121a3d606516213454d09d02e232e4f9a
parent8c0f54ee647bd454470d0f0149210e0124b7ffb2 (diff)
downloadview.love-3f07ac51d269581c0107e7b89181f01a6fd9db0e.tar.gz
some unnecessary mutations
Why are we not modifying Screen_top1.pos in these places? Because we
don't really need to modify Screen_top1 at all.
-rw-r--r--main.lua4
-rw-r--r--text.lua4
2 files changed, 0 insertions, 8 deletions
diff --git a/main.lua b/main.lua
index 1235641..b541bd4 100644
--- a/main.lua
+++ b/main.lua
@@ -344,8 +344,6 @@ function App.keychord_pressed(chord)
       Text.populate_screen_line_starting_pos(i)
     end
     if Cursor1.line-Screen_top1.line+1 + num_newlines > App.screen.height/Line_height then
-      Screen_top1.line = Cursor1.line
-      Screen_top1.pos = 1
       Text.scroll_up_while_cursor_on_screen()
     end
     -- hack 2: if we have too much text wrapping we definitely need to scroll
@@ -353,8 +351,6 @@ function App.keychord_pressed(chord)
     local clipboard_width = App.width(clipboard_text)
 --?     print(Cursor_y, Cursor_y*Line_width, Cursor_y*Line_width+Cursor_x, Cursor_y*Line_width+Cursor_x+clipboard_width, Line_width*App.screen.height/Line_height)
     if Cursor_y*Line_width+Cursor_x + clipboard_width > Line_width*App.screen.height/Line_height then
-      Screen_top1.line = Cursor1.line
-      Screen_top1.pos = 1
       Text.scroll_up_while_cursor_on_screen()
     end
     record_undo_event({before=before, after=snapshot(before_line, Cursor1.line)})
diff --git a/text.lua b/text.lua
index e4bb325..0053c9d 100644
--- a/text.lua
+++ b/text.lua
@@ -364,7 +364,6 @@ function Text.insert_return()
   Cursor1.line = Cursor1.line+1
   Cursor1.pos = 1
   if scroll_down then
-    Screen_top1.line = Cursor1.line
     Text.scroll_up_while_cursor_on_screen()
   end
 end
@@ -484,7 +483,6 @@ function Text.down()
     end
     if Cursor1.line > Screen_bottom1.line then
 --?       print('screen top before:', Screen_top1.line, Screen_top1.pos)
-      Screen_top1.line = Cursor1.line
 --?       print('scroll up preserving cursor')
       Text.scroll_up_while_cursor_on_screen()
 --?       print('screen top after:', Screen_top1.line, Screen_top1.pos)
@@ -503,7 +501,6 @@ function Text.down()
     Cursor1.pos = new_screen_line_starting_pos + Text.nearest_cursor_pos(s, Cursor_x) - 1
 --?     print('cursor pos is now', Cursor1.line, Cursor1.pos)
     if scroll_down then
-      Screen_top1.line = Cursor1.line
 --?       print('scroll up preserving cursor')
       Text.scroll_up_while_cursor_on_screen()
 --?       print('screen top after:', Screen_top1.line, Screen_top1.pos)
@@ -616,7 +613,6 @@ function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necess
 --?   print(y, App.screen.height, App.screen.height-Line_height)
   if y > App.screen.height - Line_height then
 --?     print('scroll up')
-    Screen_top1.line = Cursor1.line
     Text.scroll_up_while_cursor_on_screen()
   end
 end