File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,37 +102,29 @@ fn migrate_open_app_targets(value: &mut Value) {
102102 return ;
103103 } ;
104104
105- let default_targets = match serde_json:: to_value ( AppSettings :: default ( ) . open_app_targets ) {
106- Ok ( Value :: Array ( targets) ) => targets,
107- _ => return ,
108- } ;
109-
110- let existing_ids = existing_targets
105+ let has_phpstorm = existing_targets
111106 . iter ( )
112- . filter_map ( |target| target. get ( "id" ) . and_then ( Value :: as_str) )
113- . collect :: < std:: collections:: HashSet < _ > > ( ) ;
114-
115- let missing_targets: Vec < Value > = default_targets
116- . into_iter ( )
117- . filter ( |target| {
118- target
119- . get ( "id" )
120- . and_then ( Value :: as_str)
121- . map ( |id| !existing_ids. contains ( id) )
122- . unwrap_or ( false )
123- } )
124- . collect ( ) ;
125-
126- if missing_targets. is_empty ( ) {
107+ . any ( |target| target. get ( "id" ) . and_then ( Value :: as_str) == Some ( "phpstorm" ) ) ;
108+ if has_phpstorm {
127109 return ;
128110 }
129111
112+ let phpstorm_target = match serde_json:: to_value ( AppSettings :: default ( ) . open_app_targets ) {
113+ Ok ( Value :: Array ( targets) ) => targets
114+ . into_iter ( )
115+ . find ( |target| target. get ( "id" ) . and_then ( Value :: as_str) == Some ( "phpstorm" ) ) ,
116+ _ => None ,
117+ } ;
118+ let Some ( phpstorm_target) = phpstorm_target else {
119+ return ;
120+ } ;
121+
130122 let insert_at = existing_targets
131123 . iter ( )
132124 . position ( |target| target. get ( "id" ) . and_then ( Value :: as_str) == Some ( "finder" ) )
133125 . unwrap_or ( existing_targets. len ( ) ) ;
134126
135- existing_targets. splice ( insert_at..insert_at , missing_targets ) ;
127+ existing_targets. insert ( insert_at, phpstorm_target ) ;
136128}
137129
138130#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments