about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-25 14:56:21 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-25 14:56:21 -0700
commit34950353b958979cf47611c77e271a0db3dc8c8f (patch)
tree4c2d74793871b95361ae0b953636c326b58e1a5c
parentfd213e6f49d44f3aa04edeea55d1da4b490b84d2 (diff)
downloadlines.love-34950353b958979cf47611c77e271a0db3dc8c8f.tar.gz
bugfix: don't append metadata when it already exists
-rw-r--r--text.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/text.lua b/text.lua
index b293e11..626e898 100644
--- a/text.lua
+++ b/text.lua
@@ -974,7 +974,7 @@ function Text.cursor_at_final_screen_line()
   if Lines[Cursor1.line].screen_line_starting_pos == nil then
     return true
   end
-  screen_lines = Lines[Cursor1.line].screen_line_starting_pos
+  local screen_lines = Lines[Cursor1.line].screen_line_starting_pos
 --?   print(screen_lines[#screen_lines], Cursor1.pos)
   return screen_lines[#screen_lines] <= Cursor1.pos
 end
@@ -1217,8 +1217,11 @@ end
 
 function Text.populate_screen_line_starting_pos(line_index)
 --?   print('Text.populate_screen_line_starting_pos')
-  -- duplicate some logic from Text.draw
   local line = Lines[line_index]
+  if line.screen_line_starting_pos then
+    return
+  end
+  -- duplicate some logic from Text.draw
   if line.fragments == nil then
     Text.compute_fragments(line, Line_width)
   end
@@ -1234,6 +1237,7 @@ function Text.populate_screen_line_starting_pos(line_index)
       if line.screen_line_starting_pos == nil then
         line.screen_line_starting_pos = {1, pos}
       else
+--?         print(' ', #line.screen_line_starting_pos, line.data)
         table.insert(line.screen_line_starting_pos, pos)
       end
     end