Allow opening the FS root dir as a remote project (#30190)
### Todo * [x] Allow opening `ssh://username@host:/` from the CLI * [x] Allow selecting `/` in the `open path` picker * [x] Allow selecting the home directory in the `open path` picker Release Notes: - Changed the initial state of the SSH project picker to show the full path to your home directory on the remote machine, instead of `~`. - Added the ability to open `/` as a project folder over SSH --------- Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
parent
6ac2f4e6a5
commit
37010aac6b
7 changed files with 98 additions and 54 deletions
|
@ -1,7 +1,7 @@
|
|||
use futures::channel::oneshot;
|
||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
use project::DirectoryLister;
|
||||
use project::{DirectoryItem, DirectoryLister};
|
||||
use std::{
|
||||
path::{MAIN_SEPARATOR_STR, Path, PathBuf},
|
||||
sync::{
|
||||
|
@ -137,6 +137,7 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
} else {
|
||||
(query, String::new())
|
||||
};
|
||||
|
||||
if dir == "" {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
|
@ -171,6 +172,13 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
this.update(cx, |this, _| {
|
||||
this.delegate.directory_state = Some(match paths {
|
||||
Ok(mut paths) => {
|
||||
if dir == "/" {
|
||||
paths.push(DirectoryItem {
|
||||
is_dir: true,
|
||||
path: Default::default(),
|
||||
});
|
||||
}
|
||||
|
||||
paths.sort_by(|a, b| compare_paths((&a.path, true), (&b.path, true)));
|
||||
let match_candidates = paths
|
||||
.iter()
|
||||
|
@ -309,12 +317,16 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
let Some(candidate) = directory_state.match_candidates.get(*m) else {
|
||||
return;
|
||||
};
|
||||
let result = Path::new(
|
||||
self.lister
|
||||
.resolve_tilde(&directory_state.path, cx)
|
||||
.as_ref(),
|
||||
)
|
||||
.join(&candidate.path.string);
|
||||
let result = if directory_state.path == "/" && candidate.path.string.is_empty() {
|
||||
PathBuf::from("/")
|
||||
} else {
|
||||
Path::new(
|
||||
self.lister
|
||||
.resolve_tilde(&directory_state.path, cx)
|
||||
.as_ref(),
|
||||
)
|
||||
.join(&candidate.path.string)
|
||||
};
|
||||
if let Some(tx) = self.tx.take() {
|
||||
tx.send(Some(vec![result])).ok();
|
||||
}
|
||||
|
@ -355,7 +367,11 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
.inset(true)
|
||||
.toggle_state(selected)
|
||||
.child(HighlightedLabel::new(
|
||||
candidate.path.string.clone(),
|
||||
if directory_state.path == "/" {
|
||||
format!("/{}", candidate.path.string)
|
||||
} else {
|
||||
candidate.path.string.clone()
|
||||
},
|
||||
highlight_positions,
|
||||
)),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue