summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-16 03:05:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-16 03:05:24 +0800
commit1f6d6ef0e134659ab55ed0ad5d380676a5983cd9 (patch)
tree7717ada7e17112087dfe3271594c670102fb132e
parent81fb889cbf994be47f162dbfda446f80e51c6fab (diff)
downloadlua-language-server-1f6d6ef0e134659ab55ed0ad5d380676a5983cd9.zip
矫正光标位置
-rw-r--r--server-beta/src/proto/define.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/server-beta/src/proto/define.lua b/server-beta/src/proto/define.lua
index 3771c726..a6ad7e47 100644
--- a/server-beta/src/proto/define.lua
+++ b/server-beta/src/proto/define.lua
@@ -11,6 +11,9 @@ function m.offset(lines, text, position)
local row = position.line + 1
local start = guide.lineRange(lines, row)
local offset = utf8.offset(text, position.character + 1, start)
+ if text:sub(offset-1, offset):match '[%w_][^%w_]' then
+ offset = offset - 1
+ end
return offset
end