Skip to content

Commit 0fc72b8

Browse files
committed
cleanup
1 parent 02dd5b6 commit 0fc72b8

File tree

7 files changed

+37
-20
lines changed

7 files changed

+37
-20
lines changed

script/core/completion/completion.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ local function tryluaDocBySource(state, position, source, results)
18661866
end
18671867
return true
18681868
elseif source.type == 'doc.see.name' then
1869-
local symbolds = wssymbol(source[1])
1869+
local symbolds = wssymbol(source[1], state.uri)
18701870
table.sort(symbolds, function (a, b)
18711871
return a.name < b.name
18721872
end)
@@ -2029,7 +2029,7 @@ local function tryluaDocByErr(state, position, err, docState, results)
20292029
}
20302030
end
20312031
elseif err.type == 'LUADOC_MISS_SEE_NAME' then
2032-
local symbolds = wssymbol('')
2032+
local symbolds = wssymbol('', state.uri)
20332033
table.sort(symbolds, function (a, b)
20342034
return a.name < b.name
20352035
end)

script/core/definition.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ local function checkSee(source, results)
114114
if source.type ~= 'doc.see.name' then
115115
return
116116
end
117-
local symbols = wssymbol(source[1])
117+
local symbols = wssymbol(source[1], guide.getUri(source))
118118
for _, symbol in ipairs(symbols) do
119119
if symbol.name == source[1] then
120120
results[#results+1] = {

script/core/hover/description.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ local function packSee(see)
131131
local name = see.name[1]
132132
local buf = {}
133133
local target
134-
for _, symbol in ipairs(wssymbol(name)) do
134+
for _, symbol in ipairs(wssymbol(name, guide.getUri(see))) do
135135
if symbol.name == name then
136136
target = symbol.source
137137
break

script/core/hover/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local function getHover(source)
1616
local descMark = {}
1717

1818
if source.type == 'doc.see.name' then
19-
for _, symbol in ipairs(wssymbol(source[1])) do
19+
for _, symbol in ipairs(wssymbol(source[1], guide.getUri(source))) do
2020
if symbol.name == source[1] then
2121
source = symbol.source
2222
break

script/core/workspace-symbol.lua

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,19 @@ end
5757

5858
---@async
5959
---@param key string
60+
---@param suri? uri
6061
---@param results table[]
61-
local function searchGlobalAndClass(key, results)
62+
local function searchGlobalAndClass(key, suri, results)
6263
for _, global in pairs(vm.getAllGlobals()) do
6364
local name = global:getCodeName()
6465
if matchKey(key, name) then
65-
for _, set in ipairs(global:getAllSets()) do
66+
local sets
67+
if suri then
68+
sets = global:getSets(suri)
69+
else
70+
sets = global:getAllSets()
71+
end
72+
for _, set in ipairs(sets) do
6673
local skind, ckind
6774
if set.type == 'doc.class' then
6875
skind = define.SymbolKind.Class
@@ -88,8 +95,9 @@ end
8895

8996
---@async
9097
---@param key string
98+
---@param suri? uri
9199
---@param results table[]
92-
local function searchClassField(key, results)
100+
local function searchClassField(key, suri, results)
93101
local class, inField = key:match('^(.+)%.(.-)$')
94102
if not class then
95103
return
@@ -98,11 +106,16 @@ local function searchClassField(key, results)
98106
if not global then
99107
return
100108
end
101-
local set = global:getAllSets()[1]
109+
local set
110+
if suri then
111+
set = global:getSets(suri)[1]
112+
else
113+
set = global:getAllSets()[1]
114+
end
102115
if not set then
103116
return
104117
end
105-
local suri = guide.getUri(set)
118+
suri = suri or guide.getUri(set)
106119
vm.getClassFields(suri, global, nil, false, function (field, isMark)
107120
if field.type == 'generic' then
108121
return
@@ -126,9 +139,10 @@ end
126139

127140
---@async
128141
---@param key string
142+
---@param suri? uri
129143
---@param results table[]
130-
local function searchWords(key, results)
131-
for uri in files.eachFile() do
144+
local function searchWords(key, suri, results)
145+
for uri in files.eachFile(suri) do
132146
searchFile(uri, key, results)
133147
if #results > 1000 then
134148
break
@@ -138,13 +152,16 @@ local function searchWords(key, results)
138152
end
139153

140154
---@async
141-
return function (key, includeWords)
155+
---@param key string
156+
---@param suri? uri
157+
---@param includeWords? boolean
158+
return function (key, suri, includeWords)
142159
local results = {}
143160

144-
searchGlobalAndClass(key, results)
145-
searchClassField(key, results)
161+
searchGlobalAndClass(key, suri, results)
162+
searchClassField(key, suri, results)
146163
if includeWords then
147-
searchWords(key, results)
164+
searchWords(key, suri, results)
148165
end
149166

150167
return results

script/provider/provider.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ m.register 'workspace/symbol' {
954954
local _ <close> = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_PROCESSING_WS_SYMBOL, 0.5)
955955
local core = require 'core.workspace-symbol'
956956

957-
local symbols = core(params.query, true)
957+
local symbols = core(params.query, nil, true)
958958
if not symbols or #symbols == 0 then
959959
return nil
960960
end

test/crossfile/hover.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,7 @@ local x: unknown
16581658
16591659
---
16601660
1661-
See: [A](file:///a.lua:1:10) comment1]]
1661+
See: [A](file:///a.lua#1#10) comment1]]
16621662
}
16631663

16641664
TEST { {path = 'a.lua', content = [[
@@ -1678,6 +1678,6 @@ local x: unknown
16781678
---
16791679
16801680
See:
1681-
* [A](file:///a.lua:1:10) comment1
1682-
* [TTT](file:///a.lua:3:0) comment2]]
1681+
* [A](file:///a.lua#1#10) comment1
1682+
* [TTT](file:///a.lua#3#0) comment2]]
16831683
}

0 commit comments

Comments
 (0)