summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/workspace/require-path.lua2
-rw-r--r--test/crossfile/definition.lua84
3 files changed, 65 insertions, 22 deletions
diff --git a/changelog.md b/changelog.md
index ac91756f..63a53bec 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,7 @@
# changelog
## 2.5.4
+* `FIX` [#847](https://github.com/sumneko/lua-language-server/issues/847)
* `FIX` [#848](https://github.com/sumneko/lua-language-server/issues/848)
* `FIX` completion: incorrect cache
* `FIX` hover: always view string
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 52151dba..0fec6cc9 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -60,10 +60,8 @@ function m.getVisiblePath(path)
pos = currentPath:match('[/\\]+()', pos)
if platform.OS == 'Windows' then
searcher = searcher :gsub('[/\\]+', '\\')
- :gsub('^[/\\]+', '')
else
searcher = searcher :gsub('[/\\]+', '/')
- :gsub('^[/\\]+', '')
end
local expect = getOnePath(cutedPath, searcher)
if expect then
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index f44633e1..aa971f3e 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -891,25 +891,69 @@ print(t.<?x?>)
}
}
---config.set('Lua.runtime.path', {
--- '/home/?.lua'
---})
---TEST {
--- {
--- path = '/home/a.lua',
--- content = [[
---return {
--- <!x!> = 1,
---}
---]],
--- },
--- {
--- path = 'b.lua',
--- content = [[
---local t = require 'a'
---print(t.<?x?>)
--- ]]
--- }
---}
+config.set('Lua.runtime.path', {
+ '/home/?.lua'
+})
+TEST {
+ {
+ path = '/home/a.lua',
+ content = [[
+return {
+ <!x!> = 1,
+}
+]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+local t = require 'a'
+print(t.<?x?>)
+ ]]
+ }
+}
+config.set('Lua.runtime.pathStrict', true)
+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', {
+ '/home/?.lua'
+})
+TEST {
+ {
+ path = '/home/a.lua',
+ content = [[
+return {
+ <!x!> = 1,
+}
+]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+local t = require 'a'
+print(t.<?x?>)
+ ]]
+ }
+}
+
+config.set('Lua.runtime.pathStrict', false)
config.set('Lua.runtime.path', originRuntimePath)