@@ -5,9 +5,9 @@ use auto_update::AutoUpdater;
5
5
use editor:: Editor ;
6
6
use futures:: channel:: oneshot;
7
7
use gpui:: {
8
- percentage, px, Action , Animation , AnimationExt , AnyWindowHandle , AsyncAppContext ,
9
- DismissEvent , EventEmitter , FocusableView , ParentElement as _, Render , SemanticVersion ,
10
- SharedString , Task , Transformation , View ,
8
+ percentage, px, Animation , AnimationExt , AnyWindowHandle , AsyncAppContext , DismissEvent ,
9
+ EventEmitter , FocusableView , ParentElement as _, Render , SemanticVersion , SharedString , Task ,
10
+ Transformation , View ,
11
11
} ;
12
12
use gpui:: { AppContext , Model } ;
13
13
use release_channel:: { AppVersion , ReleaseChannel } ;
@@ -83,6 +83,7 @@ pub struct SshPrompt {
83
83
84
84
pub struct SshConnectionModal {
85
85
pub ( crate ) prompt : View < SshPrompt > ,
86
+ is_separate_window : bool ,
86
87
}
87
88
88
89
impl SshPrompt {
@@ -207,9 +208,14 @@ impl Render for SshPrompt {
207
208
}
208
209
209
210
impl SshConnectionModal {
210
- pub fn new ( connection_options : & SshConnectionOptions , cx : & mut ViewContext < Self > ) -> Self {
211
+ pub fn new (
212
+ connection_options : & SshConnectionOptions ,
213
+ is_separate_window : bool ,
214
+ cx : & mut ViewContext < Self > ,
215
+ ) -> Self {
211
216
Self {
212
217
prompt : cx. new_view ( |cx| SshPrompt :: new ( connection_options, cx) ) ,
218
+ is_separate_window,
213
219
}
214
220
}
215
221
@@ -218,7 +224,10 @@ impl SshConnectionModal {
218
224
}
219
225
220
226
fn dismiss ( & mut self , _: & menu:: Cancel , cx : & mut ViewContext < Self > ) {
221
- cx. remove_window ( ) ;
227
+ cx. emit ( DismissEvent ) ;
228
+ if self . is_separate_window {
229
+ cx. remove_window ( ) ;
230
+ }
222
231
}
223
232
}
224
233
@@ -232,6 +241,7 @@ impl Render for SshConnectionModal {
232
241
233
242
v_flex ( )
234
243
. elevation_3 ( cx)
244
+ . track_focus ( & self . focus_handle ( cx) )
235
245
. on_action ( cx. listener ( Self :: dismiss) )
236
246
. on_action ( cx. listener ( Self :: confirm) )
237
247
. w ( px ( 500. ) )
@@ -250,7 +260,9 @@ impl Render for SshConnectionModal {
250
260
div ( ) . absolute ( ) . left_0p5 ( ) . top_0p5 ( ) . child (
251
261
IconButton :: new ( "ssh-connection-cancel" , IconName :: ArrowLeft )
252
262
. icon_size ( IconSize :: XSmall )
253
- . on_click ( |_, cx| cx. dispatch_action ( menu:: Cancel . boxed_clone ( ) ) )
263
+ . on_click ( cx. listener ( move |this, _, cx| {
264
+ this. dismiss ( & Default :: default ( ) , cx) ;
265
+ } ) )
254
266
. tooltip ( |cx| Tooltip :: for_action ( "Back" , & menu:: Cancel , cx) ) ,
255
267
) ,
256
268
)
@@ -464,11 +476,10 @@ pub async fn open_ssh_project(
464
476
open_options : workspace:: OpenOptions ,
465
477
cx : & mut AsyncAppContext ,
466
478
) -> Result < ( ) > {
467
- let options = cx. update ( |cx| ( app_state. build_window_options ) ( None , cx) ) ?;
468
-
469
479
let window = if let Some ( window) = open_options. replace_window {
470
480
window
471
481
} else {
482
+ let options = cx. update ( |cx| ( app_state. build_window_options ) ( None , cx) ) ?;
472
483
cx. open_window ( options, |cx| {
473
484
let project = project:: Project :: local (
474
485
app_state. client . clone ( ) ,
@@ -485,7 +496,9 @@ pub async fn open_ssh_project(
485
496
486
497
let delegate = window. update ( cx, |workspace, cx| {
487
498
cx. activate_window ( ) ;
488
- workspace. toggle_modal ( cx, |cx| SshConnectionModal :: new ( & connection_options, cx) ) ;
499
+ workspace. toggle_modal ( cx, |cx| {
500
+ SshConnectionModal :: new ( & connection_options, true , cx)
501
+ } ) ;
489
502
let ui = workspace
490
503
. active_modal :: < SshConnectionModal > ( cx)
491
504
. unwrap ( )
@@ -500,8 +513,11 @@ pub async fn open_ssh_project(
500
513
} )
501
514
} ) ?;
502
515
503
- cx. update ( |cx| {
504
- workspace:: open_ssh_project ( window, connection_options, delegate, app_state, paths, cx)
505
- } ) ?
506
- . await
516
+ let did_open_ssh_project = cx
517
+ . update ( |cx| {
518
+ workspace:: open_ssh_project ( window, connection_options, delegate, app_state, paths, cx)
519
+ } ) ?
520
+ . await ;
521
+
522
+ did_open_ssh_project
507
523
}
0 commit comments