From e36559d264616cc8bc10ebbfcc429663c17fb7aa Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 26 Dec 2023 11:19:23 -0800 Subject: bugfix: utf-8 --- source_text.lua | 3 ++- text.lua | 3 ++- 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 5222e22..6696fe5 100644 --- a/text.lua +++ b/text.lua @@ -845,7 +845,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) -- cgit 1.4.1-2-gfad0