about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-08-10 22:38:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-10 22:38:10 -0700
commitba48aadaa71ac01db2a9d9bd06a26dec30fd31b3 (patch)
treea27028754c2590e43414266c12d1f5dd391ebc25 /text.lua
parent8cfffdef41a56db0e2db7b329c5d0c31b2564e3c (diff)
downloadview.love-ba48aadaa71ac01db2a9d9bd06a26dec30fd31b3.tar.gz
bugfix: backspace from start of final line
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/text.lua b/text.lua
index 555d2c4..4e6c072 100644
--- a/text.lua
+++ b/text.lua
@@ -206,7 +206,11 @@ function Text.keychord_pressed(State, chord)
       end
       State.cursor1.line = State.cursor1.line-1
     end
-    if Text.lt1(State.cursor1, State.screen_top1) then
+    if State.screen_top1.line > #State.lines then
+      Text.populate_screen_line_starting_pos(State, #State.lines)
+      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)