summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua29
-rw-r--r--script/files.lua76
2 files changed, 0 insertions, 105 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index e56ed3f8..bb55506a 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -225,35 +225,6 @@ local function buildFunction(results, source, value, oop, data)
end
end
-local function buildInsertRequire(state, targetUri, stemName)
- local uri = guide.getUri(state.ast)
- local text = files.getText(uri)
- local start = 1
- for i = 1, #lines do
- local ln = lines[i]
- local lnText = text:sub(ln.start, ln.finish)
- if not lnText:find('require', 1, true) then
- start = ln.start
- break
- end
- end
- local path = furi.decode(targetUri)
- local visiblePaths = rpath.getVisiblePath(path, config.get 'Lua.runtime.path', true)
- if not visiblePaths or #visiblePaths == 0 then
- return nil
- end
- table.sort(visiblePaths, function (a, b)
- return #a.expect < #b.expect
- end)
- return {
- {
- start = start,
- finish = start - 1,
- newText = ('local %s = require %q\n'):format(stemName, visiblePaths[1].expect)
- }
- }
-end
-
local function isSameSource(state, source, pos)
if guide.getUri(source) ~= guide.getUri(state.ast) then
return false
diff --git a/script/files.lua b/script/files.lua
index d6ea057f..e7999533 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -576,78 +576,6 @@ function m.diffedOffsetBack(uri, offset)
return smerger.getOffsetBack(file._diffInfo, offset)
end
---- 将光标位置转化为 position
----@param uri uri
----@param offset integer
----@param leftOrRight? '"left"'|'"right"'
----@return position
-function m.position(uri, offset, leftOrRight)
- local file = m.getFile(uri)
- local lines = m.getLines(uri)
- local text = m.getText(uri)
- if not file then
- return {
- line = 0,
- character = 0,
- }
- end
- if file._diffInfo then
- local start, finish = smerger.getOffsetBack(file._diffInfo, offset)
- if leftOrRight == 'right' then
- offset = finish
- else
- offset = start
- end
- lines = m.getOriginLines(uri)
- text = m.getOriginText(uri)
- end
- local row, col = guide.rowColOf(offset)
- local start, finish = guide.lineRange(lines, row, true)
- start = start + 1
- if col <= finish - start + 1 then
- local ucol = util.utf8Len(text, start, start + col - 1)
- if row < 1 then
- row = 1
- end
- if leftOrRight == 'left' and ucol > 0 then
- ucol = ucol - 1
- end
- return {
- line = row - 1,
- character = ucol,
- }
- else
- return {
- line = row - 1,
- character = util.utf8Len(text, start, finish),
- }
- end
-end
-
---- 将起点与终点位置转化为 range
-
----@param uri uri
----@param offset1 integer
----@param offset2 integer
-function m.range(uri, offset1, offset2)
- local range = {
- start = m.position(uri, offset1, 'left'),
- ['end'] = m.position(uri, offset2, 'right'),
- }
- return range
-end
-
---- convert `range` to `offsetStart` and `offsetFinish`
----@param uri table
----@param range table
----@return integer start
----@return integer finish
-function m.unrange(uri, range)
- local start = m.offset(uri, range.start, true)
- local finish = m.offset(uri, range['end'], false)
- return start, finish
-end
-
--- 获取文件的自定义缓存信息(在文件内容更新后自动失效)
function m.getCache(uri)
local file = m.fileMap[uri]
@@ -778,8 +706,6 @@ end
function m.flushCache()
for uri, file in pairs(m.fileMap) do
file.cacheActiveTime = math.huge
- m.linesMap[uri] = nil
- m.originLinesMap[uri] = nil
m.astMap[uri] = nil
file.cache = {}
end
@@ -791,8 +717,6 @@ function m.flushFileCache(uri)
return
end
file.cacheActiveTime = math.huge
- m.linesMap[uri] = nil
- m.originLinesMap[uri] = nil
m.astMap[uri] = nil
file.cache = {}
end