@@ -14,13 +14,13 @@ use ide::{
1414 InlayFieldsToResolve , InlayHint , InlayHintLabel , InlayHintLabelPart , InlayKind , LazyProperty ,
1515 Markup , NavigationTarget , ReferenceCategory , RenameError , Runnable , Severity , SignatureHelp ,
1616 SnippetEdit , SourceChange , StructureNodeKind , SymbolKind , TextEdit , TextRange , TextSize ,
17+ UpdateTest ,
1718} ;
1819use ide_db:: { assists, rust_doc:: format_docs, FxHasher } ;
1920use itertools:: Itertools ;
2021use paths:: { Utf8Component , Utf8Prefix } ;
2122use semver:: VersionReq ;
2223use serde_json:: to_value;
23- use syntax:: SmolStr ;
2424use vfs:: AbsPath ;
2525
2626use crate :: {
@@ -1623,8 +1623,7 @@ pub(crate) fn code_lens(
16231623 }
16241624 if lens_config. update_test && client_commands_config. run_single {
16251625 let label = update_test. label ( ) ;
1626- let env = update_test. env ( ) ;
1627- if let Some ( r) = make_update_runnable ( & r, & label, & env) {
1626+ if let Some ( r) = make_update_runnable ( & r, update_test) {
16281627 let command = command:: run_single ( & r, label. unwrap ( ) . as_str ( ) ) ;
16291628 acc. push ( lsp_types:: CodeLens {
16301629 range : annotation_range,
@@ -1871,22 +1870,22 @@ pub(crate) mod command {
18711870
18721871pub ( crate ) fn make_update_runnable (
18731872 runnable : & lsp_ext:: Runnable ,
1874- label : & Option < SmolStr > ,
1875- env : & [ ( & str , & str ) ] ,
1873+ update_test : UpdateTest ,
18761874) -> Option < lsp_ext:: Runnable > {
1877- if !matches ! ( runnable. args, lsp_ext:: RunnableArgs :: Cargo ( _) ) {
1878- return None ;
1879- }
1880- let label = label. as_ref ( ) ?;
1875+ let label = update_test. label ( ) ?;
18811876
18821877 let mut runnable = runnable. clone ( ) ;
18831878 runnable. label = format ! ( "{} + {}" , runnable. label, label) ;
18841879
18851880 let lsp_ext:: RunnableArgs :: Cargo ( r) = & mut runnable. args else {
1886- unreachable ! ( ) ;
1881+ return None ;
18871882 } ;
18881883
1889- r. environment . extend ( env. iter ( ) . map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) ) ) ;
1884+ r. environment . extend ( update_test. env ( ) . iter ( ) . map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) ) ) ;
1885+
1886+ if update_test. insta {
1887+ r. cargo_args . insert ( 0 , "insta" . to_owned ( ) ) ;
1888+ }
18901889
18911890 Some ( runnable)
18921891}
0 commit comments