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-18 09:51:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-18 09:51:43 -0700
commita14f1096b6b11940bd677000eb41bc8ba6e9b559 (patch)
tree1674e795d0190354cd186b93fc5554b9aac0c4e0 /text.lua
parentf79dd4824c72ab93e90bdbf1d3fa130f7fb3c97d (diff)
downloadtext.love-a14f1096b6b11940bd677000eb41bc8ba6e9b559.tar.gz
extract a variable
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/text.lua b/text.lua
index 4a585b7..ff98140 100644
--- a/text.lua
+++ b/text.lua
@@ -870,9 +870,10 @@ function Text.to2(State, loc1)
     return {line=loc1.line, screen_line=1, screen_pos=1}
   end
   local result = {line=loc1.line, screen_line=1}
+  local line_cache = State.line_cache[loc1.line]
   Text.populate_screen_line_starting_pos(State, loc1.line)
-  for i=#State.line_cache[loc1.line].screen_line_starting_pos,1,-1 do
-    local spos = State.line_cache[loc1.line].screen_line_starting_pos[i]
+  for i=#line_cache.screen_line_starting_pos,1,-1 do
+    local spos = line_cache.screen_line_starting_pos[i]
     if spos <= loc1.pos then
       result.screen_line = i
       result.screen_pos = loc1.pos - spos + 1