From 3913f3beba3196119c2ae9c483a97637eee2fe5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 13 Sep 2020 19:26:28 +0800 Subject: =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/proto/define.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'script-beta/proto/define.lua') diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua index 317eda6c..0dd781c1 100644 --- a/script-beta/proto/define.lua +++ b/script-beta/proto/define.lua @@ -23,7 +23,8 @@ end function m.offsetOfWord(lines, text, position) local row = position.line + 1 local start = guide.lineRange(lines, row) - local offset = utf8.offset(text, position.character + 1, start) if offset > #text + local offset = utf8.offset(text, position.character + 1, start) + if offset > #text or text:sub(offset-1, offset):match '[%w_][^%w_]' then offset = offset - 1 end @@ -42,7 +43,7 @@ function m.position(lines, text, offset) if start < 1 then start = 1 end - local ucol = util.utf8Len(text, start, start + col - 1, true) + local ucol = util.utf8Len(text, start, start + col - 1) if row < 1 then row = 1 end -- cgit v1.2.3