summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-09 11:12:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-09 11:12:23 +0800
commit0748f983c77d6e133959891823ee1c338d3deee9 (patch)
tree06a437ffaafecbefbda3087432f13fc9d18be3f9 /script/files.lua
parent9881e7cd087deb3cdba2eae2071fcfd955d27477 (diff)
downloadlua-language-server-0748f983c77d6e133959891823ee1c338d3deee9.zip
improve didChange
Diffstat (limited to 'script/files.lua')
-rw-r--r--script/files.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/script/files.lua b/script/files.lua
index 745c5354..c322bbe8 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -193,6 +193,19 @@ function m.setText(uri, text, isTrust)
end
end
+function m.setRawText(uri, text)
+ if not text then
+ return
+ end
+ uri = getUriKey(uri)
+ local file = m.fileMap[uri]
+ file.text = text
+ file.originText = text
+ m.linesMap[uri] = nil
+ m.originLinesMap[uri] = nil
+ m.astMap[uri] = nil
+end
+
--- 获取文件版本
function m.getVersion(uri)
uri = getUriKey(uri)
@@ -539,9 +552,8 @@ function m.offset(uri, position, isFinish)
local row = position.line + 1
local start = guide.lineRange(lines, row)
local offset
- -- TODO
if start <= 0 or start > #text then
- offset = math.maxinteger
+ offset = #text + 1
else
offset = utf8.offset(text, position.character + 1, start) or #text
end