summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-27 16:41:09 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-27 16:41:09 +0800
commitf8c9c70e8693a2471f914d47ed36bbe19c982f0c (patch)
tree9641f814cfb5a51d8bd06d5e4ed3d59e1070b26f
parent1de77a38e4ec3ea6cb1a2b2b3045c2c08f4311c0 (diff)
downloadlua-language-server-f8c9c70e8693a2471f914d47ed36bbe19c982f0c.zip
#1385
-rw-r--r--script/file-uri.lua4
-rw-r--r--script/workspace/workspace.lua4
2 files changed, 7 insertions, 1 deletions
diff --git a/script/file-uri.lua b/script/file-uri.lua
index 88e1111a..f9ede668 100644
--- a/script/file-uri.lua
+++ b/script/file-uri.lua
@@ -92,6 +92,10 @@ function m.split(uri)
return uri:match('([^:]*):/?/?([^/]*)(.*)')
end
+function m.isValid(uri)
+ return m.split(uri) ~= nil
+end
+
function m.normalize(uri)
if uri == '' then
return uri
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 11fe0dfa..973ae9ec 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -45,7 +45,9 @@ end
--- 初始化工作区
function m.create(uri)
- uri = furi.normalize(uri)
+ if furi.isValid(uri) then
+ uri = furi.normalize(uri)
+ end
log.info('Workspace create: ', uri)
if uri == furi.encode '/'
or uri == furi.encode(os.getenv 'HOME' or '') then