diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-12-26 11:30:56 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-12-26 11:30:56 -0800 |
commit | 320f68ba43c4f7b44072110827eabb648462a78e (patch) | |
tree | b801558dd58b5c0e75b156aecc6d927b99e4e2d5 | |
parent | 25f16f2a88f1e144989574cfbee877fd93a3c2af (diff) | |
parent | 2b1c48c08e55247cac35c9cb4cdbd1ae10b91fd9 (diff) | |
download | view.love-320f68ba43c4f7b44072110827eabb648462a78e.tar.gz |
Merge text.love
-rw-r--r-- | source_text.lua | 3 | ||||
-rw-r--r-- | 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 6dfd81b..bee99cf 100644 --- a/text.lua +++ b/text.lua @@ -653,7 +653,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) |