@@ -5,9 +5,9 @@ use auto_update::AutoUpdater;
55use editor:: Editor ;
66use futures:: channel:: oneshot;
77use 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 ,
1111} ;
1212use gpui:: { AppContext , Model } ;
1313use release_channel:: { AppVersion , ReleaseChannel } ;
@@ -83,6 +83,7 @@ pub struct SshPrompt {
8383
8484pub struct SshConnectionModal {
8585 pub ( crate ) prompt : View < SshPrompt > ,
86+ is_separate_window : bool ,
8687}
8788
8889impl SshPrompt {
@@ -207,9 +208,14 @@ impl Render for SshPrompt {
207208}
208209
209210impl 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 {
211216 Self {
212217 prompt : cx. new_view ( |cx| SshPrompt :: new ( connection_options, cx) ) ,
218+ is_separate_window,
213219 }
214220 }
215221
@@ -218,7 +224,10 @@ impl SshConnectionModal {
218224 }
219225
220226 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+ }
222231 }
223232}
224233
@@ -232,6 +241,7 @@ impl Render for SshConnectionModal {
232241
233242 v_flex ( )
234243 . elevation_3 ( cx)
244+ . track_focus ( & self . focus_handle ( cx) )
235245 . on_action ( cx. listener ( Self :: dismiss) )
236246 . on_action ( cx. listener ( Self :: confirm) )
237247 . w ( px ( 500. ) )
@@ -250,7 +260,9 @@ impl Render for SshConnectionModal {
250260 div ( ) . absolute ( ) . left_0p5 ( ) . top_0p5 ( ) . child (
251261 IconButton :: new ( "ssh-connection-cancel" , IconName :: ArrowLeft )
252262 . 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+ } ) )
254266 . tooltip ( |cx| Tooltip :: for_action ( "Back" , & menu:: Cancel , cx) ) ,
255267 ) ,
256268 )
@@ -464,11 +476,10 @@ pub async fn open_ssh_project(
464476 open_options : workspace:: OpenOptions ,
465477 cx : & mut AsyncAppContext ,
466478) -> Result < ( ) > {
467- let options = cx. update ( |cx| ( app_state. build_window_options ) ( None , cx) ) ?;
468-
469479 let window = if let Some ( window) = open_options. replace_window {
470480 window
471481 } else {
482+ let options = cx. update ( |cx| ( app_state. build_window_options ) ( None , cx) ) ?;
472483 cx. open_window ( options, |cx| {
473484 let project = project:: Project :: local (
474485 app_state. client . clone ( ) ,
@@ -485,7 +496,9 @@ pub async fn open_ssh_project(
485496
486497 let delegate = window. update ( cx, |workspace, cx| {
487498 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+ } ) ;
489502 let ui = workspace
490503 . active_modal :: < SshConnectionModal > ( cx)
491504 . unwrap ( )
@@ -500,8 +513,11 @@ pub async fn open_ssh_project(
500513 } )
501514 } ) ?;
502515
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
507523}
0 commit comments