Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Saving a session always offers a free name and asks before replacing one (742)

gelenmedyabcb9504ad1ff
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index e7bd3aa3..85baa37d 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -1848,25 +1848,21 @@ impl Workspace {
cx.notify();
}
- /// Asks for a name and saves this window's tabs under it (`settings::NamedSession`). The name offered is the window's own
- /// session's, or the first "Oturum N" not taken; another session's name is replaced only after a second press of Kaydet, which
- /// the question asks for (issue 742: "Oturum 1" was offered again and the saved one replaced without a word).
+ /// Asks for a name and saves this window's tabs under it (`settings::NamedSession`). The name offered is always the first
+ /// "Oturum N" not taken, and a name that is taken - the window's own session's too - is replaced only after a second press of
+ /// Kaydet, which the question asks for (issue 742: "Oturum 1" was offered again and the saved one replaced without a word. Twice
+ /// the window's own session was let through as "an update"; the reporter read that as the same fault both times, and a save that
+ /// replaces something without asking is one, whatever the dialog's small print says).
fn save_named_session(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let (tabs, panes) = self.session_now(cx);
let active = self.active;
let taken: Vec<String> = cx.global::<crate::settings::Settings>().saved_sessions.iter().map(|s| s.name.clone()).collect();
- let first = self.session_name.clone().unwrap_or_else(|| free_session_name(&taken));
- let own = self.session_name.clone();
+ let first = free_session_name(&taken);
let asked = std::rc::Rc::new(std::cell::RefCell::new(None::<String>));
let me = cx.entity().downgrade();
crate::prompt::show(
t!("Oturumu kaydet"),
- // a window that holds a saved session updates it on Kaydet, and says so (issue 742: saving again replaced "Oturum 1" as if
- // by accident)
- Some(match &own {
- Some(name) => t!("Bu pencere «{name}» oturumu: Kaydet onu bu penceredeki sekmelerle günceller. Yeni bir oturum için başka bir ad yazın.").replace("{name}", name),
- None => t!("Bu penceredeki sekmeler bu adla kaydedilecek. Kaydedilen bir oturumu açmak için sekme menüsünden Oturum aç'ı seçin; yeni bir pencerede açılır.").to_string(),
- }),
+ Some(t!("Bu penceredeki sekmeler bu adla kaydedilecek. Kaydedilen bir oturumu açmak için sekme menüsünden Oturum aç'ı seçin; yeni bir pencerede açılır.").to_string()),
Some((first, String::new())),
vec![
crate::prompt::Button::new(t!("Kaydet"), crate::prompt::Kind::Primary, move |text, _, cx| {
@@ -1874,8 +1870,9 @@ impl Workspace {
if name.is_empty() {
return Err(t!("Bir ad yazın.").to_string());
}
- // another session of this name: replaced only when Kaydet is pressed again for the same name
- if taken.contains(&name) && own.as_deref() != Some(name.as_str()) && asked.borrow().as_deref() != Some(name.as_str()) {
+ // a session of this name: replaced only when Kaydet is pressed again for the same name
+ // (compared as the save itself compares names: without regard to case)
+ if taken.iter().any(|t| t.eq_ignore_ascii_case(&name)) && asked.borrow().as_deref() != Some(name.as_str()) {
*asked.borrow_mut() = Some(name.clone());
return Err(t!("Bu adla kaydedilmiş bir oturum var. Üzerine yazmak için yeniden Kaydet'e basın.").to_string());
}