@@ -1345,7 +1345,7 @@ pub(crate) fn code_action(
13451345pub ( crate ) fn runnable (
13461346 snap : & GlobalStateSnapshot ,
13471347 runnable : Runnable ,
1348- ) -> Cancellable < lsp_ext:: Runnable > {
1348+ ) -> Cancellable < Option < lsp_ext:: Runnable > > {
13491349 let config = snap. config . runnables ( ) ;
13501350 let target_spec = TargetSpec :: for_file ( snap, runnable. nav . file_id ) ?;
13511351
@@ -1360,7 +1360,7 @@ pub(crate) fn runnable(
13601360 let label = runnable. label ( Some ( target) ) ;
13611361 let location = location_link ( snap, None , runnable. nav ) ?;
13621362
1363- Ok ( lsp_ext:: Runnable {
1363+ Ok ( Some ( lsp_ext:: Runnable {
13641364 label,
13651365 location : Some ( location) ,
13661366 kind : lsp_ext:: RunnableKind :: Cargo ,
@@ -1372,15 +1372,15 @@ pub(crate) fn runnable(
13721372 executable_args,
13731373 expect_test : None ,
13741374 } ) ,
1375- } )
1375+ } ) )
13761376 }
13771377 None => {
13781378 let ( cargo_args, executable_args) =
13791379 CargoTargetSpec :: runnable_args ( snap, None , & runnable. kind , & runnable. cfg ) ;
13801380 let label = runnable. label ( None ) ;
13811381 let location = location_link ( snap, None , runnable. nav ) ?;
13821382
1383- Ok ( lsp_ext:: Runnable {
1383+ Ok ( Some ( lsp_ext:: Runnable {
13841384 label,
13851385 location : Some ( location) ,
13861386 kind : lsp_ext:: RunnableKind :: Cargo ,
@@ -1392,7 +1392,7 @@ pub(crate) fn runnable(
13921392 executable_args,
13931393 expect_test : None ,
13941394 } ) ,
1395- } )
1395+ } ) )
13961396 }
13971397 }
13981398}
@@ -1418,34 +1418,36 @@ pub(crate) fn code_lens(
14181418 } ;
14191419 let r = runnable ( snap, run) ?;
14201420
1421- let has_root = match & r. args {
1422- lsp_ext:: RunnableArgs :: Cargo ( c) => c. workspace_root . is_some ( ) ,
1423- } ;
1421+ if let Some ( r) = r {
1422+ let has_root = match & r. args {
1423+ lsp_ext:: RunnableArgs :: Cargo ( c) => c. workspace_root . is_some ( ) ,
1424+ } ;
14241425
1425- let lens_config = snap. config . lens ( ) ;
1426- if lens_config. run && client_commands_config. run_single && has_root {
1427- let command = command:: run_single ( & r, & title) ;
1428- acc. push ( lsp_types:: CodeLens {
1429- range : annotation_range,
1430- command : Some ( command) ,
1431- data : None ,
1432- } )
1433- }
1434- if lens_config. debug && can_debug && client_commands_config. debug_single {
1435- let command = command:: debug_single ( & r) ;
1436- acc. push ( lsp_types:: CodeLens {
1437- range : annotation_range,
1438- command : Some ( command) ,
1439- data : None ,
1440- } )
1441- }
1442- if lens_config. interpret {
1443- let command = command:: interpret_single ( & r) ;
1444- acc. push ( lsp_types:: CodeLens {
1445- range : annotation_range,
1446- command : Some ( command) ,
1447- data : None ,
1448- } )
1426+ let lens_config = snap. config . lens ( ) ;
1427+ if lens_config. run && client_commands_config. run_single && has_root {
1428+ let command = command:: run_single ( & r, & title) ;
1429+ acc. push ( lsp_types:: CodeLens {
1430+ range : annotation_range,
1431+ command : Some ( command) ,
1432+ data : None ,
1433+ } )
1434+ }
1435+ if lens_config. debug && can_debug && client_commands_config. debug_single {
1436+ let command = command:: debug_single ( & r) ;
1437+ acc. push ( lsp_types:: CodeLens {
1438+ range : annotation_range,
1439+ command : Some ( command) ,
1440+ data : None ,
1441+ } )
1442+ }
1443+ if lens_config. interpret {
1444+ let command = command:: interpret_single ( & r) ;
1445+ acc. push ( lsp_types:: CodeLens {
1446+ range : annotation_range,
1447+ command : Some ( command) ,
1448+ data : None ,
1449+ } )
1450+ }
14491451 }
14501452 }
14511453 AnnotationKind :: HasImpls { pos, data } => {
@@ -1575,7 +1577,7 @@ pub(crate) fn test_item(
15751577 . file
15761578 . map ( |f| lsp_types:: TextDocumentIdentifier { uri : url ( snap, f) } ) ,
15771579 range : line_index. and_then ( |l| Some ( range ( l, test_item. text_range ?) ) ) ,
1578- runnable : test_item. runnable . and_then ( |r| runnable ( snap, r) . ok ( ) ) ,
1580+ runnable : test_item. runnable . and_then ( |r| runnable ( snap, r) . ok ( ) ) . flatten ( ) ,
15791581 } )
15801582}
15811583
0 commit comments