summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-18 16:37:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-18 16:37:56 +0800
commit9d955bee3c8471ecb2babc63be4794118890af14 (patch)
tree2e8f72701fe3a4655414b24f75a6c1fffe6ab4f4 /script
parent69c0e4c50101ee29ac1459897495d4c1219bb8c8 (diff)
downloadlua-language-server-9d955bee3c8471ecb2babc63be4794118890af14.zip
no longer ignore file names case in Windows
Diffstat (limited to 'script')
-rw-r--r--script/client.lua1
-rw-r--r--script/core/code-action.lua1
-rw-r--r--script/core/command/jsonToLua.lua2
-rw-r--r--script/core/completion.lua21
-rw-r--r--script/core/definition.lua4
-rw-r--r--script/core/diagnostics/init.lua2
-rw-r--r--script/core/highlight.lua2
-rw-r--r--script/core/hover/description.lua3
-rw-r--r--script/core/noder.lua3
-rw-r--r--script/core/reference.lua6
-rw-r--r--script/core/rename.lua2
-rw-r--r--script/core/type-definition.lua4
-rw-r--r--script/core/workspace-symbol.lua2
-rw-r--r--script/files.lua122
-rw-r--r--script/fs-utility.lua10
-rw-r--r--script/library.lua7
-rw-r--r--script/provider/diagnostic.lua18
-rw-r--r--script/provider/provider.lua6
-rw-r--r--script/vm/getLinks.lua2
-rw-r--r--script/workspace/require-path.lua2
-rw-r--r--script/workspace/workspace.lua26
21 files changed, 64 insertions, 182 deletions
diff --git a/script/client.lua b/script/client.lua
index cd956f19..4e4196b4 100644
--- a/script/client.lua
+++ b/script/client.lua
@@ -217,7 +217,6 @@ end
function m.editText(uri, edits)
local files = require 'files'
local textEdits = {}
- uri = files.getOriginUri(uri)
for i, edit in ipairs(edits) do
textEdits[i] = define.textEdit(files.range(uri, edit.start, edit.finish), edit.text)
end
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index c7727487..e5690fe4 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -397,7 +397,6 @@ local function checkSwapParams(results, uri, start, finish)
return a.source.start > b.source.start
end)
local target = args[1]
- uri = files.getOriginUri(uri)
local myArg = target.source[target.index]
for i, targetArg in ipairs(target.source) do
if i ~= target.index then
diff --git a/script/core/command/jsonToLua.lua b/script/core/command/jsonToLua.lua
index 6b5613b9..c4f001ff 100644
--- a/script/core/command/jsonToLua.lua
+++ b/script/core/command/jsonToLua.lua
@@ -24,7 +24,7 @@ return function (data)
label = 'json to lua',
edit = {
changes = {
- [files.getOriginUri(data.uri)] = {
+ [data.uri] = {
{
range = files.range(data.uri, data.start, data.finish),
newText = luaStr,
diff --git a/script/core/completion.lua b/script/core/completion.lua
index f6556233..ba480451 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -255,7 +255,7 @@ local function buildInsertRequire(ast, targetUri, stemName)
end
local function isSameSource(ast, source, pos)
- if not files.eq(guide.getUri(source), guide.getUri(ast.ast)) then
+ if guide.getUri(source) ~= guide.getUri(ast.ast) then
return false
end
if source.type == 'field'
@@ -337,11 +337,10 @@ local function checkModule(ast, word, offset, results)
end
local locals = guide.getVisibleLocals(ast.ast, offset)
for uri in files.eachFile() do
- if files.eq(uri, guide.getUri(ast.ast)) then
+ if uri == guide.getUri(ast.ast) then
goto CONTINUE
end
- local originUri = files.getOriginUri(uri)
- local path = furi.decode(originUri)
+ local path = furi.decode(uri)
local fileName = path:match '[^/\\]*$'
local stemName = fileName:gsub('%..+', '')
if not locals[stemName]
@@ -380,7 +379,7 @@ local function checkModule(ast, word, offset, results)
arguments = {
{
uri = guide.getUri(ast.ast),
- target = originUri,
+ target = uri,
name = stemName,
},
},
@@ -389,8 +388,8 @@ local function checkModule(ast, word, offset, results)
return {
detail = buildDetail(targetSource),
description = lang.script('COMPLETION_IMPORT_FROM', ('[%s](%s)'):format(
- workspace.getRelativePath(originUri),
- originUri
+ workspace.getRelativePath(uri),
+ uri
))
.. '\n' .. buildDesc(targetSource),
--additionalTextEdits = buildInsertRequire(ast, originUri, stemName),
@@ -637,7 +636,7 @@ local function checkCommon(myUri, word, text, offset, results)
if #results >= 100 then
break
end
- if myUri and files.eq(myUri, uri) then
+ if myUri == uri then
goto CONTINUE
end
local words = files.getWordsOfHead(uri, myHead)
@@ -886,8 +885,7 @@ local function checkUri(ast, text, offset, results)
end
if libName == 'require' then
for uri in files.eachFile() do
- uri = files.getOriginUri(uri)
- if files.eq(myUri, uri) then
+ if myUri == uri then
goto CONTINUE
end
local path = workspace.getRelativePath(uri)
@@ -940,8 +938,7 @@ local function checkUri(ast, text, offset, results)
elseif libName == 'dofile'
or libName == 'loadfile' then
for uri in files.eachFile() do
- uri = files.getOriginUri(uri)
- if files.eq(myUri, uri) then
+ if myUri == uri then
goto CONTINUE
end
if vm.isMetaFile(uri) then
diff --git a/script/core/definition.lua b/script/core/definition.lua
index fb74b73a..1693406c 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -119,7 +119,7 @@ return function (uri, offset)
if uris then
for i, uri in ipairs(uris) do
results[#results+1] = {
- uri = files.getOriginUri(uri),
+ uri = uri,
source = source,
target = {
start = 0,
@@ -170,7 +170,7 @@ return function (uri, offset)
results[#results+1] = {
target = src,
- uri = files.getOriginUri(root.uri),
+ uri = root.uri,
source = source,
}
::CONTINUE::
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index b44d6a2c..09688f6e 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -57,7 +57,7 @@ local function check(uri, name, results)
end, name)
local passed = os.clock() - clock
if passed >= 0.5 then
- log.warn(('Diagnostics [%s] @ [%s] takes [%.3f] sec!'):format(name, files.getOriginUri(uri), passed))
+ log.warn(('Diagnostics [%s] @ [%s] takes [%.3f] sec!'):format(name, uri, passed))
end
if DIAGTIMES then
DIAGTIMES[name] = (DIAGTIMES[name] or 0) + passed
diff --git a/script/core/highlight.lua b/script/core/highlight.lua
index 8955be69..47b482d5 100644
--- a/script/core/highlight.lua
+++ b/script/core/highlight.lua
@@ -267,7 +267,7 @@ return function (uri, offset)
if isLiteral ~= isLiteralValue(target) then
return
end
- if not files.eq(uri, guide.getUri(target)) then
+ if uri ~= guide.getUri(target) then
return
end
local kind
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 5bb86603..b58a08b7 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -31,9 +31,8 @@ local function asStringInRequire(source, literal)
local shows = {}
for i, uri in ipairs(result) do
local searcher = searchers and searchers[uri]
- uri = files.getOriginUri(uri)
local path = furi.decode(uri)
- if files.eq(path:sub(1, #rootPath), rootPath) then
+ if path:sub(1, #rootPath) == rootPath then
path = path:sub(#rootPath + 1)
end
path = path:gsub('^[/\\]*', '')
diff --git a/script/core/noder.lua b/script/core/noder.lua
index a63a1c25..70c24c85 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -1518,7 +1518,7 @@ function m.compileAllNodes(source)
guide.eachSource(root, function (src)
m.compileNode(noders, src)
end)
- log.debug('compileNodes finish:', files.getOriginUri(guide.getUri(root)))
+ log.debug('compileNodes finish:', guide.getUri(root))
return noders
end
@@ -1658,7 +1658,6 @@ function m.compileGlobalNodes(root)
end
files.watch(function (ev, uri)
- uri = files.asKey(uri)
if ev == 'update' then
local state = files.getState(uri)
if state then
diff --git a/script/core/reference.lua b/script/core/reference.lua
index 8f113a8d..5f5831c6 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -111,13 +111,9 @@ return function (uri, offset)
elseif src.type == 'table' and src.parent.type ~= 'return' then
goto CONTINUE
end
- local ouri = files.getOriginUri(root.uri)
- if not ouri then
- goto CONTINUE
- end
results[#results+1] = {
target = src,
- uri = ouri,
+ uri = root.uri,
}
::CONTINUE::
end
diff --git a/script/core/rename.lua b/script/core/rename.lua
index d0a0e25f..0ab7a055 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -348,7 +348,7 @@ function m.rename(uri, pos, newname)
local mark = {}
rename(source, newname, function (target, start, finish, text)
- local turi = files.getOriginUri(guide.getUri(target))
+ local turi = guide.getUri(target)
if not turi then
return
end
diff --git a/script/core/type-definition.lua b/script/core/type-definition.lua
index 6d45b601..dee07c61 100644
--- a/script/core/type-definition.lua
+++ b/script/core/type-definition.lua
@@ -120,7 +120,7 @@ return function (uri, offset)
if uris then
for i, uri in ipairs(uris) do
results[#results+1] = {
- uri = files.getOriginUri(uri),
+ uri = uri,
source = source,
target = {
start = 0,
@@ -160,7 +160,7 @@ return function (uri, offset)
or src.type == 'doc.type.ltable' then
results[#results+1] = {
target = src,
- uri = files.getOriginUri(root.uri),
+ uri = root.uri,
source = source,
}
end
diff --git a/script/core/workspace-symbol.lua b/script/core/workspace-symbol.lua
index 18ab1eeb..265a8d92 100644
--- a/script/core/workspace-symbol.lua
+++ b/script/core/workspace-symbol.lua
@@ -61,7 +61,7 @@ return function (key)
local results = {}
for uri in files.eachFile() do
- searchFile(files.getOriginUri(uri), key, results)
+ searchFile(uri, key, results)
if #results > 1000 then
break
end
diff --git a/script/files.lua b/script/files.lua
index e67ab653..93331bb5 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -39,55 +39,34 @@ m.linesMap = setmetatable({}, { __mode = 'v' })
m.originLinesMap = setmetatable({}, { __mode = 'v' })
m.astMap = {} -- setmetatable({}, { __mode = 'v' })
-local uriMap = {}
-local function getUriKey(uri)
- if not uri then
- return nil
- end
- if not uriMap[uri] then
- if platform.OS == 'Windows' then
- uriMap[uri] = uri:lower()
- else
- uriMap[uri] = uri
- end
- end
- return uriMap[uri]
-end
-
--- 打开文件
---@param uri uri
function m.open(uri)
- local originUri = uri
- uri = getUriKey(uri)
m.openMap[uri] = {
cache = {},
}
- m.onWatch('open', originUri)
+ m.onWatch('open', uri)
end
--- 关闭文件
---@param uri uri
function m.close(uri)
- local originUri = uri
- uri = getUriKey(uri)
m.openMap[uri] = nil
local file = m.fileMap[uri]
if file then
file.trusted = false
end
- m.onWatch('close', originUri)
+ m.onWatch('close', uri)
end
--- 是否打开
---@param uri uri
---@return boolean
function m.isOpen(uri)
- uri = getUriKey(uri)
return m.openMap[uri] ~= nil
end
function m.getOpenedCache(uri)
- uri = getUriKey(uri)
local data = m.openMap[uri]
if not data then
return nil
@@ -97,19 +76,16 @@ end
--- 标记为库文件
function m.setLibraryPath(uri, libraryPath)
- uri = getUriKey(uri)
m.libraryMap[uri] = libraryPath
end
--- 是否是库文件
function m.isLibrary(uri)
- uri = getUriKey(uri)
return m.libraryMap[uri] ~= nil
end
--- 获取库文件的根目录
function m.getLibraryPath(uri)
- uri = getUriKey(uri)
return m.libraryMap[uri]
end
@@ -120,15 +96,9 @@ end
--- 是否存在
---@return boolean
function m.exists(uri)
- uri = getUriKey(uri)
return m.fileMap[uri] ~= nil
end
-function m.asKey(uri)
- uri = getUriKey(uri)
- return uri
-end
-
local function pluginOnSetText(file, text)
file._diffInfo = nil
local suc, result = plugin.dispatch('OnSetText', file.uri, text)
@@ -163,12 +133,10 @@ function m.setText(uri, text, isTrust, instance)
return
end
--log.debug('setText', uri)
- local originUri = uri
- uri = getUriKey(uri)
local create
if not m.fileMap[uri] then
m.fileMap[uri] = {
- uri = originUri,
+ uri = uri,
version = 0,
}
m.fileCount = m.fileCount + 1
@@ -202,7 +170,7 @@ function m.setText(uri, text, isTrust, instance)
await.close('files.version')
m.onWatch('version')
if create then
- m.onWatch('create', originUri)
+ m.onWatch('create', uri)
end
if DEVELOP then
if text ~= newText then
@@ -211,14 +179,14 @@ function m.setText(uri, text, isTrust, instance)
end
if instance or TEST then
- m.onWatch('update', originUri)
+ m.onWatch('update', uri)
else
await.call(function ()
- await.close('update:' .. originUri)
- await.setID('update:' .. originUri)
+ await.close('update:' .. uri)
+ await.setID('update:' .. uri)
await.delay()
- if m.exists(originUri) then
- m.onWatch('update', originUri)
+ if m.exists(uri) then
+ m.onWatch('update', uri)
end
end)
end
@@ -235,7 +203,6 @@ 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
@@ -245,7 +212,6 @@ function m.setRawText(uri, text)
end
function m.getCachedRows(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -254,7 +220,6 @@ function m.getCachedRows(uri)
end
function m.setCachedRows(uri, rows)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return
@@ -263,7 +228,6 @@ function m.setCachedRows(uri, rows)
end
function m.getWords(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return
@@ -292,7 +256,6 @@ function m.getWords(uri)
end
function m.getWordsOfHead(uri, head)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -306,7 +269,6 @@ end
--- 获取文件版本
function m.getVersion(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -318,7 +280,6 @@ end
---@param uri uri
---@return string text
function m.getText(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -330,7 +291,6 @@ end
---@param uri uri
---@return string text
function m.getOriginText(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -339,7 +299,6 @@ function m.getOriginText(uri)
end
function m.getChildFiles(uri)
- uri = getUriKey(uri)
local results = {}
local uris = m.getAllUris()
for _, curi in ipairs(uris) do
@@ -356,7 +315,6 @@ end
---@param uri uri
function m.remove(uri)
local originUri = uri
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return
@@ -473,7 +431,7 @@ function m.compileState(uri, text)
m.notifyCache['preloadFileSize'][uri] = true
m.notifyCache['skipLargeFileCount'] = m.notifyCache['skipLargeFileCount'] + 1
local message = lang.script('WORKSPACE_SKIP_LARGE_FILE'
- , ws.getRelativePath(m.getOriginUri(uri))
+ , ws.getRelativePath(uri)
, config.get 'Lua.workspace.preloadFileSize'
, #text / 1000
)
@@ -486,7 +444,7 @@ function m.compileState(uri, text)
return nil
end
local prog <close> = progress.create(lang.script.WINDOW_COMPILING, 0.5)
- prog:setMessage(ws.getRelativePath(m.getOriginUri(uri)))
+ prog:setMessage(ws.getRelativePath(uri))
local clock = os.clock()
local state, err = parser:compile(text
, 'lua'
@@ -523,7 +481,7 @@ function m.compileState(uri, text)
end})
return state
else
- log.error('Compile failed:', m.getOriginUri(uri), err)
+ log.error('Compile failed:', uri, err)
return nil
end
end
@@ -532,7 +490,6 @@ end
---@param uri uri
---@return table state
function m.getState(uri)
- uri = getUriKey(uri)
if uri ~= '' and not m.isLua(uri) then
return nil
end
@@ -551,19 +508,17 @@ function m.getState(uri)
end
---设置文件的当前可见范围
----@param originUri uri
----@param ranges range[]
-function m.setVisibles(originUri, ranges)
- local uri = m.getUri(originUri)
+---@param uri uri
+---@param ranges range[]
+function m.setVisibles(uri, ranges)
m.visible[uri] = ranges
- m.onWatch('updateVisible', originUri)
+ m.onWatch('updateVisible', uri)
end
---获取文件的当前可见范围
---@param uri uri
---@return table[]
function m.getVisibles(uri)
- uri = m.getUri(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -587,7 +542,6 @@ end
---@param uri uri
---@return table lines
function m.getLines(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -601,7 +555,6 @@ function m.getLines(uri)
end
function m.getOriginLines(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -614,23 +567,7 @@ function m.getOriginLines(uri)
return lines
end
---- 获取原始uri
-function m.getOriginUri(uri)
- uri = getUriKey(uri)
- local file = m.fileMap[uri] or m.dllMap[uri]
- if not file then
- return nil
- end
- return file.uri
-end
-
-function m.getUri(uri)
- uri = getUriKey(uri)
- return uri
-end
-
function m.getFile(uri)
- uri = getUriKey(uri)
return m.fileMap[uri]
or m.dllMap[uri]
end
@@ -857,7 +794,6 @@ end
--- 获取文件的自定义缓存信息(在文件内容更新后自动失效)
function m.getCache(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return nil
@@ -866,15 +802,6 @@ function m.getCache(uri)
return file.cache
end
---- 判断文件名相等
-function m.eq(a, b)
- if platform.OS == 'Windows' then
- return a:lower():gsub('[/\\]+', '/') == b:lower():gsub('[/\\]+', '/')
- else
- return a == b
- end
-end
-
--- 获取文件关联
function m.getAssoc()
if m.assocVersion == config.get 'version' then
@@ -883,14 +810,11 @@ function m.getAssoc()
m.assocVersion = config.get 'version'
local patt = {}
for k, v in pairs(config.get 'files.associations') do
- if m.eq(v, 'lua') then
+ if v == 'lua' then
patt[#patt+1] = k
end
end
m.assocMatcher = glob.glob(patt)
- if platform.OS == 'Windows' then
- m.assocMatcher:setOption 'ignoreCase'
- end
return m.assocMatcher
end
@@ -902,7 +826,7 @@ function m.isLua(uri)
if not ext then
return false
end
- if m.eq(ext, 'lua') then
+ if ext == 'lua' then
return true
end
local matcher = m.getAssoc()
@@ -919,11 +843,11 @@ function m.isDll(uri)
return false
end
if platform.OS == 'Windows' then
- if m.eq(ext, 'dll') then
+ if ext == 'dll' then
return true
end
else
- if m.eq(ext, 'so') then
+ if ext == 'so' then
return true
end
end
@@ -937,7 +861,6 @@ function m.saveDll(uri, content)
if not content then
return
end
- local luri = getUriKey(uri)
local file = {
uri = uri,
opens = {},
@@ -959,7 +882,7 @@ function m.saveDll(uri, content)
end
end
- m.dllMap[luri] = file
+ m.dllMap[uri] = file
m.onWatch('dll', uri)
end
@@ -967,7 +890,6 @@ end
---@param uri uri
---@return string[]|nil
function m.getDllOpens(uri)
- uri = getUriKey(uri)
local file = m.dllMap[uri]
if not file then
return nil
@@ -979,7 +901,6 @@ end
---@param uri uri
---@return string[]|nil
function m.getDllWords(uri)
- uri = getUriKey(uri)
local file = m.dllMap[uri]
if not file then
return nil
@@ -1009,7 +930,6 @@ function m.flushCache()
end
function m.flushFileCache(uri)
- uri = getUriKey(uri)
local file = m.fileMap[uri]
if not file then
return
diff --git a/script/fs-utility.lua b/script/fs-utility.lua
index 11494e6a..529e8fcd 100644
--- a/script/fs-utility.lua
+++ b/script/fs-utility.lua
@@ -56,7 +56,7 @@ function m.relative(path, base)
local sPath = fs.absolute(path):string()
local sBase = fs.absolute(base):string()
--TODO 先只支持最简单的情况
- if sPath:sub(1, #sBase):lower() == sBase:lower()
+ if sPath:sub(1, #sBase) == sBase
and sPath:sub(#sBase + 1, #sBase + 1):match '^[/\\]' then
return fs.path(sPath:sub(#sBase + 1):gsub('^[/\\]+', ''))
end
@@ -490,13 +490,7 @@ function m.fileList(option)
if not path then
return nil
end
- local key
- if os == 'Windows' then
- key = path:string():lower()
- else
- key = path:string()
- end
- return key
+ return path:string()
end
return setmetatable({}, {
__index = function (_, path)
diff --git a/script/library.lua b/script/library.lua
index 0e65d96c..e0c32023 100644
--- a/script/library.lua
+++ b/script/library.lua
@@ -271,7 +271,7 @@ local function loadSingle3rdConfig(libraryDir)
if cfg.files then
for i, filename in ipairs(cfg.files) do
if plat.OS == 'Windows' then
- filename = filename:lower():gsub('/', '\\')
+ filename = filename:gsub('/', '\\')
else
filename = filename:gsub('\\', '/')
end
@@ -413,9 +413,6 @@ local function check3rdByFileName(uri, configs)
if not path then
return
end
- if plat.OS == 'Windows' then
- path = path:lower()
- end
await.call(function ()
for _, cfg in ipairs(configs) do
if cfg.files then
@@ -473,7 +470,7 @@ end)
files.watch(function (ev, uri)
if ev == 'update'
or ev == 'dll' then
- check3rd(files.asKey(uri))
+ check3rd(uri)
end
end)
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 5e8926a8..7fb1bdd2 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -45,7 +45,7 @@ local function buildSyntaxError(uri, err)
else
rmessage = text:sub(rel.start, rel.finish)
end
- local relUri = files.getOriginUri(rel.uri)
+ local relUri = rel.uri
relatedInformation[#relatedInformation+1] = {
message = rmessage,
location = define.location(relUri, files.range(relUri, rel.start, rel.finish)),
@@ -126,16 +126,15 @@ local function mergeSyntaxAndDiags(a, b)
end
function m.clear(uri)
- local luri = files.asKey(uri)
- if not m.cache[luri] then
+ if not m.cache[uri] then
return
end
- m.cache[luri] = nil
+ m.cache[uri] = nil
proto.notify('textDocument/publishDiagnostics', {
- uri = files.getOriginUri(luri) or uri,
+ uri = uri,
diagnostics = {},
})
- log.debug('clearDiagnostics', files.getOriginUri(uri))
+ log.debug('clearDiagnostics', uri)
end
function m.clearAll()
@@ -183,7 +182,6 @@ function m.doDiagnostic(uri)
if not config.get 'Lua.diagnostics.enable' then
return
end
- uri = files.asKey(uri)
if files.isLibrary(uri) or ws.isIgnored(uri) then
return
end
@@ -197,7 +195,7 @@ function m.doDiagnostic(uri)
end
local prog <close> = progress.create(lang.script.WINDOW_DIAGNOSING, 0.5)
- prog:setMessage(ws.getRelativePath(files.getOriginUri(uri)))
+ prog:setMessage(ws.getRelativePath(uri))
local syntax = m.syntaxErrors(uri, ast)
local diags = {}
@@ -216,11 +214,11 @@ function m.doDiagnostic(uri)
m.cache[uri] = full
proto.notify('textDocument/publishDiagnostics', {
- uri = files.getOriginUri(uri),
+ uri = uri,
diagnostics = full,
})
if #full > 0 then
- log.debug('publishDiagnostics', files.getOriginUri(uri), #full)
+ log.debug('publishDiagnostics', uri, #full)
end
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index e1cb86c3..477a342c 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -134,8 +134,8 @@ proto.on('workspace/didChangeWatchedFiles', function (params)
local path = furi.decode(uri)
local filename = fs.path(path):filename():string()
-- 排除类文件发生更改需要重新扫描
- if files.eq(filename, '.gitignore')
- or files.eq(filename, '.gitmodules') then
+ if filename == '.gitignore'
+ or filename == '.gitmodules' then
workspace.reload()
break
end
@@ -180,7 +180,7 @@ proto.on('workspace/didRenameFiles', function (params)
for _, uri in ipairs(childs) do
local ctext = files.getOriginText(uri)
if ctext then
- local ouri = files.getOriginUri(uri)
+ local ouri = uri
local tail = ouri:sub(#file.oldUri)
local nuri = file.newUri .. tail
log.debug('workspace/didRenameFiles#child', ouri, nuri)
diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua
index 245b6919..8df79dca 100644
--- a/script/vm/getLinks.lua
+++ b/script/vm/getLinks.lua
@@ -23,7 +23,6 @@ local function getFileLinks(uri)
end
local uris = ws.findUrisByRequirePath(args[1][1])
for _, u in ipairs(uris) do
- u = files.asKey(u)
if not links[u] then
links[u] = {}
end
@@ -41,7 +40,6 @@ local function getFileLinksOrCache(uri)
end
local function getLinksTo(uri)
- uri = files.asKey(uri)
local links = {}
for u in files.eachFile() do
local ls = getFileLinksOrCache(u)
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 8e5b67dc..096b7f75 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -18,7 +18,7 @@ local function getOnePath(path, searcher)
for pos = start, #stemPath do
local word = stemPath:sub(start, pos)
local newSearcher = stemSearcher:gsub('%?', (word:gsub('%%', '%%%%')))
- if files.eq(newSearcher, stemPath) then
+ if newSearcher == stemPath then
return word
end
end
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index b79a678b..ebd1b842 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -26,9 +26,7 @@ m.waitingReady = {}
m.requireCache = {}
m.cache = {}
m.watchers = {}
-m.matchOption = {
- ignoreCase = platform.OS == 'Windows',
-}
+m.matchOption = {}
--- 初始化工作区
function m.initPath(uri)
@@ -373,9 +371,6 @@ function m.findUrisByFilePath(path)
return {}
end
local lpath = furi.encode(path):gsub('^file:///', '')
- if platform.OS == 'Windows' then
- lpath = lpath:lower()
- end
local vm = require 'vm'
local resultCache = vm.getCache 'findUrisByRequirePath.result'
if resultCache[path] then
@@ -385,19 +380,16 @@ function m.findUrisByFilePath(path)
local results = {}
local posts = {}
for uri in files.eachFile() do
- if platform.OS ~= 'Windows' then
- uri = files.getOriginUri(uri)
- end
if not uri:find(lpath, 1, true) then
goto CONTINUE
end
local pathLen = #path
- local curPath = furi.decode(files.getOriginUri(uri))
+ local curPath = furi.decode(uri)
local curLen = #curPath
local seg = curPath:sub(curLen - pathLen, curLen - pathLen)
if seg == '/' or seg == '\\' or seg == '' then
local see = curPath:sub(curLen - pathLen + 1, curLen)
- if files.eq(see, path) then
+ if see == path then
results[#results+1] = uri
local post = curPath:sub(1, curLen - pathLen)
posts[uri] = post:gsub('^[/\\]+', '')
@@ -506,12 +498,7 @@ function m.getRelativePath(uriOrPath)
local relative = m.normalize(path)
return relative:gsub('^[/\\]+', '')
end
- local _, pos
- if platform.OS == 'Windows' then
- _, pos = m.normalize(path):lower():find(m.path:lower(), 1, true)
- else
- _, pos = m.normalize(path):find(m.path, 1, true)
- end
+ local _, pos = m.normalize(path):find(m.path, 1, true)
if pos then
return m.normalize(path:sub(pos + 1)):gsub('^[/\\]+', '')
else
@@ -523,9 +510,8 @@ function m.isWorkspaceUri(uri)
if not m.uri then
return false
end
- local luri = files.getUri(uri)
- local ruri = files.getUri(m.uri)
- return luri:sub(1, #ruri) == ruri
+ local ruri = m.uri
+ return uri:sub(1, #ruri) == ruri
end
--- 获取工作区等级的缓存