Skip to content

Commit eb37453

Browse files
committed
fix comments
1 parent 2896105 commit eb37453

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

script/core/hover/description.lua

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,33 +83,21 @@ local function asString(source)
8383
or asStringView(source, literal)
8484
end
8585

86-
local function getBindComment(source)
87-
local lines = {}
88-
for _, docComment in ipairs(source.bindComments) do
89-
if docComment.comment.text:sub(1, 1) == '-' then
90-
lines[#lines+1] = docComment.comment.text:sub(2)
91-
else
92-
lines[#lines+1] = docComment.comment.text
93-
end
94-
end
95-
if not lines or #lines == 0 then
96-
return nil
97-
end
98-
return table.concat(lines, '\n')
99-
end
100-
10186
---@param comment string
10287
---@param suri uri
10388
---@return string?
10489
local function normalizeComment(comment, suri)
90+
if not comment then
91+
return nil
92+
end
10593
if comment:sub(1, 1) == '-' then
10694
comment = comment:sub(2)
10795
end
10896
if comment:sub(1, 1) == '@' then
10997
return nil
11098
end
11199
comment = comment:gsub('(%[.-%]%()(.-)(%))', function (left, path, right)
112-
if path:match '^file:/' then
100+
if furi.split(path) then
113101
return
114102
end
115103
local absPath = ws.getAbsolutePath(suri:gsub('/[^/]+$', ''), path)
@@ -122,6 +110,18 @@ local function normalizeComment(comment, suri)
122110
return comment
123111
end
124112

113+
local function getBindComment(source)
114+
local uri = guide.getUri(source)
115+
local lines = {}
116+
for _, docComment in ipairs(source.bindComments) do
117+
lines[#lines+1] = normalizeComment(docComment.comment.text, uri)
118+
end
119+
if not lines or #lines == 0 then
120+
return nil
121+
end
122+
return table.concat(lines, '\n')
123+
end
124+
125125
local function lookUpDocComments(source, docGroup)
126126
if source.type == 'setlocal'
127127
or source.type == 'getlocal' then
@@ -134,25 +134,19 @@ local function lookUpDocComments(source, docGroup)
134134
local lines = {}
135135
for _, doc in ipairs(docGroup) do
136136
if doc.type == 'doc.comment' then
137-
local comment = normalizeComment(doc.comment.text, uri)
138-
lines[#lines+1] = comment
137+
lines[#lines+1] = normalizeComment(doc.comment.text, uri)
139138
elseif doc.type == 'doc.type' then
140139
if doc.comment then
141-
lines[#lines+1] = doc.comment.text
140+
lines[#lines+1] = normalizeComment(doc.comment.text, uri)
142141
end
143142
elseif doc.type == 'doc.class' then
144143
for _, docComment in ipairs(doc.bindComments) do
145-
if docComment.comment.text:sub(1, 1) == '-' then
146-
lines[#lines+1] = docComment.comment.text:sub(2)
147-
else
148-
lines[#lines+1] = docComment.comment.text
149-
end
144+
lines[#lines+1] = normalizeComment(docComment.comment.text, uri)
150145
end
151146
end
152-
::CONTINUE::
153147
end
154148
if source.comment then
155-
lines[#lines+1] = source.comment.text
149+
lines[#lines+1] = normalizeComment(source.comment.text, uri)
156150
end
157151
if not lines or #lines == 0 then
158152
return nil

script/file-uri.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function m.decode(uri)
8989
end
9090

9191
function m.split(uri)
92-
return uri:match('([^:]*):?/?/?([^/]*)(.*)')
92+
return uri:match('([^:]*):/?/?([^/]*)(.*)')
9393
end
9494

9595
return m

0 commit comments

Comments
 (0)