diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 2380049da70849b8abf50ef030f48b1714c0a271..19b3ac850efb596778a5958a84e71124dc941bdd 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -7,7 +7,6 @@ pub mod fs_watcher; use anyhow::{Context as _, Result, anyhow}; #[cfg(any(target_os = "linux", target_os = "freebsd"))] use ashpd::desktop::trash; -use encodings::Encoding; use futures::stream::iter; use gpui::App; use gpui::BackgroundExecutor; diff --git a/crates/project/src/invalid_item_view.rs b/crates/project/src/invalid_item_view.rs index 208cf05c48d27b9ebe9205081843a22c326f6974..c5dfd6436f8a0a669db18024eba7ae2ef4b7cc21 100644 --- a/crates/project/src/invalid_item_view.rs +++ b/crates/project/src/invalid_item_view.rs @@ -78,8 +78,6 @@ impl Focusable for InvalidItemView { impl Render for InvalidItemView { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl gpui::IntoElement { let abs_path = self.abs_path.clone(); - let path0 = self.abs_path.clone(); - let path1 = self.abs_path.clone(); v_flex() .size_full() @@ -103,63 +101,20 @@ impl Render for InvalidItemView { ), ) .when(self.is_local, |contents| { - contents - .child( - h_flex().justify_center().child( - Button::new("open-with-system", "Open in Default App") - .on_click(move |_, _, cx| { - cx.open_with_system(&abs_path); - }) - .style(ButtonStyle::Outlined) - .key_binding(KeyBinding::for_action( - &OpenWithSystem, - window, - cx, - )), - ), - ) - .child( - h_flex() - .justify_center() - .child( - Button::new( - "open-with-encoding", - "Open With a Different Encoding", - ) - .style(ButtonStyle::Outlined) - .on_click( - move |_, window, cx| { - window.dispatch_action( - Box::new( - zed_actions::encodings_ui::Toggle( - path0.clone(), - ), - ), - cx, - ) - }, - ), - ) - .child( - Button::new( - "accept-risk-and-open", - "Accept the Risk and Open", - ) - .style(ButtonStyle::Tinted(TintColor::Warning)) - .on_click( - move |_, window, cx| { - window.dispatch_action( - Box::new( - zed_actions::encodings_ui::ForceOpen( - path1.clone(), - ), - ), - cx, - ); - }, - ), - ), - ) + contents.child( + h_flex().justify_center().child( + Button::new("open-with-system", "Open in Default App") + .on_click(move |_, _, cx| { + cx.open_with_system(&abs_path); + }) + .style(ButtonStyle::Outlined) + .key_binding(KeyBinding::for_action( + &OpenWithSystem, + window, + cx, + )), + ), + ) }), ), ) diff --git a/crates/workspace/src/invalid_item_view.rs b/crates/workspace/src/invalid_item_view.rs index eb6c8f3299838c1a01777885009fa67271b924d7..75dcf768a16c2d00c8239a95997421b4bab00e90 100644 --- a/crates/workspace/src/invalid_item_view.rs +++ b/crates/workspace/src/invalid_item_view.rs @@ -1,6 +1,7 @@ use std::{path::Path, sync::Arc}; +use ui::TintColor; -use gpui::{EventEmitter, FocusHandle, Focusable}; +use gpui::{EventEmitter, FocusHandle, Focusable, div}; use ui::{ App, Button, ButtonCommon, ButtonStyle, Clickable, Context, FluentBuilder, InteractiveElement, KeyBinding, Label, LabelCommon, LabelSize, ParentElement, Render, SharedString, Styled as _, @@ -77,6 +78,9 @@ impl Focusable for InvalidItemView { impl Render for InvalidItemView { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl gpui::IntoElement { let abs_path = self.abs_path.clone(); + let path0 = self.abs_path.clone(); + let path1 = self.abs_path.clone(); + v_flex() .size_full() .track_focus(&self.focus_handle(cx)) @@ -91,21 +95,70 @@ impl Render for InvalidItemView { .gap_2() .child(h_flex().justify_center().child("Could not open file")) .child( - h_flex() - .justify_center() - .child(Label::new(self.error.clone()).size(LabelSize::Small)), + h_flex().justify_center().child( + div() + .whitespace_normal() + .text_center() + .child(Label::new(self.error.clone()).size(LabelSize::Small)), + ), ) .when(self.is_local, |contents| { - contents.child( - h_flex().justify_center().child( - Button::new("open-with-system", "Open in Default App") - .on_click(move |_, _, cx| { - cx.open_with_system(&abs_path); - }) - .style(ButtonStyle::Outlined) - .key_binding(KeyBinding::for_action(&OpenWithSystem, cx)), - ), - ) + contents + .child( + h_flex().justify_center().child( + Button::new("open-with-system", "Open in Default App") + .on_click(move |_, _, cx| { + cx.open_with_system(&abs_path); + }) + .style(ButtonStyle::Outlined) + .key_binding(KeyBinding::for_action( + &OpenWithSystem, + cx, + )), + ), + ) + .child( + h_flex() + .justify_center() + .child( + Button::new( + "open-with-encoding", + "Open With a Different Encoding", + ) + .style(ButtonStyle::Outlined) + .on_click( + move |_, window, cx| { + window.dispatch_action( + Box::new( + zed_actions::encodings_ui::Toggle( + path0.clone(), + ), + ), + cx, + ) + }, + ), + ) + .child( + Button::new( + "accept-risk-and-open", + "Accept the Risk and Open", + ) + .style(ButtonStyle::Tinted(TintColor::Warning)) + .on_click( + move |_, window, cx| { + window.dispatch_action( + Box::new( + zed_actions::encodings_ui::ForceOpen( + path1.clone(), + ), + ), + cx, + ); + }, + ), + ), + ) }), ), )