@@ -404,7 +404,7 @@ pub fn handle_runnables(
404
404
continue ;
405
405
}
406
406
}
407
- if is_lib_target ( & runnable, cargo_spec. as_ref ( ) ) {
407
+ if should_skip_target ( & runnable, cargo_spec. as_ref ( ) ) {
408
408
continue ;
409
409
}
410
410
@@ -812,7 +812,7 @@ pub fn handle_code_lens(
812
812
if snap. config . lens . runnable ( ) {
813
813
// Gather runnables
814
814
for runnable in snap. analysis ( ) . runnables ( file_id) ? {
815
- if is_lib_target ( & runnable, cargo_spec. as_ref ( ) ) {
815
+ if should_skip_target ( & runnable, cargo_spec. as_ref ( ) ) {
816
816
continue ;
817
817
}
818
818
@@ -1185,6 +1185,11 @@ fn to_runnable_action(
1185
1185
file_id : FileId ,
1186
1186
runnable : & Runnable ,
1187
1187
) -> Option < lsp_ext:: CommandLinkGroup > {
1188
+ let cargo_spec = CargoTargetSpec :: for_file ( & snap, file_id) . ok ( ) ?;
1189
+ if should_skip_target ( runnable, cargo_spec. as_ref ( ) ) {
1190
+ return None ;
1191
+ }
1192
+
1188
1193
to_proto:: runnable ( snap, file_id, runnable) . ok ( ) . map ( |r| {
1189
1194
let mut group = lsp_ext:: CommandLinkGroup :: default ( ) ;
1190
1195
@@ -1222,16 +1227,18 @@ fn prepare_hover_actions(
1222
1227
. collect ( )
1223
1228
}
1224
1229
1225
- fn is_lib_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1226
- // Do not suggest binary run on other target than binary
1227
- if let RunnableKind :: Bin = runnable. kind {
1228
- if let Some ( spec) = cargo_spec {
1229
- match spec. target_kind {
1230
- TargetKind :: Bin => return true ,
1231
- _ => ( ) ,
1230
+ fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1231
+ match runnable. kind {
1232
+ RunnableKind :: Bin => {
1233
+ // Do not suggest binary run on other target than binary
1234
+ match & cargo_spec {
1235
+ Some ( spec) => match spec. target_kind {
1236
+ TargetKind :: Bin => false ,
1237
+ _ => true ,
1238
+ } ,
1239
+ None => true ,
1232
1240
}
1233
1241
}
1242
+ _ => false ,
1234
1243
}
1235
-
1236
- false
1237
1244
}
0 commit comments