@@ -34,21 +34,24 @@ export const LINKED_COMMANDS = new Map<string, ra.CommandLink>();
3434// add code to remove a target command from the map after the link is
3535// clicked, but assuming most links in hover sheets won't be clicked anyway
3636// this code won't change the overall memory use much.
37- setInterval ( function cleanupOlderCommandLinks ( ) {
38- // keys are returned in insertion order, we'll keep a few
39- // of recent keys available, and clean the rest
40- const keys = [ ...LINKED_COMMANDS . keys ( ) ] ;
41- const keysToRemove = keys . slice ( 0 , keys . length - 10 ) ;
42- for ( const key of keysToRemove ) {
43- LINKED_COMMANDS . delete ( key ) ;
44- }
45- } , 10 * 60 * 1000 ) ;
37+ setInterval (
38+ function cleanupOlderCommandLinks ( ) {
39+ // keys are returned in insertion order, we'll keep a few
40+ // of recent keys available, and clean the rest
41+ const keys = [ ...LINKED_COMMANDS . keys ( ) ] ;
42+ const keysToRemove = keys . slice ( 0 , keys . length - 10 ) ;
43+ for ( const key of keysToRemove ) {
44+ LINKED_COMMANDS . delete ( key ) ;
45+ }
46+ } ,
47+ 10 * 60 * 1000 ,
48+ ) ;
4649
4750function renderCommand ( cmd : ra . CommandLink ) : string {
4851 const commandId = randomUUID ( ) ;
4952 LINKED_COMMANDS . set ( commandId , cmd ) ;
5053 return `[${ cmd . title } ](command:rust-analyzer.linkToCommand?${ encodeURIComponent (
51- JSON . stringify ( [ commandId ] )
54+ JSON . stringify ( [ commandId ] ) ,
5255 ) } '${ cmd . tooltip } ')`;
5356}
5457
@@ -57,7 +60,7 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri
5760 . map (
5861 ( group ) =>
5962 ( group . title ? group . title + " " : "" ) +
60- group . commands . map ( renderCommand ) . join ( " | " )
63+ group . commands . map ( renderCommand ) . join ( " | " ) ,
6164 )
6265 . join ( "___" ) ;
6366
@@ -72,7 +75,7 @@ export async function createClient(
7275 initializationOptions : vscode . WorkspaceConfiguration ,
7376 serverOptions : lc . ServerOptions ,
7477 config : Config ,
75- unlinkedFiles : vscode . Uri [ ]
78+ unlinkedFiles : vscode . Uri [ ] ,
7679) : Promise < lc . LanguageClient > {
7780 const clientOptions : lc . LanguageClientOptions = {
7881 documentSelector : [ { scheme : "file" , language : "rust" } ] ,
@@ -93,7 +96,7 @@ export async function createClient(
9396 async configuration (
9497 params : lc . ConfigurationParams ,
9598 token : vscode . CancellationToken ,
96- next : lc . ConfigurationRequest . HandlerSignature
99+ next : lc . ConfigurationRequest . HandlerSignature ,
97100 ) {
98101 const resp = await next ( params , token ) ;
99102 if ( resp && Array . isArray ( resp ) ) {
@@ -117,7 +120,7 @@ export async function createClient(
117120 async handleDiagnostics (
118121 uri : vscode . Uri ,
119122 diagnosticList : vscode . Diagnostic [ ] ,
120- next : lc . HandleDiagnosticsSignature
123+ next : lc . HandleDiagnosticsSignature ,
121124 ) {
122125 const preview = config . previewRustcOutput ;
123126 const errorCode = config . useRustcErrorCode ;
@@ -137,20 +140,20 @@ export async function createClient(
137140 const folder = vscode . workspace . getWorkspaceFolder ( uri ) ?. uri . fsPath ;
138141 if ( folder ) {
139142 const parentBackslash = uri . fsPath . lastIndexOf (
140- pathSeparator + "src"
143+ pathSeparator + "src" ,
141144 ) ;
142145 const parent = uri . fsPath . substring ( 0 , parentBackslash ) ;
143146
144147 if ( parent . startsWith ( folder ) ) {
145148 const path = vscode . Uri . file (
146- parent + pathSeparator + "Cargo.toml"
149+ parent + pathSeparator + "Cargo.toml" ,
147150 ) ;
148151 void vscode . workspace . fs . stat ( path ) . then ( async ( ) => {
149152 const choice = await vscode . window . showInformationMessage (
150153 `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${ path . path } , do you want to add it to the linked Projects?` ,
151154 "Yes" ,
152155 "No" ,
153- "Don't show this again"
156+ "Don't show this again" ,
154157 ) ;
155158 switch ( choice ) {
156159 case undefined :
@@ -168,14 +171,14 @@ export async function createClient(
168171 config
169172 . get < any [ ] > ( "linkedProjects" )
170173 ?. concat ( pathToInsert ) ,
171- false
174+ false ,
172175 ) ;
173176 break ;
174177 case "Don't show this again" :
175178 await config . update (
176179 "showUnlinkedFileNotification" ,
177180 false ,
178- false
181+ false ,
179182 ) ;
180183 break ;
181184 }
@@ -222,7 +225,7 @@ export async function createClient(
222225 document : vscode . TextDocument ,
223226 position : vscode . Position ,
224227 token : vscode . CancellationToken ,
225- _next : lc . ProvideHoverSignature
228+ _next : lc . ProvideHoverSignature ,
226229 ) {
227230 const editor = vscode . window . activeTextEditor ;
228231 const positionOrRange = editor ?. selection ?. contains ( position )
@@ -236,7 +239,7 @@ export async function createClient(
236239 client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
237240 position : positionOrRange ,
238241 } ,
239- token
242+ token ,
240243 )
241244 . then (
242245 ( result ) => {
@@ -250,7 +253,7 @@ export async function createClient(
250253 ( error ) => {
251254 client . handleFailedRequest ( lc . HoverRequest . type , token , error , null ) ;
252255 return Promise . resolve ( null ) ;
253- }
256+ } ,
254257 ) ;
255258 } ,
256259 // Using custom handling of CodeActions to support action groups and snippet edits.
@@ -260,14 +263,14 @@ export async function createClient(
260263 range : vscode . Range ,
261264 context : vscode . CodeActionContext ,
262265 token : vscode . CancellationToken ,
263- _next : lc . ProvideCodeActionsSignature
266+ _next : lc . ProvideCodeActionsSignature ,
264267 ) {
265268 const params : lc . CodeActionParams = {
266269 textDocument : client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
267270 range : client . code2ProtocolConverter . asRange ( range ) ,
268271 context : await client . code2ProtocolConverter . asCodeActionContext (
269272 context ,
270- token
273+ token ,
271274 ) ,
272275 } ;
273276 return client . sendRequest ( lc . CodeActionRequest . type , params , token ) . then (
@@ -283,21 +286,21 @@ export async function createClient(
283286 if ( lc . CodeAction . is ( item ) ) {
284287 assert (
285288 ! item . command ,
286- "We don't expect to receive commands in CodeActions"
289+ "We don't expect to receive commands in CodeActions" ,
287290 ) ;
288291 const action = await client . protocol2CodeConverter . asCodeAction (
289292 item ,
290- token
293+ token ,
291294 ) ;
292295 result . push ( action ) ;
293296 continue ;
294297 }
295298 assert (
296299 isCodeActionWithoutEditsAndCommands ( item ) ,
297- "We don't expect edits or commands here"
300+ "We don't expect edits or commands here" ,
298301 ) ;
299302 const kind = client . protocol2CodeConverter . asCodeActionKind (
300- ( item as any ) . kind
303+ ( item as any ) . kind ,
301304 ) ;
302305 const action = new vscode . CodeAction ( item . title , kind ) ;
303306 const group = ( item as any ) . group ;
@@ -351,7 +354,7 @@ export async function createClient(
351354 }
352355 return result ;
353356 } ,
354- ( _error ) => undefined
357+ ( _error ) => undefined ,
355358 ) ;
356359 } ,
357360 } ,
@@ -364,7 +367,7 @@ export async function createClient(
364367 "rust-analyzer" ,
365368 "Rust Analyzer Language Server" ,
366369 serverOptions ,
367- clientOptions
370+ clientOptions ,
368371 ) ;
369372
370373 // To turn on all proposed features use: client.registerProposedFeatures();
@@ -400,7 +403,7 @@ class ExperimentalFeatures implements lc.StaticFeature {
400403 }
401404 initialize (
402405 _capabilities : lc . ServerCapabilities ,
403- _documentSelector : lc . DocumentSelector | undefined
406+ _documentSelector : lc . DocumentSelector | undefined ,
404407 ) : void { }
405408 dispose ( ) : void { }
406409}
@@ -419,7 +422,7 @@ class OverrideFeatures implements lc.StaticFeature {
419422 }
420423 initialize (
421424 _capabilities : lc . ServerCapabilities ,
422- _documentSelector : lc . DocumentSelector | undefined
425+ _documentSelector : lc . DocumentSelector | undefined ,
423426 ) : void { }
424427 dispose ( ) : void { }
425428}
0 commit comments