about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-07-31 08:56:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-07-31 08:56:20 -0700
commit2b52383e181e317f348b5abe734f0f484ea69121 (patch)
tree779aa2bc9c71c00418c257fb23499ae4bda378bc /text.lua
parent8879fd6f29c1c997a87afe33167d634f7294e397 (diff)
downloadtext.love-2b52383e181e317f348b5abe734f0f484ea69121.tar.gz
remove a duplicate print to screen
In addition to being more efficient, this will simplify the next bugfix.
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua11
1 files changed, 5 insertions, 6 deletions
diff --git a/text.lua b/text.lua
index a477c4f..da97a55 100644
--- a/text.lua
+++ b/text.lua
@@ -22,13 +22,11 @@ function Text.draw(State, line_index, y, startpos)
       local screen_line = Text.screen_line(line, line_cache, i)
 --?       print('text.draw:', screen_line, 'at', line_index,pos, 'after', x,y)
       local frag_len = utf8.len(screen_line)
-      -- render fragment
+      -- render any highlights
       if State.selection1.line then
         local lo, hi = Text.clip_selection(State, line_index, pos, pos+frag_len)
         Text.draw_highlight(State, line, State.left,y, pos, lo,hi)
       end
-      App.color(Text_color)
-      App.screen.print(screen_line, State.left,y)
       if line_index == State.cursor1.line then
         -- render search highlight or cursor
         if State.search_term then
@@ -37,9 +35,7 @@ function Text.draw(State, line_index, y, startpos)
             local cursor_offset = Text.offset(data, State.cursor1.pos)
             if data:sub(cursor_offset, cursor_offset+#State.search_term-1) == State.search_term then
               local hi = State.cursor1.pos+utf8.len(State.search_term)
-              local lo_px = Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
-              App.color(Text_color)
-              love.graphics.print(State.search_term, State.left+lo_px,y)
+              Text.draw_highlight(State, line, State.left,y, pos, State.cursor1.pos, hi)
             end
           end
         else
@@ -53,6 +49,9 @@ function Text.draw(State, line_index, y, startpos)
           end
         end
       end
+      -- render fragment
+      App.color(Text_color)
+      App.screen.print(screen_line, State.left,y)
       y = y + State.line_height
       if y >= App.screen.height then
         break