summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-16 17:07:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-16 17:07:15 +0800
commit8b0d3827faf0cdc967e52ddfbe043c07c0dbe6a2 (patch)
tree34e869b1babfaf99ee04b752878ee53993303815
parentedf22aba16f36ca7784832f7bb6a550ac6ab1af2 (diff)
downloadlua-language-server-8b0d3827faf0cdc967e52ddfbe043c07c0dbe6a2.zip
#847 normalize `./`
-rw-r--r--script/workspace/workspace.lua1
-rw-r--r--test/crossfile/definition.lua25
2 files changed, 26 insertions, 0 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index ea2c4737..529c8936 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -488,6 +488,7 @@ function m.normalize(path)
end
end)
path = util.expandPath(path)
+ path = path:gsub('^%.[/\\]+', '')
if platform.OS == 'Windows' then
path = path:gsub('[/\\]+', '\\')
:gsub('[/\\]+$', '')
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index 058f5d18..b0cc232f 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -867,3 +867,28 @@ print(t.<?x?>)
]]
}
}
+
+local originRuntimePath = config.get 'Lua.runtime.path'
+config.set('Lua.runtime.path', {
+ './?.lua'
+})
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+return {
+ <!x!> = 1,
+}
+]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+local t = require 'a'
+print(t.<?x?>)
+ ]]
+ }
+}
+
+config.set('Lua.runtime.path', originRuntimePath)