@@ -897,21 +897,23 @@ pub(crate) fn handle_runnables(
897
897
Some ( TargetSpec :: ProjectJson ( _) ) => { }
898
898
None => {
899
899
if !snap. config . linked_or_discovered_projects ( ) . is_empty ( ) {
900
- let mut cargo_args = vec ! [ "check" . to_owned( ) , "--workspace" . to_owned( ) ] ;
901
- cargo_args. extend ( config. cargo_extra_args . iter ( ) . cloned ( ) ) ;
902
- res. push ( lsp_ext:: Runnable {
903
- label : "cargo check --workspace" . to_owned ( ) ,
904
- location : None ,
905
- kind : lsp_ext:: RunnableKind :: Cargo ,
906
- args : lsp_ext:: RunnableArgs :: Cargo ( lsp_ext:: CargoRunnableArgs {
907
- workspace_root : None ,
908
- cwd : "." . into ( ) ,
909
- override_cargo : config. override_cargo ,
910
- cargo_args,
911
- executable_args : Vec :: new ( ) ,
912
- environment : Default :: default ( ) ,
913
- } ) ,
914
- } ) ;
900
+ if let Some ( path) = snap. file_id_to_file_path ( file_id) . parent ( ) {
901
+ let mut cargo_args = vec ! [ "check" . to_owned( ) , "--workspace" . to_owned( ) ] ;
902
+ cargo_args. extend ( config. cargo_extra_args . iter ( ) . cloned ( ) ) ;
903
+ res. push ( lsp_ext:: Runnable {
904
+ label : "cargo check --workspace" . to_owned ( ) ,
905
+ location : None ,
906
+ kind : lsp_ext:: RunnableKind :: Cargo ,
907
+ args : lsp_ext:: RunnableArgs :: Cargo ( lsp_ext:: CargoRunnableArgs {
908
+ workspace_root : None ,
909
+ cwd : path. as_path ( ) . unwrap ( ) . to_path_buf ( ) . into ( ) ,
910
+ override_cargo : config. override_cargo ,
911
+ cargo_args,
912
+ executable_args : Vec :: new ( ) ,
913
+ environment : Default :: default ( ) ,
914
+ } ) ,
915
+ } ) ;
916
+ } ;
915
917
}
916
918
}
917
919
}
0 commit comments