@@ -5,29 +5,39 @@ local define = require 'proto.define'
55local util = require ' utility'
66local subber = require ' core.substring'
77
8+ --- @param text string
9+ --- @return string
10+ local function clipLastLine (text )
11+ if text :find ' [\r\n ]' then
12+ return ' ... ' .. util .trim (text :match ' [^\r\n ]*$' )
13+ else
14+ return text
15+ end
16+ end
17+
818local function buildName (source , sub )
919 if source .type == ' setmethod'
1020 or source .type == ' getmethod' then
1121 if source .method then
12- return sub (source .start + 1 , source .method .finish )
22+ return clipLastLine ( sub (source .start + 1 , source .method .finish ) )
1323 end
1424 end
1525 if source .type == ' setfield'
1626 or source .type == ' tablefield'
1727 or source .type == ' getfield' then
1828 if source .field then
19- return sub (source .start + 1 , source .field .finish )
29+ return clipLastLine ( sub (source .start + 1 , source .field .finish ) )
2030 end
2131 end
2232 if source .type == ' tableindex' then
2333 if source .index then
24- return sub (source .start + 1 , source .finish )
34+ return ( ' [%s] ' ): format ( clipLastLine ( sub (source .index . start + 1 , source .index . finish )) )
2535 end
2636 end
2737 if source .type == ' tableexp' then
2838 return (' [%d]' ):format (source .tindex )
2939 end
30- return sub (source .start + 1 , source .finish )
40+ return clipLastLine ( sub (source .start + 1 , source .finish ) )
3141end
3242
3343local function buildFunctionParams (func )
@@ -205,18 +215,20 @@ local function buildAnonymous(source, sub, used, symbols)
205215 end
206216 used [source ] = true
207217 local head = ' '
218+ local detail = ' '
208219 local parent = source .parent
209220 if parent .type == ' return' then
210221 head = ' return'
211222 elseif parent .type == ' callargs' then
212223 local call = parent .parent
213224 local node = call .node
214- head = buildName (node , sub ) .. ' ->'
225+ head = buildName (node , sub )
226+ detail = ' -> '
215227 end
216228 if source .type == ' function' then
217229 symbols [# symbols + 1 ] = {
218230 name = head ,
219- detail = (' function (%s)' ):format (buildFunctionParams (source )),
231+ detail = detail .. (' function (%s)' ):format (buildFunctionParams (source )),
220232 kind = define .SymbolKind .Function ,
221233 range = { source .start , source .finish },
222234 selectionRange = { source .keyword [1 ], source .keyword [2 ] },
@@ -243,7 +255,7 @@ local function buildAnonymous(source, sub, used, symbols)
243255 end
244256 symbols [# symbols + 1 ] = {
245257 name = head ,
246- detail = table.concat (details ),
258+ detail = detail .. table.concat (details ),
247259 kind = kind ,
248260 range = { source .start , source .finish },
249261 selectionRange = { source .start , source .finish },
0 commit comments