about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua3
1 files changed, 2 insertions, 1 deletions
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)