about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-20 06:55:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-20 06:56:19 -0700
commitb5451e4351c9046b467b9efb669f0bd1929e3204 (patch)
tree029473802d79fb7c8895e740841fa5046c43e048 /text.lua
parentd41301c1b79124e3dc7ef5551d8bd7b5dd553b17 (diff)
downloadtext.love-b5451e4351c9046b467b9efb669f0bd1929e3204.tar.gz
move a var closer to its use
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/text.lua b/text.lua
index a1d9ce6..4c4ab4a 100644
--- a/text.lua
+++ b/text.lua
@@ -26,8 +26,6 @@ function Text.draw(State, line_index, y, startpos)
 --?   print('--')
   for _, f in ipairs(line_cache.fragments) do
     local frag, frag_text = f.data, f.text
-    -- render fragment
-    local frag_width = App.width(frag_text)
     local frag_len = utf8.len(frag)
 --?     local s=tostring
 --?     print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(right)..') '..s(line_index)..' vs '..s(State.screen_top1.line)..'; '..s(pos)..' vs '..s(State.screen_top1.pos)..'; bottom: '..s(State.screen_bottom1.line)..'/'..s(State.screen_bottom1.pos))
@@ -35,6 +33,8 @@ function Text.draw(State, line_index, y, startpos)
       -- render nothing
 --?       print('skipping', frag)
     else
+      -- render fragment
+      local frag_width = App.width(frag_text)
       if x + frag_width > State.right then
         assert(x > State.left)  -- no overfull lines
         y = y + State.line_height