about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-23 11:03:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-23 11:03:46 -0700
commit5a06c1286dabc2dc0fa82f41b9e79689e9a10105 (patch)
treea4d38bf0f27cdc5ab309b94fb3d7fd73c9197436
parent515dad95f92a9713463d5e0f485e448e6022f04f (diff)
downloadtext.love-5a06c1286dabc2dc0fa82f41b9e79689e9a10105.tar.gz
bugfix: recompute screen lines in backspace/delete
Scenario: backspacing until a line takes up fewer screen lines, then
pressing `down`.

I've gone through and checked that fragments and screen_line_starting_pos
are now cleared together everywhere.
-rw-r--r--text.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/text.lua b/text.lua
index b5e8392..0ed46f8 100644
--- a/text.lua
+++ b/text.lua
@@ -203,6 +203,7 @@ function Text.keychord_pressed(chord)
           Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)
         end
         Lines[Cursor1.line].fragments = nil
+        Lines[Cursor1.line].screen_line_starting_pos = nil
         Cursor1.pos = Cursor1.pos-1
       end
     elseif Cursor1.line > 1 then
@@ -214,6 +215,7 @@ function Text.keychord_pressed(chord)
         Cursor1.pos = utf8.len(Lines[Cursor1.line-1].data)+1
         Lines[Cursor1.line-1].data = Lines[Cursor1.line-1].data..Lines[Cursor1.line].data
         Lines[Cursor1.line-1].fragments = nil
+        Lines[Cursor1.line-1].screen_line_starting_pos = nil
         table.remove(Lines, Cursor1.line)
       end
       Cursor1.line = Cursor1.line-1
@@ -249,6 +251,7 @@ function Text.keychord_pressed(chord)
           Lines[Cursor1.line].data = string.sub(Lines[Cursor1.line].data, 1, byte_start-1)
         end
         Lines[Cursor1.line].fragments = nil
+        Lines[Cursor1.line].screen_line_starting_pos = nil
         -- no change to Cursor1.pos
       end
     elseif Cursor1.line < #Lines then
@@ -258,6 +261,7 @@ function Text.keychord_pressed(chord)
         -- join lines
         Lines[Cursor1.line].data = Lines[Cursor1.line].data..Lines[Cursor1.line+1].data
         Lines[Cursor1.line].fragments = nil
+        Lines[Cursor1.line].screen_line_starting_pos = nil
         table.remove(Lines, Cursor1.line+1)
       end
     end