diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 79391b2d5a..d99713308a 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -103,7 +103,7 @@ impl View for ProjectDiagnosticsEditor { if self.path_states.is_empty() { let theme = &self.settings.borrow().theme.project_diagnostics; Label::new( - "No problems detected in the project".to_string(), + "No problems in workspace".to_string(), theme.empty_message.clone(), ) .aligned() @@ -132,10 +132,8 @@ impl ProjectDiagnosticsEditor { let project = model.read(cx).project.clone(); cx.subscribe(&project, |this, _, event, cx| match event { project::Event::DiskBasedDiagnosticsFinished => { - this.summary = this.model.read(cx).project.read(cx).diagnostic_summary(cx); - let paths = mem::take(&mut this.paths_to_update); - this.update_excerpts(paths, cx); - cx.emit(Event::TitleChanged); + this.update_excerpts(cx); + this.update_title(cx); } project::Event::DiagnosticsUpdated(path) => { this.paths_to_update.insert(path.clone()); @@ -156,7 +154,7 @@ impl ProjectDiagnosticsEditor { let project = project.read(cx); let paths_to_update = project.diagnostic_summaries(cx).map(|e| e.0).collect(); - let this = Self { + let mut this = Self { model, summary: project.diagnostic_summary(cx), workspace, @@ -165,9 +163,9 @@ impl ProjectDiagnosticsEditor { build_settings, settings, path_states: Default::default(), - paths_to_update: Default::default(), + paths_to_update, }; - this.update_excerpts(paths_to_update, cx); + this.update_excerpts(cx); this } @@ -222,7 +220,8 @@ impl ProjectDiagnosticsEditor { } } - fn update_excerpts(&self, paths: BTreeSet, cx: &mut ViewContext) { + fn update_excerpts(&mut self, cx: &mut ViewContext) { + let paths = mem::take(&mut self.paths_to_update); let project = self.model.read(cx).project.clone(); cx.spawn(|this, mut cx| { async move { @@ -280,12 +279,7 @@ impl ProjectDiagnosticsEditor { let mut first_excerpt_id = None; let excerpts_snapshot = self.excerpts.update(cx, |excerpts, excerpts_cx| { let mut old_groups = path_state.diagnostic_groups.iter().enumerate().peekable(); - let mut new_groups = snapshot - .diagnostic_groups() - .into_iter() - .filter(|group| group.entries[group.primary_ix].diagnostic.is_disk_based) - .peekable(); - + let mut new_groups = snapshot.diagnostic_groups().into_iter().peekable(); loop { let mut to_insert = None; let mut to_remove = None; @@ -526,6 +520,11 @@ impl ProjectDiagnosticsEditor { } cx.notify(); } + + fn update_title(&mut self, cx: &mut ViewContext) { + self.summary = self.model.read(cx).project.read(cx).diagnostic_summary(cx); + cx.emit(Event::TitleChanged); + } } impl workspace::Item for ProjectDiagnostics { @@ -770,48 +769,52 @@ pub(crate) fn render_summary( text_style: &TextStyle, theme: &theme::ProjectDiagnostics, ) -> ElementBox { - let icon_width = theme.tab_icon_width; - let icon_spacing = theme.tab_icon_spacing; - let summary_spacing = theme.tab_summary_spacing; - Flex::row() - .with_children([ - Svg::new("icons/diagnostic-summary-error.svg") - .with_color(text_style.color) - .constrained() - .with_width(icon_width) + if summary.error_count == 0 && summary.warning_count == 0 { + Label::new("No problems".to_string(), text_style.clone()).boxed() + } else { + let icon_width = theme.tab_icon_width; + let icon_spacing = theme.tab_icon_spacing; + let summary_spacing = theme.tab_summary_spacing; + Flex::row() + .with_children([ + Svg::new("icons/diagnostic-summary-error.svg") + .with_color(text_style.color) + .constrained() + .with_width(icon_width) + .aligned() + .contained() + .with_margin_right(icon_spacing) + .named("no-icon"), + Label::new( + summary.error_count.to_string(), + LabelStyle { + text: text_style.clone(), + highlight_text: None, + }, + ) .aligned() - .contained() - .with_margin_right(icon_spacing) - .named("no-icon"), - Label::new( - summary.error_count.to_string(), - LabelStyle { - text: text_style.clone(), - highlight_text: None, - }, - ) - .aligned() - .boxed(), - Svg::new("icons/diagnostic-summary-warning.svg") - .with_color(text_style.color) - .constrained() - .with_width(icon_width) + .boxed(), + Svg::new("icons/diagnostic-summary-warning.svg") + .with_color(text_style.color) + .constrained() + .with_width(icon_width) + .aligned() + .contained() + .with_margin_left(summary_spacing) + .with_margin_right(icon_spacing) + .named("warn-icon"), + Label::new( + summary.warning_count.to_string(), + LabelStyle { + text: text_style.clone(), + highlight_text: None, + }, + ) .aligned() - .contained() - .with_margin_left(summary_spacing) - .with_margin_right(icon_spacing) - .named("warn-icon"), - Label::new( - summary.warning_count.to_string(), - LabelStyle { - text: text_style.clone(), - highlight_text: None, - }, - ) - .aligned() - .boxed(), - ]) - .boxed() + .boxed(), + ]) + .boxed() + } } fn compare_diagnostics( diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a3c62295f7..27a8c79ba3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3493,9 +3493,11 @@ impl Editor { fn set_selections(&mut self, selections: Arc<[Selection]>, cx: &mut ViewContext) { self.selections = selections; - self.buffer.update(cx, |buffer, cx| { - buffer.set_active_selections(&self.selections, cx) - }); + if self.focused { + self.buffer.update(cx, |buffer, cx| { + buffer.set_active_selections(&self.selections, cx) + }); + } } pub fn request_autoscroll(&mut self, autoscroll: Autoscroll, cx: &mut ViewContext) { @@ -3725,6 +3727,10 @@ impl Editor { } fn pause_cursor_blinking(&mut self, cx: &mut ViewContext) { + if !self.focused { + return; + } + self.show_local_cursors = true; cx.notify(); diff --git a/crates/zed/assets/themes/_base.toml b/crates/zed/assets/themes/_base.toml index 0fcf8159cf..b818b514a7 100644 --- a/crates/zed/assets/themes/_base.toml +++ b/crates/zed/assets/themes/_base.toml @@ -185,7 +185,7 @@ corner_radius = 6 [project_panel] extends = "$panel" -padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2 +padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2 [project_panel.entry] text = "$text.1" @@ -313,7 +313,7 @@ message.highlight_text.color = "$text.3.color" [project_diagnostics] background = "$surface.1" -empty_message = "$text.0" +empty_message = { extends = "$text.0", size = 18 } status_bar_item = { extends = "$text.2", margin.right = 10 } tab_icon_width = 13 tab_icon_spacing = 4