summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/completion/completion.lua4
-rw-r--r--script/core/definition.lua2
-rw-r--r--script/core/hover/description.lua2
-rw-r--r--script/core/hover/init.lua2
-rw-r--r--script/core/workspace-symbol.lua39
-rw-r--r--script/provider/provider.lua2
-rw-r--r--test/crossfile/hover.lua6
7 files changed, 37 insertions, 20 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index cac74543..0f85bec5 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1866,7 +1866,7 @@ local function tryluaDocBySource(state, position, source, results)
end
return true
elseif source.type == 'doc.see.name' then
- local symbolds = wssymbol(source[1])
+ local symbolds = wssymbol(source[1], state.uri)
table.sort(symbolds, function (a, b)
return a.name < b.name
end)
@@ -2029,7 +2029,7 @@ local function tryluaDocByErr(state, position, err, docState, results)
}
end
elseif err.type == 'LUADOC_MISS_SEE_NAME' then
- local symbolds = wssymbol('')
+ local symbolds = wssymbol('', state.uri)
table.sort(symbolds, function (a, b)
return a.name < b.name
end)
diff --git a/script/core/definition.lua b/script/core/definition.lua
index 22a43bbf..b175db42 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -114,7 +114,7 @@ local function checkSee(source, results)
if source.type ~= 'doc.see.name' then
return
end
- local symbols = wssymbol(source[1])
+ local symbols = wssymbol(source[1], guide.getUri(source))
for _, symbol in ipairs(symbols) do
if symbol.name == source[1] then
results[#results+1] = {
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 0bbe510a..bd584d74 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -131,7 +131,7 @@ local function packSee(see)
local name = see.name[1]
local buf = {}
local target
- for _, symbol in ipairs(wssymbol(name)) do
+ for _, symbol in ipairs(wssymbol(name, guide.getUri(see))) do
if symbol.name == name then
target = symbol.source
break
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua
index 2051623c..d9fb2b6d 100644
--- a/script/core/hover/init.lua
+++ b/script/core/hover/init.lua
@@ -16,7 +16,7 @@ local function getHover(source)
local descMark = {}
if source.type == 'doc.see.name' then
- for _, symbol in ipairs(wssymbol(source[1])) do
+ for _, symbol in ipairs(wssymbol(source[1], guide.getUri(source))) do
if symbol.name == source[1] then
source = symbol.source
break
diff --git a/script/core/workspace-symbol.lua b/script/core/workspace-symbol.lua
index 2e865594..8ac22b20 100644
--- a/script/core/workspace-symbol.lua
+++ b/script/core/workspace-symbol.lua
@@ -57,12 +57,19 @@ end
---@async
---@param key string
+---@param suri? uri
---@param results table[]
-local function searchGlobalAndClass(key, results)
+local function searchGlobalAndClass(key, suri, results)
for _, global in pairs(vm.getAllGlobals()) do
local name = global:getCodeName()
if matchKey(key, name) then
- for _, set in ipairs(global:getAllSets()) do
+ local sets
+ if suri then
+ sets = global:getSets(suri)
+ else
+ sets = global:getAllSets()
+ end
+ for _, set in ipairs(sets) do
local skind, ckind
if set.type == 'doc.class' then
skind = define.SymbolKind.Class
@@ -88,8 +95,9 @@ end
---@async
---@param key string
+---@param suri? uri
---@param results table[]
-local function searchClassField(key, results)
+local function searchClassField(key, suri, results)
local class, inField = key:match('^(.+)%.(.-)$')
if not class then
return
@@ -98,11 +106,16 @@ local function searchClassField(key, results)
if not global then
return
end
- local set = global:getAllSets()[1]
+ local set
+ if suri then
+ set = global:getSets(suri)[1]
+ else
+ set = global:getAllSets()[1]
+ end
if not set then
return
end
- local suri = guide.getUri(set)
+ suri = suri or guide.getUri(set)
vm.getClassFields(suri, global, nil, false, function (field, isMark)
if field.type == 'generic' then
return
@@ -126,9 +139,10 @@ end
---@async
---@param key string
+---@param suri? uri
---@param results table[]
-local function searchWords(key, results)
- for uri in files.eachFile() do
+local function searchWords(key, suri, results)
+ for uri in files.eachFile(suri) do
searchFile(uri, key, results)
if #results > 1000 then
break
@@ -138,13 +152,16 @@ local function searchWords(key, results)
end
---@async
-return function (key, includeWords)
+---@param key string
+---@param suri? uri
+---@param includeWords? boolean
+return function (key, suri, includeWords)
local results = {}
- searchGlobalAndClass(key, results)
- searchClassField(key, results)
+ searchGlobalAndClass(key, suri, results)
+ searchClassField(key, suri, results)
if includeWords then
- searchWords(key, results)
+ searchWords(key, suri, results)
end
return results
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 9fede5cc..33dba27a 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -954,7 +954,7 @@ m.register 'workspace/symbol' {
local _ <close> = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_PROCESSING_WS_SYMBOL, 0.5)
local core = require 'core.workspace-symbol'
- local symbols = core(params.query, true)
+ local symbols = core(params.query, nil, true)
if not symbols or #symbols == 0 then
return nil
end
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 4a567a31..1cb48e61 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -1658,7 +1658,7 @@ local x: unknown
---
-See: [A](file:///a.lua:1:10) comment1]]
+See: [A](file:///a.lua#1#10) comment1]]
}
TEST { {path = 'a.lua', content = [[
@@ -1678,6 +1678,6 @@ local x: unknown
---
See:
- * [A](file:///a.lua:1:10) comment1
- * [TTT](file:///a.lua:3:0) comment2]]
+ * [A](file:///a.lua#1#10) comment1
+ * [TTT](file:///a.lua#3#0) comment2]]
}