From 7df798ded50c48d2e08b76e3fa3e304031cfc130 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 22 Mar 2023 09:32:27 +0100 Subject: [PATCH 01/13] Remove screen sharing indicator when call ends Previously, we would only remove it when the screen sharing stopped. --- crates/collab_ui/src/sharing_status_indicator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/collab_ui/src/sharing_status_indicator.rs b/crates/collab_ui/src/sharing_status_indicator.rs index 541194ec66..e16d4a2d89 100644 --- a/crates/collab_ui/src/sharing_status_indicator.rs +++ b/crates/collab_ui/src/sharing_status_indicator.rs @@ -21,6 +21,8 @@ pub fn init(cx: &mut MutableAppContext) { } else if let Some((window_id, _)) = status_indicator.take() { cx.remove_status_bar_item(window_id); } + } else if let Some((window_id, _)) = status_indicator.take() { + cx.remove_status_bar_item(window_id); } }) .detach(); From aa7254167a7512fc31392c615359a42f26b2934e Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Wed, 22 Mar 2023 15:31:21 +0200 Subject: [PATCH 02/13] Fix typo --- crates/language_selector/src/active_buffer_language.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index ce9fd5a3b0..3979ce292c 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -53,7 +53,7 @@ impl View for ActiveBufferLanguage { let active_language = if let Some(active_language) = self.active_language.as_ref() { active_language.to_string() } else { - "Unkown".to_string() + "Unknown".to_string() }; MouseEventHandler::::new(0, cx, |state, cx| { From d5bb2d13b83f7f0e7c0ca58acb5a7325729119ee Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Wed, 22 Mar 2023 16:13:58 +0200 Subject: [PATCH 03/13] Introduce terminal button count Co-Authored-By: Antonio Scandurra --- crates/project/src/terminals.rs | 3 ++- crates/terminal_view/src/terminal_button.rs | 25 ++++++++++++++++----- crates/theme/src/theme.rs | 12 +++++++++- crates/workspace/src/sidebar.rs | 4 ++-- styles/src/styleTree/statusBar.ts | 4 ++++ 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index f7b4105dd2..0f3092ca41 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -43,11 +43,12 @@ impl Project { .push(terminal_handle.downgrade()); let id = terminal_handle.id(); - cx.observe_release(&terminal_handle, move |project, _terminal, _cx| { + cx.observe_release(&terminal_handle, move |project, _terminal, cx| { let handles = &mut project.terminals.local_handles; if let Some(index) = handles.iter().position(|terminal| terminal.id() == id) { handles.remove(index); + cx.notify(); } }) .detach(); diff --git a/crates/terminal_view/src/terminal_button.rs b/crates/terminal_view/src/terminal_button.rs index 8c723ad4d4..3943984405 100644 --- a/crates/terminal_view/src/terminal_button.rs +++ b/crates/terminal_view/src/terminal_button.rs @@ -56,13 +56,14 @@ impl View for TerminalButton { .unwrap_or(false); let has_terminals = !project.local_terminal_handles().is_empty(); + let terminal_count = project.local_terminal_handles().len() as i32; let theme = cx.global::().theme.clone(); Stack::new() .with_child( MouseEventHandler::::new(0, cx, { let theme = theme.clone(); - move |state, _| { + move |state, _cx| { let style = theme .workspace .status_bar @@ -70,10 +71,23 @@ impl View for TerminalButton { .item .style_for(state, active); - Svg::new("icons/terminal_12.svg") - .with_color(style.icon_color) + Flex::row() + .with_child( + Svg::new("icons/terminal_12.svg") + .with_color(style.icon_color) + .constrained() + .with_width(style.icon_size) + .aligned() + .named("terminals-icon"), + ) + .with_child( + Label::new(terminal_count.to_string(), style.label.text.clone()) + .contained() + .with_style(style.label.container) + .aligned() + .boxed(), + ) .constrained() - .with_width(style.icon_size) .with_height(style.icon_size) .contained() .with_style(style.container) @@ -112,8 +126,7 @@ impl View for TerminalButton { impl TerminalButton { pub fn new(workspace: ViewHandle, cx: &mut ViewContext) -> Self { - // When terminal moves, redraw so that the icon and toggle status matches. - cx.subscribe(&workspace, |_, _, _, cx| cx.notify()).detach(); + cx.observe(&workspace, |_, _, cx| cx.notify()).detach(); Self { workspace: workspace.downgrade(), popup_menu: cx.add_view(|cx| { diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 87de31f635..5650ae1886 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -299,6 +299,15 @@ pub struct StatusBar { pub diagnostic_message: Interactive, } +#[derive(Deserialize, Default)] +pub struct TerminalButton { + #[serde(flatten)] + pub container: ContainerStyle, + pub icon_color: Color, + pub icon_size: f32, + pub text: TextStyle, +} + #[derive(Deserialize, Default)] pub struct StatusBarSidebarButtons { pub group_left: ContainerStyle, @@ -340,12 +349,13 @@ pub struct Sidebar { pub container: ContainerStyle, } -#[derive(Clone, Copy, Deserialize, Default)] +#[derive(Clone, Deserialize, Default)] pub struct SidebarItem { #[serde(flatten)] pub container: ContainerStyle, pub icon_color: Color, pub icon_size: f32, + pub label: ContainedText, } #[derive(Deserialize, Default)] diff --git a/crates/workspace/src/sidebar.rs b/crates/workspace/src/sidebar.rs index 214f227757..37375b7e4a 100644 --- a/crates/workspace/src/sidebar.rs +++ b/crates/workspace/src/sidebar.rs @@ -230,7 +230,7 @@ impl View for SidebarButtons { let tooltip_style = theme.tooltip.clone(); let theme = &theme.workspace.status_bar.sidebar_buttons; let sidebar = self.sidebar.read(cx); - let item_style = theme.item; + let item_style = theme.item.clone(); let badge_style = theme.badge; let active_ix = sidebar.active_item_ix; let is_open = sidebar.is_open; @@ -254,7 +254,7 @@ impl View for SidebarButtons { sidebar_side, item_index: ix, }; - MouseEventHandler::::new(ix, cx, move |state, cx| { + MouseEventHandler::::new(ix, cx, |state, cx| { let is_active = is_open && ix == active_ix; let style = item_style.style_for(state, is_active); Stack::new() diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index b7e9696488..41961c4615 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -100,6 +100,10 @@ export default function statusBar(colorScheme: ColorScheme) { ...statusContainer, iconSize: 16, iconColor: foreground(layer, "variant"), + label: { + margin: { left: 6 }, + ...text(layer, "sans", { size: "sm" }), + }, hover: { iconColor: foreground(layer, "hovered"), background: background(layer, "variant"), From 15406ff2d9b4db6e172658fa09c8e9acd521996b Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Wed, 22 Mar 2023 16:31:42 +0200 Subject: [PATCH 04/13] Remove comment --- crates/terminal_view/src/terminal_button.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/terminal_view/src/terminal_button.rs b/crates/terminal_view/src/terminal_button.rs index 3943984405..83bce4d9f6 100644 --- a/crates/terminal_view/src/terminal_button.rs +++ b/crates/terminal_view/src/terminal_button.rs @@ -19,7 +19,6 @@ pub struct FocusTerminal { terminal_handle: WeakModelHandle, } -//actions!(terminal, [DeployTerminalMenu]); impl_internal_actions!(terminal, [FocusTerminal, DeployTerminalMenu]); pub fn init(cx: &mut MutableAppContext) { From e017b9938429558f68e0eec02f1de5a2a0b687eb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 22 Mar 2023 09:13:10 -0600 Subject: [PATCH 05/13] Fix typo --- crates/language_selector/src/active_buffer_language.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index ce9fd5a3b0..3979ce292c 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -53,7 +53,7 @@ impl View for ActiveBufferLanguage { let active_language = if let Some(active_language) = self.active_language.as_ref() { active_language.to_string() } else { - "Unkown".to_string() + "Unknown".to_string() }; MouseEventHandler::::new(0, cx, |state, cx| { From bd1515cdd22b29b18639f46706b8dcfe2a001130 Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Wed, 22 Mar 2023 18:23:41 +0200 Subject: [PATCH 06/13] Only show count when we have terminals Co-Authored-By: Mikayla Maki --- crates/terminal_view/src/terminal_button.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/terminal_view/src/terminal_button.rs b/crates/terminal_view/src/terminal_button.rs index 83bce4d9f6..87f0a2deba 100644 --- a/crates/terminal_view/src/terminal_button.rs +++ b/crates/terminal_view/src/terminal_button.rs @@ -79,13 +79,13 @@ impl View for TerminalButton { .aligned() .named("terminals-icon"), ) - .with_child( + .with_children(has_terminals.then(|| { Label::new(terminal_count.to_string(), style.label.text.clone()) .contained() .with_style(style.label.container) .aligned() - .boxed(), - ) + .boxed() + })) .constrained() .with_height(style.icon_size) .contained() From fd9eff3a78a1f0d9bf1394f43f67f7124d0c955f Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Wed, 22 Mar 2023 19:28:06 +0200 Subject: [PATCH 07/13] Remove struct --- crates/theme/src/theme.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 5650ae1886..d64a1d2499 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -299,15 +299,6 @@ pub struct StatusBar { pub diagnostic_message: Interactive, } -#[derive(Deserialize, Default)] -pub struct TerminalButton { - #[serde(flatten)] - pub container: ContainerStyle, - pub icon_color: Color, - pub icon_size: f32, - pub text: TextStyle, -} - #[derive(Deserialize, Default)] pub struct StatusBarSidebarButtons { pub group_left: ContainerStyle, From 4fc37cf982c6fa93b35e08159626f8ab02887747 Mon Sep 17 00:00:00 2001 From: Julia Date: Wed, 22 Mar 2023 15:40:51 -0400 Subject: [PATCH 08/13] Remove another spot with a flag old npm does not like --- crates/zed/src/languages/installation.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/zed/src/languages/installation.rs b/crates/zed/src/languages/installation.rs index 80bb1c9500..c5aff17e56 100644 --- a/crates/zed/src/languages/installation.rs +++ b/crates/zed/src/languages/installation.rs @@ -64,7 +64,6 @@ pub async fn npm_install_packages( let output = smol::process::Command::new("npm") .args(["-fetch-retry-mintimeout", "2000"]) .args(["-fetch-retry-maxtimeout", "5000"]) - .args(["-fetch-timeout", "5000"]) .arg("install") .arg("--prefix") .arg(directory) From 6de38f7410b08fa3eda65bdba2321d0b74e8d4a7 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Wed, 22 Mar 2023 16:33:06 -0400 Subject: [PATCH 09/13] v0.80.x dev --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8990500c56..8ef885471e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8436,7 +8436,7 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zed" -version = "0.79.0" +version = "0.80.0" dependencies = [ "activity_indicator", "anyhow", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 6a2422f87c..585c591ad2 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Nathan Sobo "] description = "The fast, collaborative code editor." edition = "2021" name = "zed" -version = "0.79.0" +version = "0.80.0" publish = false [lib] From e729c4ad4f002a5fd01e416034931aeee3c31f21 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 22 Mar 2023 17:04:52 -0700 Subject: [PATCH 10/13] Fix fold indicator offsets --- crates/editor/src/element.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 69e39b65d3..c1a489f48e 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -576,13 +576,16 @@ impl EditorElement { for (ix, fold_indicator) in layout.fold_indicators.iter_mut().enumerate() { if let Some(indicator) = fold_indicator.as_mut() { - let mut x = bounds.width() - layout.gutter_padding; - let mut y = ix as f32 * line_height - scroll_top; + let position = vec2f( + bounds.width() - layout.gutter_padding, + ix as f32 * line_height - (scroll_top % line_height), + ); + let centering_offset = vec2f( + ((layout.gutter_padding + layout.gutter_margin - indicator.size().x()) / 2.), + (line_height - indicator.size().y()) / 2., + ); - x += ((layout.gutter_padding + layout.gutter_margin) - indicator.size().x()) / 2.; - y += (line_height - indicator.size().y()) / 2.; - - let indicator_origin = bounds.origin() + vec2f(x, y); + let indicator_origin = bounds.origin() + position + centering_offset; indicator.paint(indicator_origin, visible_bounds, cx); } From e87c3b6dd7ca34bb7b5cd5265a76b62b7dd5df36 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 22 Mar 2023 17:05:54 -0700 Subject: [PATCH 11/13] Update element.rs remove spare parens --- crates/editor/src/element.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index c1a489f48e..780f8cd1d5 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -581,7 +581,7 @@ impl EditorElement { ix as f32 * line_height - (scroll_top % line_height), ); let centering_offset = vec2f( - ((layout.gutter_padding + layout.gutter_margin - indicator.size().x()) / 2.), + (layout.gutter_padding + layout.gutter_margin - indicator.size().x()) / 2., (line_height - indicator.size().y()) / 2., ); From bb5c2833a30641b787cb2e3d906fbdcb862877fe Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 23 Mar 2023 13:08:31 -0700 Subject: [PATCH 12/13] Aligned title bar items to the center and fixed left spacing on the sign in button co-authored-by: max --- crates/collab_ui/src/collab_titlebar_item.rs | 3 ++- styles/src/styleTree/workspace.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index fbaf72b332..3228f7d5a6 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -89,7 +89,7 @@ impl View for CollabTitlebarItem { let theme = cx.global::().theme.clone(); let mut left_container = Flex::row(); - let mut right_container = Flex::row(); + let mut right_container = Flex::row().align_children_center(); left_container.add_child( Label::new(project_title, theme.workspace.titlebar.title.clone()) @@ -117,6 +117,7 @@ impl View for CollabTitlebarItem { let status = workspace.read(cx).client().status(); let status = &*status.borrow(); + if matches!(status, client::Status::Connected { .. }) { right_container.add_child(self.render_toggle_contacts_button(&theme, cx)); right_container.add_child(self.render_user_menu_button(&theme, cx)); diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index e3c24a0a6a..6edbfe7c55 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -174,6 +174,9 @@ export default function workspace(colorScheme: ColorScheme) { // Sign in buttom // FlatButton, Variant signInPrompt: { + margin: { + left: itemSpacing + }, ...titlebarButton, }, From 5db11c628bf8525d2a46660e874701c702c0e380 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 23 Mar 2023 13:29:23 -0700 Subject: [PATCH 13/13] changed language status bar item to only show on editors --- .../src/active_buffer_language.rs | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index 3979ce292c..ce4b3aebdd 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use workspace::{item::ItemHandle, StatusItemView}; pub struct ActiveBufferLanguage { - active_language: Option>, + active_language: Option>>, _observe_active_editor: Option, } @@ -27,12 +27,12 @@ impl ActiveBufferLanguage { } fn update_language(&mut self, editor: ViewHandle, cx: &mut ViewContext) { - self.active_language.take(); + self.active_language = Some(None); let editor = editor.read(cx); if let Some((_, buffer, _)) = editor.active_excerpt(cx) { if let Some(language) = buffer.read(cx).language() { - self.active_language = Some(language.name()); + self.active_language = Some(Some(language.name())); } } @@ -50,23 +50,27 @@ impl View for ActiveBufferLanguage { } fn render(&mut self, cx: &mut RenderContext) -> ElementBox { - let active_language = if let Some(active_language) = self.active_language.as_ref() { - active_language.to_string() - } else { - "Unknown".to_string() - }; + if let Some(active_language) = self.active_language.as_ref() { + let active_language_text = if let Some(active_language_text) = active_language { + active_language_text.to_string() + } else { + "Unknown".to_string() + }; - MouseEventHandler::::new(0, cx, |state, cx| { - let theme = &cx.global::().theme.workspace.status_bar; - let style = theme.active_language.style_for(state, false); - Label::new(active_language, style.text.clone()) - .contained() - .with_style(style.container) - .boxed() - }) - .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, |_, cx| cx.dispatch_action(crate::Toggle)) - .boxed() + MouseEventHandler::::new(0, cx, |state, cx| { + let theme = &cx.global::().theme.workspace.status_bar; + let style = theme.active_language.style_for(state, false); + Label::new(active_language_text, style.text.clone()) + .contained() + .with_style(style.container) + .boxed() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, |_, cx| cx.dispatch_action(crate::Toggle)) + .boxed() + } else { + Empty::new().boxed() + } } }