summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-01-30 21:01:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-01-30 21:01:01 +0800
commitce0432a3cc09909d6a9c9c9886761a128d34c2ad (patch)
treec201df1746aef3a9caa13d43f48b6a2abf32ac65
parentb93e0756cc07d9188a8047438f502ff296d5ec66 (diff)
downloadlua-language-server-ce0432a3cc09909d6a9c9c9886761a128d34c2ad.zip
fix #1851
-rw-r--r--changelog.md2
-rw-r--r--script/core/completion/auto-require.lua21
-rw-r--r--script/workspace/require-path.lua1
3 files changed, 16 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md
index d9098991..1e6100e4 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,10 +5,12 @@
* `FIX` [#1831]
* `FIX` [#1838]
* `FIX` [#1841]
+* `FIX` [#1851]
[#1831]: https://github.com/sumneko/lua-language-server/issues/1831
[#1838]: https://github.com/sumneko/lua-language-server/issues/1838
[#1841]: https://github.com/sumneko/lua-language-server/issues/1841
+[#1851]: https://github.com/sumneko/lua-language-server/issues/1851
## 3.6.7
`2023-1-20`
diff --git a/script/core/completion/auto-require.lua b/script/core/completion/auto-require.lua
index 74fd2e1e..cec7139c 100644
--- a/script/core/completion/auto-require.lua
+++ b/script/core/completion/auto-require.lua
@@ -48,16 +48,21 @@ function m.check(state, word, position, callback)
local infos = rpath.getVisiblePath(uri, path)
local testedStem = { }
for _, sr in ipairs(infos) do
- local pattern = sr.searcher
- :gsub("(%p)", "%%%1")
- :gsub("%%%?", "(.-)")
+ local stemName
+ if sr.searcher == '[[meta]]' then
+ stemName = sr.name
+ else
+ local pattern = sr.searcher
+ : gsub("(%p)", "%%%1")
+ : gsub("%%%?", "(.-)")
- local stemName = relativePath
- :match(pattern)
- :match("[%a_][%w_]*$")
+ stemName = relativePath
+ : match(pattern)
+ : match("[%a_][%w_]*$")
- if not stemName or testedStem[stemName] then
- goto INNER_CONTINUE
+ if not stemName or testedStem[stemName] then
+ goto INNER_CONTINUE
+ end
end
testedStem[stemName] = true
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index d7ca8e26..e51d1219 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -68,6 +68,7 @@ function mt:getRequireResultByPath(path)
if vm.isMetaFileRequireable(uri) then
result[#result+1] = {
name = metaName,
+ searcher = '[[meta]]',
}
end
return result