Remove 'Destructive' prompts (#11631)

While these would match how macOS handles this scenario, they crash on
Catalina, and require mouse clicks to interact.

cc @bennetbo



Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-05-09 18:52:09 -06:00 committed by GitHub
parent 901cb8b3d2
commit 0c2d71f1ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 4 additions and 14 deletions

View file

@ -334,7 +334,7 @@ impl PickerDelegate for NewPathDelegate {
if exists { if exists {
self.should_dismiss = false; self.should_dismiss = false;
let answer = cx.prompt( let answer = cx.prompt(
gpui::PromptLevel::Destructive, gpui::PromptLevel::Critical,
&format!("{} already exists. Do you want to replace it?", m.relative_path()), &format!("{} already exists. Do you want to replace it?", m.relative_path()),
Some( Some(
"A file or folder with the same name already eixsts. Replacing it will overwrite its current contents.", "A file or folder with the same name already eixsts. Replacing it will overwrite its current contents.",

View file

@ -719,10 +719,6 @@ pub enum PromptLevel {
/// A prompt that is shown when a critical problem has occurred /// A prompt that is shown when a critical problem has occurred
Critical, Critical,
/// A prompt that is shown when asking the user to confirm a potentially destructive action
/// (overwriting a file for example)
Destructive,
} }
/// The style of the cursor (pointer) /// The style of the cursor (pointer)

View file

@ -890,7 +890,7 @@ impl PlatformWindow for MacWindow {
let alert_style = match level { let alert_style = match level {
PromptLevel::Info => 1, PromptLevel::Info => 1,
PromptLevel::Warning => 0, PromptLevel::Warning => 0,
PromptLevel::Critical | PromptLevel::Destructive => 2, PromptLevel::Critical => 2,
}; };
let _: () = msg_send![alert, setAlertStyle: alert_style]; let _: () = msg_send![alert, setAlertStyle: alert_style];
let _: () = msg_send![alert, setMessageText: ns_string(msg)]; let _: () = msg_send![alert, setMessageText: ns_string(msg)];
@ -905,16 +905,10 @@ impl PlatformWindow for MacWindow {
{ {
let button: id = msg_send![alert, addButtonWithTitle: ns_string(answer)]; let button: id = msg_send![alert, addButtonWithTitle: ns_string(answer)];
let _: () = msg_send![button, setTag: ix as NSInteger]; let _: () = msg_send![button, setTag: ix as NSInteger];
if level == PromptLevel::Destructive && answer != &"Cancel" {
let _: () = msg_send![button, setHasDestructiveAction: YES];
}
} }
if let Some((ix, answer)) = latest_non_cancel_label { if let Some((ix, answer)) = latest_non_cancel_label {
let button: id = msg_send![alert, addButtonWithTitle: ns_string(answer)]; let button: id = msg_send![alert, addButtonWithTitle: ns_string(answer)];
let _: () = msg_send![button, setTag: ix as NSInteger]; let _: () = msg_send![button, setTag: ix as NSInteger];
if level == PromptLevel::Destructive {
let _: () = msg_send![button, setHasDestructiveAction: YES];
}
} }
let (done_tx, done_rx) = oneshot::channel(); let (done_tx, done_rx) = oneshot::channel();

View file

@ -437,7 +437,7 @@ impl PlatformWindow for WindowsWindow {
title = windows::core::w!("Warning"); title = windows::core::w!("Warning");
main_icon = TD_WARNING_ICON; main_icon = TD_WARNING_ICON;
} }
crate::PromptLevel::Critical | crate::PromptLevel::Destructive => { crate::PromptLevel::Critical => {
title = windows::core::w!("Critical"); title = windows::core::w!("Critical");
main_icon = TD_ERROR_ICON; main_icon = TD_ERROR_ICON;
} }

View file

@ -263,7 +263,7 @@ impl Render for LanguageServerPrompt {
PromptLevel::Warning => { PromptLevel::Warning => {
Some(DiagnosticSeverity::WARNING) Some(DiagnosticSeverity::WARNING)
} }
PromptLevel::Critical | PromptLevel::Destructive => { PromptLevel::Critical => {
Some(DiagnosticSeverity::ERROR) Some(DiagnosticSeverity::ERROR)
} }
} }