@@ -487,7 +487,7 @@ impl DirectoryLister {
487
487
pub fn is_local ( & self , cx : & AppContext ) -> bool {
488
488
match self {
489
489
DirectoryLister :: Local ( _) => true ,
490
- DirectoryLister :: Project ( project) => project. read ( cx) . is_local_or_ssh ( ) ,
490
+ DirectoryLister :: Project ( project) => project. read ( cx) . is_local ( ) ,
491
491
}
492
492
}
493
493
@@ -1199,7 +1199,13 @@ impl Project {
1199
1199
self . dev_server_project_id
1200
1200
}
1201
1201
1202
- pub fn supports_remote_terminal ( & self , cx : & AppContext ) -> bool {
1202
+ pub fn supports_terminal ( & self , cx : & AppContext ) -> bool {
1203
+ if self . is_local ( ) {
1204
+ return true ;
1205
+ }
1206
+ if self . is_via_ssh ( ) {
1207
+ return true ;
1208
+ }
1203
1209
let Some ( id) = self . dev_server_project_id else {
1204
1210
return false ;
1205
1211
} ;
@@ -1213,10 +1219,6 @@ impl Project {
1213
1219
}
1214
1220
1215
1221
pub fn ssh_connection_string ( & self , cx : & ModelContext < Self > ) -> Option < SharedString > {
1216
- if self . is_local_or_ssh ( ) {
1217
- return None ;
1218
- }
1219
-
1220
1222
let dev_server_id = self . dev_server_project_id ( ) ?;
1221
1223
dev_server_projects:: Store :: global ( cx)
1222
1224
. read ( cx)
@@ -1643,13 +1645,6 @@ impl Project {
1643
1645
}
1644
1646
}
1645
1647
1646
- pub fn is_local_or_ssh ( & self ) -> bool {
1647
- match & self . client_state {
1648
- ProjectClientState :: Local | ProjectClientState :: Shared { .. } => true ,
1649
- ProjectClientState :: Remote { .. } => false ,
1650
- }
1651
- }
1652
-
1653
1648
pub fn is_via_ssh ( & self ) -> bool {
1654
1649
match & self . client_state {
1655
1650
ProjectClientState :: Local | ProjectClientState :: Shared { .. } => {
@@ -1735,7 +1730,7 @@ impl Project {
1735
1730
) -> Task < Result < Model < Buffer > > > {
1736
1731
if let Some ( buffer) = self . buffer_for_id ( id, cx) {
1737
1732
Task :: ready ( Ok ( buffer) )
1738
- } else if self . is_local_or_ssh ( ) {
1733
+ } else if self . is_local ( ) || self . is_via_ssh ( ) {
1739
1734
Task :: ready ( Err ( anyhow ! ( "buffer {} does not exist" , id) ) )
1740
1735
} else if let Some ( project_id) = self . remote_id ( ) {
1741
1736
let request = self . client . request ( proto:: OpenBufferById {
@@ -1857,7 +1852,7 @@ impl Project {
1857
1852
let mut changes = rx. ready_chunks ( MAX_BATCH_SIZE ) ;
1858
1853
1859
1854
while let Some ( changes) = changes. next ( ) . await {
1860
- let is_local = this. update ( & mut cx, |this, _| this. is_local_or_ssh ( ) ) ?;
1855
+ let is_local = this. update ( & mut cx, |this, _| this. is_local ( ) ) ?;
1861
1856
1862
1857
for change in changes {
1863
1858
match change {
@@ -2001,7 +1996,7 @@ impl Project {
2001
1996
language_server_id,
2002
1997
message,
2003
1998
} => {
2004
- if self . is_local_or_ssh ( ) {
1999
+ if self . is_local ( ) {
2005
2000
self . enqueue_buffer_ordered_message (
2006
2001
BufferOrderedMessage :: LanguageServerUpdate {
2007
2002
language_server_id : * language_server_id,
@@ -3039,8 +3034,19 @@ impl Project {
3039
3034
query : String ,
3040
3035
cx : & mut ModelContext < Self > ,
3041
3036
) -> Task < Result < Vec < PathBuf > > > {
3042
- if self . is_local_or_ssh ( ) {
3037
+ if self . is_local ( ) {
3043
3038
DirectoryLister :: Local ( self . fs . clone ( ) ) . list_directory ( query, cx)
3039
+ } else if let Some ( session) = self . ssh_session . as_ref ( ) {
3040
+ let request = proto:: ListRemoteDirectory {
3041
+ dev_server_id : SSH_PROJECT_ID ,
3042
+ path : query,
3043
+ } ;
3044
+
3045
+ let response = session. request ( request) ;
3046
+ cx. background_executor ( ) . spawn ( async move {
3047
+ let response = response. await ?;
3048
+ Ok ( response. entries . into_iter ( ) . map ( PathBuf :: from) . collect ( ) )
3049
+ } )
3044
3050
} else if let Some ( dev_server) = self . dev_server_project_id ( ) . and_then ( |id| {
3045
3051
dev_server_projects:: Store :: global ( cx)
3046
3052
. read ( cx)
@@ -3317,7 +3323,7 @@ impl Project {
3317
3323
mut cx : AsyncAppContext ,
3318
3324
) -> Result < ( ) > {
3319
3325
this. update ( & mut cx, |this, cx| {
3320
- if this. is_local_or_ssh ( ) {
3326
+ if this. is_local ( ) || this . is_via_ssh ( ) {
3321
3327
this. unshare ( cx) ?;
3322
3328
} else {
3323
3329
this. disconnected_from_host ( cx) ;
@@ -3995,7 +4001,7 @@ impl Project {
3995
4001
location : Location ,
3996
4002
cx : & mut ModelContext < ' _ , Project > ,
3997
4003
) -> Task < Option < TaskContext > > {
3998
- if self . is_local_or_ssh ( ) {
4004
+ if self . is_local ( ) {
3999
4005
let ( worktree_id, worktree_abs_path) = if let Some ( worktree) = self . task_worktree ( cx) {
4000
4006
(
4001
4007
Some ( worktree. read ( cx) . id ( ) ) ,
@@ -4081,7 +4087,7 @@ impl Project {
4081
4087
location : Option < Location > ,
4082
4088
cx : & mut ModelContext < Self > ,
4083
4089
) -> Task < Result < Vec < ( TaskSourceKind , TaskTemplate ) > > > {
4084
- if self . is_local_or_ssh ( ) {
4090
+ if self . is_local ( ) {
4085
4091
let ( file, language) = location
4086
4092
. map ( |location| {
4087
4093
let buffer = location. buffer . read ( cx) ;
0 commit comments