summaryrefslogtreecommitdiff
path: root/script
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 /script
parentb93e0756cc07d9188a8047438f502ff296d5ec66 (diff)
downloadlua-language-server-ce0432a3cc09909d6a9c9c9886761a128d34c2ad.zip
fix #1851
Diffstat (limited to 'script')
-rw-r--r--script/core/completion/auto-require.lua21
-rw-r--r--script/workspace/require-path.lua1
2 files changed, 14 insertions, 8 deletions
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