summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
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]