summaryrefslogtreecommitdiff
path: root/server-beta/src/proto
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-10 21:12:58 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-10 21:12:58 +0800
commit28f7ece61d1040b374de6be4adc6c8c65c24805f (patch)
tree5602eb1e4c183d33c5812fa3086467bd6921ce18 /server-beta/src/proto
parent39de6077b1a1a6224d1acb52d17ab8ba7c885305 (diff)
downloadlua-language-server-28f7ece61d1040b374de6be4adc6c8c65c24805f.zip
重新整理坐标转换
Diffstat (limited to 'server-beta/src/proto')
-rw-r--r--server-beta/src/proto/define.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/server-beta/src/proto/define.lua b/server-beta/src/proto/define.lua
index ee968021..5e6bd3cf 100644
--- a/server-beta/src/proto/define.lua
+++ b/server-beta/src/proto/define.lua
@@ -8,7 +8,7 @@ local m = {}
---@param position position
---@return integer
function m.offset(lines, text, position)
- local row = position.line
+ local row = position.line + 1
local start = guide.lineRange(lines, row)
local offset = utf8.offset(text, position.character + 1, start)
return offset
@@ -23,9 +23,9 @@ end
function m.position(lines, text, offset)
local row, col = guide.positionOf(lines, offset)
local start = guide.lineRange(lines, row)
- local ucol = utf8.len(text, start + 1, start + col, true)
+ local ucol = utf8.len(text, start, start + col - 1, true)
return {
- line = row,
+ line = row - 1,
character = ucol,
}
end