about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-12-26 11:29:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2023-12-26 11:29:52 -0800
commit2b1c48c08e55247cac35c9cb4cdbd1ae10b91fd9 (patch)
treeaf7c0e0e439c89932db2e230798a190f88cb8130
parent35bc6106aa64e9efefbdf49cc93e4e8e269d4bee (diff)
parente36559d264616cc8bc10ebbfcc429663c17fb7aa (diff)
downloadview.love-2b1c48c08e55247cac35c9cb4cdbd1ae10b91fd9.tar.gz
Merge lines.love
-rw-r--r--source_text.lua3
-rw-r--r--text.lua3
2 files changed, 4 insertions, 2 deletions
diff --git a/source_text.lua b/source_text.lua
index a1c7e6c..a4175c3 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -907,7 +907,8 @@ function Text.nearest_pos_less_than(line, x)
 end
 
 function Text.x_after(s, pos)
-  local offset = Text.offset(s, math.min(pos+1, #s+1))
+  local len = utf8.len(s)
+  local offset = Text.offset(s, math.min(pos+1, len+1))
   local s_before = s:sub(1, offset-1)
 --?   print('^'..s_before..'$')
   return App.width(s_before)
diff --git a/text.lua b/text.lua
index f1f6e48..f07cf48 100644
--- a/text.lua
+++ b/text.lua
@@ -771,7 +771,8 @@ function Text.nearest_pos_less_than(line, x)
 end
 
 function Text.x_after(s, pos)
-  local offset = Text.offset(s, math.min(pos+1, #s+1))
+  local len = utf8.len(s)
+  local offset = Text.offset(s, math.min(pos+1, len+1))
   local s_before = s:sub(1, offset-1)
 --?   print('^'..s_before..'$')
   return App.width(s_before)