@@ -2158,7 +2158,7 @@ local function tryluaDocByErr(state, position, err, docState, results)
21582158 end
21592159end
21602160
2161- local function buildluaDocOfFunction (func )
2161+ local function buildluaDocOfFunction (func , pad )
21622162 local index = 1
21632163 local buf = {}
21642164 buf [# buf + 1 ] = ' ${1:comment}'
@@ -2182,7 +2182,8 @@ local function buildluaDocOfFunction(func)
21822182 local funcArg = func .args [n ]
21832183 if funcArg [1 ] and funcArg .type ~= ' self' then
21842184 index = index + 1
2185- buf [# buf + 1 ] = (' ---@param %s ${%d:%s}' ):format (
2185+ buf [# buf + 1 ] = (' ---%s@param %s ${%d:%s}' ):format (
2186+ pad and ' ' or ' ' ,
21862187 funcArg [1 ],
21872188 index ,
21882189 arg
@@ -2200,7 +2201,7 @@ local function buildluaDocOfFunction(func)
22002201 return insertText
22012202end
22022203
2203- local function tryluaDocOfFunction (doc , results )
2204+ local function tryluaDocOfFunction (doc , results , pad )
22042205 if not doc .bindSource then
22052206 return
22062207 end
@@ -2222,7 +2223,7 @@ local function tryluaDocOfFunction(doc, results)
22222223 end
22232224 end
22242225 end
2225- local insertText = buildluaDocOfFunction (func )
2226+ local insertText = buildluaDocOfFunction (func , pad )
22262227 results [# results + 1 ] = {
22272228 label = ' @param;@return' ,
22282229 kind = define .CompletionItemKind .Snippet ,
@@ -2240,9 +2241,9 @@ local function tryLuaDoc(state, position, results)
22402241 end
22412242 if doc .type == ' doc.comment' then
22422243 local line = doc .originalComment .text
2243- -- 尝试 ---$
2244- if line == ' -' then
2245- tryluaDocOfFunction (doc , results )
2244+ -- 尝试 ' ---$' or '--- $'
2245+ if line == ' -' or line == ' - ' then
2246+ tryluaDocOfFunction (doc , results , line == ' - ' )
22462247 return
22472248 end
22482249 -- 尝试 ---@$
0 commit comments