summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-23 22:15:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-23 22:15:47 +0800
commitc95e9c91236bccb4593a0d9d218dca78bcb06ae0 (patch)
tree08109d0b434bdc799758936fc759d89ae8dd0266 /script/files.lua
parent291a7b3a7fcaee5bc761722ca46265f3cd7f70f3 (diff)
downloadlua-language-server-c95e9c91236bccb4593a0d9d218dca78bcb06ae0.zip
update
Diffstat (limited to 'script/files.lua')
-rw-r--r--script/files.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/script/files.lua b/script/files.lua
index 19f4da89..659a1aa0 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -112,6 +112,7 @@ local function pluginOnSetText(file, text)
suc, result, diffs = xpcall(smerger.mergeDiff, log.error, text, result)
if suc then
file._diffInfo = diffs
+ file.originLines = parser.lines(text)
return result
else
if DEVELOP and result then
@@ -291,6 +292,17 @@ function m.getOriginText(uri)
return file.originText
end
+--- 获取文件原始行表
+---@param uri uri
+---@return integer[]
+function m.getOriginLines(uri)
+ local file = m.fileMap[uri]
+ if not file then
+ return nil
+ end
+ return file.originLines
+end
+
function m.getChildFiles(uri)
local results = {}
local uris = m.getAllUris()
@@ -576,6 +588,14 @@ function m.diffedOffsetBack(uri, offset)
return smerger.getOffsetBack(file._diffInfo, offset)
end
+function m.hasDiffed(uri)
+ local file = m.getFile(uri)
+ if not file then
+ return false
+ end
+ return file._diffInfo ~= nil
+end
+
--- 获取文件的自定义缓存信息(在文件内容更新后自动失效)
function m.getCache(uri)
local file = m.fileMap[uri]