@@ -32,7 +32,7 @@ use paths::Utf8PathBuf;
32
32
use project_model:: { CargoWorkspace , ManifestPath , ProjectWorkspaceKind , TargetKind } ;
33
33
use serde_json:: json;
34
34
use stdx:: { format_to, never} ;
35
- use syntax:: { algo , ast , AstNode , TextRange , TextSize } ;
35
+ use syntax:: { TextRange , TextSize } ;
36
36
use triomphe:: Arc ;
37
37
use vfs:: { AbsPath , AbsPathBuf , FileId , VfsPath } ;
38
38
@@ -933,39 +933,31 @@ pub(crate) fn handle_runnables(
933
933
let offset = params. position . and_then ( |it| from_proto:: offset ( & line_index, it) . ok ( ) ) ;
934
934
let target_spec = TargetSpec :: for_file ( & snap, file_id) ?;
935
935
936
- let expect_test = match offset {
937
- Some ( offset) => {
938
- let source_file = snap. analysis . parse ( file_id) ?;
939
- algo:: find_node_at_offset :: < ast:: MacroCall > ( source_file. syntax ( ) , offset)
940
- . and_then ( |it| it. path ( ) ?. segment ( ) ?. name_ref ( ) )
941
- . map_or ( false , |it| it. text ( ) == "expect" || it. text ( ) == "expect_file" )
942
- }
943
- None => false ,
944
- } ;
945
-
946
936
let mut res = Vec :: new ( ) ;
947
937
for runnable in snap. analysis . runnables ( file_id) ? {
948
- if should_skip_for_offset ( & runnable, offset) {
949
- continue ;
950
- }
951
- if should_skip_target ( & runnable, target_spec. as_ref ( ) ) {
938
+ if should_skip_for_offset ( & runnable, offset)
939
+ || should_skip_target ( & runnable, target_spec. as_ref ( ) )
940
+ {
952
941
continue ;
953
942
}
943
+
944
+ let update_test = runnable. update_test ;
954
945
if let Some ( mut runnable) = to_proto:: runnable ( & snap, runnable) ? {
955
- if expect_test {
956
- if let lsp_ext:: RunnableArgs :: Cargo ( r) = & mut runnable. args {
957
- runnable. label = format ! ( "{} + expect" , runnable. label) ;
958
- r. environment . insert ( "UPDATE_EXPECT" . to_owned ( ) , "1" . to_owned ( ) ) ;
959
- if let Some ( TargetSpec :: Cargo ( CargoTargetSpec {
960
- sysroot_root : Some ( sysroot_root) ,
961
- ..
962
- } ) ) = & target_spec
963
- {
964
- r. environment
965
- . insert ( "RUSTC_TOOLCHAIN" . to_owned ( ) , sysroot_root. to_string ( ) ) ;
966
- }
967
- }
946
+ if let Some ( runnable) = to_proto:: make_update_runnable ( & runnable, & update_test. label ( ) )
947
+ {
948
+ res. push ( runnable) ;
968
949
}
950
+
951
+ if let lsp_ext:: RunnableArgs :: Cargo ( r) = & mut runnable. args {
952
+ if let Some ( TargetSpec :: Cargo ( CargoTargetSpec {
953
+ sysroot_root : Some ( sysroot_root) ,
954
+ ..
955
+ } ) ) = & target_spec
956
+ {
957
+ r. environment . insert ( "RUSTC_TOOLCHAIN" . to_owned ( ) , sysroot_root. to_string ( ) ) ;
958
+ }
959
+ } ;
960
+
969
961
res. push ( runnable) ;
970
962
}
971
963
}
@@ -2143,11 +2135,15 @@ fn runnable_action_links(
2143
2135
}
2144
2136
2145
2137
let client_commands_config = snap. config . client_commands ( ) ;
2146
- if !( client_commands_config. run_single || client_commands_config. debug_single ) {
2138
+ if !( client_commands_config. run_single
2139
+ || client_commands_config. debug_single
2140
+ || client_commands_config. update_single )
2141
+ {
2147
2142
return None ;
2148
2143
}
2149
2144
2150
2145
let title = runnable. title ( ) ;
2146
+ let update_test = runnable. update_test ;
2151
2147
let r = to_proto:: runnable ( snap, runnable) . ok ( ) ??;
2152
2148
2153
2149
let mut group = lsp_ext:: CommandLinkGroup :: default ( ) ;
@@ -2159,7 +2155,13 @@ fn runnable_action_links(
2159
2155
2160
2156
if hover_actions_config. debug && client_commands_config. debug_single {
2161
2157
let dbg_command = to_proto:: command:: debug_single ( & r) ;
2162
- group. commands . push ( to_command_link ( dbg_command, r. label ) ) ;
2158
+ group. commands . push ( to_command_link ( dbg_command, r. label . clone ( ) ) ) ;
2159
+ }
2160
+
2161
+ if client_commands_config. update_single {
2162
+ if let Some ( update_command) = to_proto:: command:: update_single ( & r, & update_test. label ( ) ) {
2163
+ group. commands . push ( to_command_link ( update_command, r. label . clone ( ) ) ) ;
2164
+ }
2163
2165
}
2164
2166
2165
2167
Some ( group)
0 commit comments