Rework file picker for SSH modal (#19020)

This PR changes the SSH modal design so its more keyboard
navigation-friendly and adds the server nickname feature.

Release Notes:

- N/A

---------

Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
This commit is contained in:
Piotr Osiewicz 2024-10-15 12:38:03 +02:00 committed by GitHub
parent be7b24fcf7
commit db7417f3b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 871 additions and 491 deletions

View file

@ -5,6 +5,8 @@ mod file_finder_settings;
mod new_path_prompt;
mod open_path_prompt;
pub use open_path_prompt::OpenPathDelegate;
use collections::HashMap;
use editor::{scroll::Autoscroll, Bias, Editor};
use file_finder_settings::FileFinderSettings;

View file

@ -26,6 +26,20 @@ pub struct OpenPathDelegate {
should_dismiss: bool,
}
impl OpenPathDelegate {
pub fn new(tx: oneshot::Sender<Option<Vec<PathBuf>>>, lister: DirectoryLister) -> Self {
Self {
tx: Some(tx),
lister,
selected_index: 0,
directory_state: None,
matches: Vec::new(),
cancel_flag: Arc::new(AtomicBool::new(false)),
should_dismiss: true,
}
}
}
struct DirectoryState {
path: String,
match_candidates: Vec<StringMatchCandidate>,
@ -48,15 +62,7 @@ impl OpenPathPrompt {
cx: &mut ViewContext<Workspace>,
) {
workspace.toggle_modal(cx, |cx| {
let delegate = OpenPathDelegate {
tx: Some(tx),
lister: lister.clone(),
selected_index: 0,
directory_state: None,
matches: Vec::new(),
cancel_flag: Arc::new(AtomicBool::new(false)),
should_dismiss: true,
};
let delegate = OpenPathDelegate::new(tx, lister.clone());
let picker = Picker::uniform_list(delegate, cx).width(rems(34.));
let query = lister.default_query(cx);