zed2: Project diagnostics (#3359)

Release Notes:

- N/A
This commit is contained in:
Julia 2023-11-17 16:54:00 -05:00 committed by GitHub
commit c9fc7eac4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 2054 additions and 89 deletions

29
Cargo.lock generated
View file

@ -2614,6 +2614,34 @@ dependencies = [
"workspace", "workspace",
] ]
[[package]]
name = "diagnostics2"
version = "0.1.0"
dependencies = [
"anyhow",
"client2",
"collections",
"editor2",
"futures 0.3.28",
"gpui2",
"language2",
"log",
"lsp2",
"postage",
"project2",
"schemars",
"serde",
"serde_derive",
"serde_json",
"settings2",
"smallvec",
"theme2",
"ui2",
"unindent",
"util",
"workspace2",
]
[[package]] [[package]]
name = "diff" name = "diff"
version = "0.1.13" version = "0.1.13"
@ -11554,6 +11582,7 @@ dependencies = [
"copilot2", "copilot2",
"ctor", "ctor",
"db2", "db2",
"diagnostics2",
"editor2", "editor2",
"env_logger 0.9.3", "env_logger 0.9.3",
"feature_flags2", "feature_flags2",

View file

@ -32,6 +32,7 @@ members = [
"crates/refineable", "crates/refineable",
"crates/refineable/derive_refineable", "crates/refineable/derive_refineable",
"crates/diagnostics", "crates/diagnostics",
"crates/diagnostics2",
"crates/drag_and_drop", "crates/drag_and_drop",
"crates/editor", "crates/editor",
"crates/feature_flags", "crates/feature_flags",

View file

@ -117,6 +117,7 @@ impl Clone for Command {
} }
} }
} }
/// Hit count for each command in the palette. /// Hit count for each command in the palette.
/// We only account for commands triggered directly via command palette and not by e.g. keystrokes because /// We only account for commands triggered directly via command palette and not by e.g. keystrokes because
/// if an user already knows a keystroke for a command, they are unlikely to use a command palette to look for it. /// if an user already knows a keystroke for a command, they are unlikely to use a command palette to look for it.

View file

@ -0,0 +1,43 @@
[package]
name = "diagnostics2"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/diagnostics.rs"
doctest = false
[dependencies]
collections = { path = "../collections" }
editor = { package = "editor2", path = "../editor2" }
gpui = { package = "gpui2", path = "../gpui2" }
ui = { package = "ui2", path = "../ui2" }
language = { package = "language2", path = "../language2" }
lsp = { package = "lsp2", path = "../lsp2" }
project = { package = "project2", path = "../project2" }
settings = { package = "settings2", path = "../settings2" }
theme = { package = "theme2", path = "../theme2" }
util = { path = "../util" }
workspace = { package = "workspace2", path = "../workspace2" }
log.workspace = true
anyhow.workspace = true
futures.workspace = true
schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true
smallvec.workspace = true
postage.workspace = true
[dev-dependencies]
client = { package = "client2", path = "../client2", features = ["test-support"] }
editor = { package = "editor2", path = "../editor2", features = ["test-support"] }
language = { package = "language2", path = "../language2", features = ["test-support"] }
lsp = { package = "lsp2", path = "../lsp2", features = ["test-support"] }
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
workspace = { package = "workspace2", path = "../workspace2", features = ["test-support"] }
theme = { package = "theme2", path = "../theme2", features = ["test-support"] }
serde_json.workspace = true
unindent.workspace = true

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,156 @@
use collections::HashSet;
use editor::{Editor, GoToDiagnostic};
use gpui::{
div, Div, EventEmitter, InteractiveComponent, ParentComponent, Render, Stateful,
StatefulInteractiveComponent, Styled, Subscription, View, ViewContext, WeakView,
};
use language::Diagnostic;
use lsp::LanguageServerId;
use theme::ActiveTheme;
use ui::{h_stack, Icon, IconElement, Label, TextColor, Tooltip};
use workspace::{item::ItemHandle, StatusItemView, ToolbarItemEvent, Workspace};
use crate::ProjectDiagnosticsEditor;
pub struct DiagnosticIndicator {
summary: project::DiagnosticSummary,
active_editor: Option<WeakView<Editor>>,
workspace: WeakView<Workspace>,
current_diagnostic: Option<Diagnostic>,
in_progress_checks: HashSet<LanguageServerId>,
_observe_active_editor: Option<Subscription>,
}
impl Render for DiagnosticIndicator {
type Element = Stateful<Self, Div<Self>>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let mut summary_row = h_stack()
.id(cx.entity_id())
.on_action(Self::go_to_next_diagnostic)
.rounded_md()
.p_1()
.cursor_pointer()
.bg(gpui::green())
.hover(|style| style.bg(cx.theme().colors().element_hover))
.active(|style| style.bg(cx.theme().colors().element_active))
.tooltip(|_, cx| Tooltip::text("Project Diagnostics", cx))
.on_click(|this, _, cx| {
if let Some(workspace) = this.workspace.upgrade() {
workspace.update(cx, |workspace, cx| {
ProjectDiagnosticsEditor::deploy(workspace, &Default::default(), cx)
})
}
});
if self.summary.error_count > 0 {
summary_row = summary_row.child(
div()
.child(IconElement::new(Icon::XCircle).color(TextColor::Error))
.bg(gpui::red()),
);
summary_row = summary_row.child(
div()
.child(Label::new(self.summary.error_count.to_string()))
.bg(gpui::yellow()),
);
}
if self.summary.warning_count > 0 {
summary_row = summary_row
.child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning));
summary_row = summary_row.child(Label::new(self.summary.warning_count.to_string()));
}
if self.summary.error_count == 0 && self.summary.warning_count == 0 {
summary_row =
summary_row.child(IconElement::new(Icon::Check).color(TextColor::Success));
}
summary_row
}
}
impl DiagnosticIndicator {
pub fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
let project = workspace.project();
cx.subscribe(project, |this, project, event, cx| match event {
project::Event::DiskBasedDiagnosticsStarted { language_server_id } => {
this.in_progress_checks.insert(*language_server_id);
cx.notify();
}
project::Event::DiskBasedDiagnosticsFinished { language_server_id }
| project::Event::LanguageServerRemoved(language_server_id) => {
this.summary = project.read(cx).diagnostic_summary(cx);
this.in_progress_checks.remove(language_server_id);
cx.notify();
}
project::Event::DiagnosticsUpdated { .. } => {
this.summary = project.read(cx).diagnostic_summary(cx);
cx.notify();
}
_ => {}
})
.detach();
Self {
summary: project.read(cx).diagnostic_summary(cx),
in_progress_checks: project
.read(cx)
.language_servers_running_disk_based_diagnostics()
.collect(),
active_editor: None,
workspace: workspace.weak_handle(),
current_diagnostic: None,
_observe_active_editor: None,
}
}
fn go_to_next_diagnostic(&mut self, _: &GoToDiagnostic, cx: &mut ViewContext<Self>) {
if let Some(editor) = self.active_editor.as_ref().and_then(|e| e.upgrade()) {
editor.update(cx, |editor, cx| {
editor.go_to_diagnostic_impl(editor::Direction::Next, cx);
})
}
}
fn update(&mut self, editor: View<Editor>, cx: &mut ViewContext<Self>) {
let editor = editor.read(cx);
let buffer = editor.buffer().read(cx);
let cursor_position = editor.selections.newest::<usize>(cx).head();
let new_diagnostic = buffer
.snapshot(cx)
.diagnostics_in_range::<_, usize>(cursor_position..cursor_position, false)
.filter(|entry| !entry.range.is_empty())
.min_by_key(|entry| (entry.diagnostic.severity, entry.range.len()))
.map(|entry| entry.diagnostic);
if new_diagnostic != self.current_diagnostic {
self.current_diagnostic = new_diagnostic;
cx.notify();
}
}
}
impl EventEmitter<ToolbarItemEvent> for DiagnosticIndicator {}
impl StatusItemView for DiagnosticIndicator {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn ItemHandle>,
cx: &mut ViewContext<Self>,
) {
if let Some(editor) = active_pane_item.and_then(|item| item.downcast::<Editor>()) {
self.active_editor = Some(editor.downgrade());
self._observe_active_editor = Some(cx.observe(&editor, Self::update));
self.update(editor, cx);
} else {
self.active_editor = None;
self.current_diagnostic = None;
self._observe_active_editor = None;
}
cx.notify();
}
}

View file

@ -0,0 +1,28 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug)]
pub struct ProjectDiagnosticsSettings {
pub include_warnings: bool,
}
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
pub struct ProjectDiagnosticsSettingsContent {
include_warnings: Option<bool>,
}
impl settings::Settings for ProjectDiagnosticsSettings {
const KEY: Option<&'static str> = Some("diagnostics");
type FileContent = ProjectDiagnosticsSettingsContent;
fn load(
default_value: &Self::FileContent,
user_values: &[&Self::FileContent],
_cx: &mut gpui::AppContext,
) -> anyhow::Result<Self>
where
Self: Sized,
{
Self::load_via_json_merge(default_value, user_values)
}
}

View file

@ -0,0 +1,66 @@
use crate::ProjectDiagnosticsEditor;
use gpui::{div, Div, EventEmitter, ParentComponent, Render, ViewContext, WeakView};
use ui::{Icon, IconButton, Tooltip};
use workspace::{item::ItemHandle, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
pub struct ToolbarControls {
editor: Option<WeakView<ProjectDiagnosticsEditor>>,
}
impl Render for ToolbarControls {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let include_warnings = self
.editor
.as_ref()
.and_then(|editor| editor.upgrade())
.map(|editor| editor.read(cx).include_warnings)
.unwrap_or(false);
let tooltip = if include_warnings {
"Exclude Warnings"
} else {
"Include Warnings"
};
div().child(
IconButton::new("toggle-warnings", Icon::ExclamationTriangle)
.tooltip(move |_, cx| Tooltip::text(tooltip, cx))
.on_click(|this: &mut Self, cx| {
if let Some(editor) = this.editor.as_ref().and_then(|editor| editor.upgrade()) {
editor.update(cx, |editor, cx| {
editor.toggle_warnings(&Default::default(), cx);
});
}
}),
)
}
}
impl EventEmitter<ToolbarItemEvent> for ToolbarControls {}
impl ToolbarItemView for ToolbarControls {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn ItemHandle>,
_: &mut ViewContext<Self>,
) -> ToolbarItemLocation {
if let Some(pane_item) = active_pane_item.as_ref() {
if let Some(editor) = pane_item.downcast::<ProjectDiagnosticsEditor>() {
self.editor = Some(editor.downgrade());
ToolbarItemLocation::PrimaryRight { flex: None }
} else {
ToolbarItemLocation::Hidden
}
} else {
ToolbarItemLocation::Hidden
}
}
}
impl ToolbarControls {
pub fn new() -> Self {
ToolbarControls { editor: None }
}
}

View file

@ -585,7 +585,7 @@ pub enum SoftWrap {
Column(u32), Column(u32),
} }
#[derive(Clone)] #[derive(Clone, Default)]
pub struct EditorStyle { pub struct EditorStyle {
pub background: Hsla, pub background: Hsla,
pub local_player: PlayerColor, pub local_player: PlayerColor,
@ -2318,7 +2318,7 @@ impl Editor {
} }
self.blink_manager.update(cx, BlinkManager::pause_blinking); self.blink_manager.update(cx, BlinkManager::pause_blinking);
cx.emit(Event::SelectionsChanged { local }); cx.emit(EditorEvent::SelectionsChanged { local });
if self.selections.disjoint_anchors().len() == 1 { if self.selections.disjoint_anchors().len() == 1 {
cx.emit(SearchEvent::ActiveMatchChanged) cx.emit(SearchEvent::ActiveMatchChanged)
@ -4242,7 +4242,7 @@ impl Editor {
self.report_copilot_event(Some(completion.uuid.clone()), true, cx) self.report_copilot_event(Some(completion.uuid.clone()), true, cx)
} }
cx.emit(Event::InputHandled { cx.emit(EditorEvent::InputHandled {
utf16_range_to_replace: None, utf16_range_to_replace: None,
text: suggestion.text.to_string().into(), text: suggestion.text.to_string().into(),
}); });
@ -5639,7 +5639,7 @@ impl Editor {
self.request_autoscroll(Autoscroll::fit(), cx); self.request_autoscroll(Autoscroll::fit(), cx);
self.unmark_text(cx); self.unmark_text(cx);
self.refresh_copilot_suggestions(true, cx); self.refresh_copilot_suggestions(true, cx);
cx.emit(Event::Edited); cx.emit(EditorEvent::Edited);
} }
} }
@ -5654,7 +5654,7 @@ impl Editor {
self.request_autoscroll(Autoscroll::fit(), cx); self.request_autoscroll(Autoscroll::fit(), cx);
self.unmark_text(cx); self.unmark_text(cx);
self.refresh_copilot_suggestions(true, cx); self.refresh_copilot_suggestions(true, cx);
cx.emit(Event::Edited); cx.emit(EditorEvent::Edited);
} }
} }
@ -8123,7 +8123,7 @@ impl Editor {
log::error!("unexpectedly ended a transaction that wasn't started by this editor"); log::error!("unexpectedly ended a transaction that wasn't started by this editor");
} }
cx.emit(Event::Edited); cx.emit(EditorEvent::Edited);
Some(tx_id) Some(tx_id)
} else { } else {
None None
@ -8711,7 +8711,7 @@ impl Editor {
if self.has_active_copilot_suggestion(cx) { if self.has_active_copilot_suggestion(cx) {
self.update_visible_copilot_suggestion(cx); self.update_visible_copilot_suggestion(cx);
} }
cx.emit(Event::BufferEdited); cx.emit(EditorEvent::BufferEdited);
cx.emit(ItemEvent::Edit); cx.emit(ItemEvent::Edit);
cx.emit(ItemEvent::UpdateBreadcrumbs); cx.emit(ItemEvent::UpdateBreadcrumbs);
cx.emit(SearchEvent::MatchesInvalidated); cx.emit(SearchEvent::MatchesInvalidated);
@ -8750,7 +8750,7 @@ impl Editor {
predecessor, predecessor,
excerpts, excerpts,
} => { } => {
cx.emit(Event::ExcerptsAdded { cx.emit(EditorEvent::ExcerptsAdded {
buffer: buffer.clone(), buffer: buffer.clone(),
predecessor: *predecessor, predecessor: *predecessor,
excerpts: excerpts.clone(), excerpts: excerpts.clone(),
@ -8759,7 +8759,7 @@ impl Editor {
} }
multi_buffer::Event::ExcerptsRemoved { ids } => { multi_buffer::Event::ExcerptsRemoved { ids } => {
self.refresh_inlay_hints(InlayHintRefreshReason::ExcerptsRemoved(ids.clone()), cx); self.refresh_inlay_hints(InlayHintRefreshReason::ExcerptsRemoved(ids.clone()), cx);
cx.emit(Event::ExcerptsRemoved { ids: ids.clone() }) cx.emit(EditorEvent::ExcerptsRemoved { ids: ids.clone() })
} }
multi_buffer::Event::Reparsed => { multi_buffer::Event::Reparsed => {
cx.emit(ItemEvent::UpdateBreadcrumbs); cx.emit(ItemEvent::UpdateBreadcrumbs);
@ -8773,7 +8773,7 @@ impl Editor {
cx.emit(ItemEvent::UpdateTab); cx.emit(ItemEvent::UpdateTab);
cx.emit(ItemEvent::UpdateBreadcrumbs); cx.emit(ItemEvent::UpdateBreadcrumbs);
} }
multi_buffer::Event::DiffBaseChanged => cx.emit(Event::DiffBaseChanged), multi_buffer::Event::DiffBaseChanged => cx.emit(EditorEvent::DiffBaseChanged),
multi_buffer::Event::Closed => cx.emit(ItemEvent::CloseItem), multi_buffer::Event::Closed => cx.emit(ItemEvent::CloseItem),
multi_buffer::Event::DiagnosticsUpdated => { multi_buffer::Event::DiagnosticsUpdated => {
self.refresh_active_diagnostics(cx); self.refresh_active_diagnostics(cx);
@ -9113,7 +9113,7 @@ impl Editor {
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
if !self.input_enabled { if !self.input_enabled {
cx.emit(Event::InputIgnored { text: text.into() }); cx.emit(EditorEvent::InputIgnored { text: text.into() });
return; return;
} }
if let Some(relative_utf16_range) = relative_utf16_range { if let Some(relative_utf16_range) = relative_utf16_range {
@ -9173,7 +9173,7 @@ impl Editor {
} }
fn handle_focus(&mut self, cx: &mut ViewContext<Self>) { fn handle_focus(&mut self, cx: &mut ViewContext<Self>) {
cx.emit(Event::Focused); cx.emit(EditorEvent::Focused);
if let Some(rename) = self.pending_rename.as_ref() { if let Some(rename) = self.pending_rename.as_ref() {
let rename_editor_focus_handle = rename.editor.read(cx).focus_handle.clone(); let rename_editor_focus_handle = rename.editor.read(cx).focus_handle.clone();
@ -9203,7 +9203,7 @@ impl Editor {
.update(cx, |buffer, cx| buffer.remove_active_selections(cx)); .update(cx, |buffer, cx| buffer.remove_active_selections(cx));
self.hide_context_menu(cx); self.hide_context_menu(cx);
hide_hover(self, cx); hide_hover(self, cx);
cx.emit(Event::Blurred); cx.emit(EditorEvent::Blurred);
cx.notify(); cx.notify();
} }
} }
@ -9326,7 +9326,7 @@ impl Deref for EditorSnapshot {
} }
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum Event { pub enum EditorEvent {
InputIgnored { InputIgnored {
text: Arc<str>, text: Arc<str>,
}, },
@ -9344,8 +9344,12 @@ pub enum Event {
}, },
BufferEdited, BufferEdited,
Edited, Edited,
Reparsed,
Focused, Focused,
Blurred, Blurred,
DirtyChanged,
Saved,
TitleChanged,
DiffBaseChanged, DiffBaseChanged,
SelectionsChanged { SelectionsChanged {
local: bool, local: bool,
@ -9354,6 +9358,7 @@ pub enum Event {
local: bool, local: bool,
autoscroll: bool, autoscroll: bool,
}, },
Closed,
} }
pub struct EditorFocused(pub View<Editor>); pub struct EditorFocused(pub View<Editor>);
@ -9368,7 +9373,7 @@ pub struct EditorReleased(pub WeakView<Editor>);
// } // }
// } // }
// //
impl EventEmitter<Event> for Editor {} impl EventEmitter<EditorEvent> for Editor {}
impl FocusableView for Editor { impl FocusableView for Editor {
fn focus_handle(&self, cx: &AppContext) -> FocusHandle { fn focus_handle(&self, cx: &AppContext) -> FocusHandle {
@ -9571,7 +9576,7 @@ impl InputHandler for Editor {
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
if !self.input_enabled { if !self.input_enabled {
cx.emit(Event::InputIgnored { text: text.into() }); cx.emit(EditorEvent::InputIgnored { text: text.into() });
return; return;
} }
@ -9601,7 +9606,7 @@ impl InputHandler for Editor {
}) })
}); });
cx.emit(Event::InputHandled { cx.emit(EditorEvent::InputHandled {
utf16_range_to_replace: range_to_replace, utf16_range_to_replace: range_to_replace,
text: text.into(), text: text.into(),
}); });
@ -9632,7 +9637,7 @@ impl InputHandler for Editor {
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
if !self.input_enabled { if !self.input_enabled {
cx.emit(Event::InputIgnored { text: text.into() }); cx.emit(EditorEvent::InputIgnored { text: text.into() });
return; return;
} }
@ -9675,7 +9680,7 @@ impl InputHandler for Editor {
}) })
}); });
cx.emit(Event::InputHandled { cx.emit(EditorEvent::InputHandled {
utf16_range_to_replace: range_to_replace, utf16_range_to_replace: range_to_replace,
text: text.into(), text: text.into(),
}); });

View file

@ -3853,7 +3853,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
view.condition::<crate::Event>(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) view.condition::<crate::EditorEvent>(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
.await; .await;
view.update(cx, |view, cx| { view.update(cx, |view, cx| {
@ -4019,7 +4019,7 @@ async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
editor editor
.condition::<crate::Event>(cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx)) .condition::<crate::EditorEvent>(cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
.await; .await;
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
@ -4583,7 +4583,7 @@ async fn test_surround_with_pair(cx: &mut gpui::TestAppContext) {
}); });
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
view.condition::<crate::Event>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
.await; .await;
view.update(cx, |view, cx| { view.update(cx, |view, cx| {
@ -4734,7 +4734,7 @@ async fn test_delete_autoclose_pair(cx: &mut gpui::TestAppContext) {
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
editor editor
.condition::<crate::Event>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) .condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
.await; .await;
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
@ -6295,7 +6295,7 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
}); });
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); let (view, cx) = cx.add_window_view(|cx| build_editor(buffer, cx));
view.condition::<crate::Event>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) view.condition::<crate::EditorEvent>(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
.await; .await;
view.update(cx, |view, cx| { view.update(cx, |view, cx| {

View file

@ -1970,6 +1970,7 @@ impl EditorElement {
TransformBlock::ExcerptHeader { .. } => false, TransformBlock::ExcerptHeader { .. } => false,
TransformBlock::Custom(block) => block.style() == BlockStyle::Fixed, TransformBlock::Custom(block) => block.style() == BlockStyle::Fixed,
}); });
let mut render_block = |block: &TransformBlock, let mut render_block = |block: &TransformBlock,
available_space: Size<AvailableSpace>, available_space: Size<AvailableSpace>,
block_id: usize, block_id: usize,
@ -2003,6 +2004,7 @@ impl EditorElement {
editor_style: &self.style, editor_style: &self.style,
}) })
} }
TransformBlock::ExcerptHeader { TransformBlock::ExcerptHeader {
buffer, buffer,
range, range,
@ -2046,6 +2048,7 @@ impl EditorElement {
} }
h_stack() h_stack()
.id("path header block")
.size_full() .size_full()
.bg(gpui::red()) .bg(gpui::red())
.child(filename.unwrap_or_else(|| "untitled".to_string())) .child(filename.unwrap_or_else(|| "untitled".to_string()))
@ -2054,6 +2057,7 @@ impl EditorElement {
} else { } else {
let text_style = style.text.clone(); let text_style = style.text.clone();
h_stack() h_stack()
.id("collapsed context")
.size_full() .size_full()
.bg(gpui::red()) .bg(gpui::red())
.child("") .child("")

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
editor_settings::SeedQuerySetting, link_go_to_definition::hide_link_definition, editor_settings::SeedQuerySetting, link_go_to_definition::hide_link_definition,
movement::surrounding_word, persistence::DB, scroll::ScrollAnchor, Anchor, Autoscroll, Editor, movement::surrounding_word, persistence::DB, scroll::ScrollAnchor, Anchor, Autoscroll, Editor,
EditorSettings, Event, ExcerptId, ExcerptRange, MultiBuffer, MultiBufferSnapshot, EditorEvent, EditorSettings, ExcerptId, ExcerptRange, MultiBuffer, MultiBufferSnapshot,
NavigationData, ToPoint as _, NavigationData, ToPoint as _,
}; };
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
@ -41,11 +41,12 @@ use workspace::{
pub const MAX_TAB_TITLE_LEN: usize = 24; pub const MAX_TAB_TITLE_LEN: usize = 24;
impl FollowableEvents for Event { impl FollowableEvents for EditorEvent {
fn to_follow_event(&self) -> Option<workspace::item::FollowEvent> { fn to_follow_event(&self) -> Option<workspace::item::FollowEvent> {
match self { match self {
Event::Edited => Some(FollowEvent::Unfollow), EditorEvent::Edited => Some(FollowEvent::Unfollow),
Event::SelectionsChanged { local } | Event::ScrollPositionChanged { local, .. } => { EditorEvent::SelectionsChanged { local }
| EditorEvent::ScrollPositionChanged { local, .. } => {
if *local { if *local {
Some(FollowEvent::Unfollow) Some(FollowEvent::Unfollow)
} else { } else {
@ -60,7 +61,7 @@ impl FollowableEvents for Event {
impl EventEmitter<ItemEvent> for Editor {} impl EventEmitter<ItemEvent> for Editor {}
impl FollowableItem for Editor { impl FollowableItem for Editor {
type FollowableEvent = Event; type FollowableEvent = EditorEvent;
fn remote_id(&self) -> Option<ViewId> { fn remote_id(&self) -> Option<ViewId> {
self.remote_id self.remote_id
} }
@ -248,7 +249,7 @@ impl FollowableItem for Editor {
match update { match update {
proto::update_view::Variant::Editor(update) => match event { proto::update_view::Variant::Editor(update) => match event {
Event::ExcerptsAdded { EditorEvent::ExcerptsAdded {
buffer, buffer,
predecessor, predecessor,
excerpts, excerpts,
@ -269,20 +270,20 @@ impl FollowableItem for Editor {
} }
true true
} }
Event::ExcerptsRemoved { ids } => { EditorEvent::ExcerptsRemoved { ids } => {
update update
.deleted_excerpts .deleted_excerpts
.extend(ids.iter().map(ExcerptId::to_proto)); .extend(ids.iter().map(ExcerptId::to_proto));
true true
} }
Event::ScrollPositionChanged { .. } => { EditorEvent::ScrollPositionChanged { .. } => {
let scroll_anchor = self.scroll_manager.anchor(); let scroll_anchor = self.scroll_manager.anchor();
update.scroll_top_anchor = Some(serialize_anchor(&scroll_anchor.anchor)); update.scroll_top_anchor = Some(serialize_anchor(&scroll_anchor.anchor));
update.scroll_x = scroll_anchor.offset.x; update.scroll_x = scroll_anchor.offset.x;
update.scroll_y = scroll_anchor.offset.y; update.scroll_y = scroll_anchor.offset.y;
true true
} }
Event::SelectionsChanged { .. } => { EditorEvent::SelectionsChanged { .. } => {
update.selections = self update.selections = self
.selections .selections
.disjoint_anchors() .disjoint_anchors()

View file

@ -6,8 +6,8 @@ use crate::{
display_map::{DisplaySnapshot, ToDisplayPoint}, display_map::{DisplaySnapshot, ToDisplayPoint},
hover_popover::hide_hover, hover_popover::hide_hover,
persistence::DB, persistence::DB,
Anchor, DisplayPoint, Editor, EditorMode, Event, InlayHintRefreshReason, MultiBufferSnapshot, Anchor, DisplayPoint, Editor, EditorEvent, EditorMode, InlayHintRefreshReason,
ToPoint, MultiBufferSnapshot, ToPoint,
}; };
use gpui::{point, px, AppContext, Entity, Pixels, Styled, Task, ViewContext}; use gpui::{point, px, AppContext, Entity, Pixels, Styled, Task, ViewContext};
use language::{Bias, Point}; use language::{Bias, Point};
@ -224,7 +224,7 @@ impl ScrollManager {
cx: &mut ViewContext<Editor>, cx: &mut ViewContext<Editor>,
) { ) {
self.anchor = anchor; self.anchor = anchor;
cx.emit(Event::ScrollPositionChanged { local, autoscroll }); cx.emit(EditorEvent::ScrollPositionChanged { local, autoscroll });
self.show_scrollbar(cx); self.show_scrollbar(cx);
self.autoscroll_request.take(); self.autoscroll_request.take();
if let Some(workspace_id) = workspace_id { if let Some(workspace_id) = workspace_id {

View file

@ -71,7 +71,8 @@ impl<'a> EditorTestContext<'a> {
&self, &self,
predicate: impl FnMut(&Editor, &AppContext) -> bool, predicate: impl FnMut(&Editor, &AppContext) -> bool,
) -> impl Future<Output = ()> { ) -> impl Future<Output = ()> {
self.editor.condition::<crate::Event>(&self.cx, predicate) self.editor
.condition::<crate::EditorEvent>(&self.cx, predicate)
} }
#[track_caller] #[track_caller]

View file

@ -84,13 +84,13 @@ impl GoToLine {
fn on_line_editor_event( fn on_line_editor_event(
&mut self, &mut self,
_: View<Editor>, _: View<Editor>,
event: &editor::Event, event: &editor::EditorEvent,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
match event { match event {
// todo!() this isn't working... // todo!() this isn't working...
editor::Event::Blurred => cx.emit(Manager::Dismiss), editor::EditorEvent::Blurred => cx.emit(Manager::Dismiss),
editor::Event::BufferEdited { .. } => self.highlight_current_line(cx), editor::EditorEvent::BufferEdited { .. } => self.highlight_current_line(cx),
_ => {} _ => {}
} }
} }

View file

@ -386,6 +386,32 @@ impl<T: Send> Model<T> {
} }
} }
impl<V: 'static> View<V> {
pub fn next_notification(&self, cx: &TestAppContext) -> impl Future<Output = ()> {
use postage::prelude::{Sink as _, Stream as _};
let (mut tx, mut rx) = postage::mpsc::channel(1);
let mut cx = cx.app.app.borrow_mut();
let subscription = cx.observe(self, move |_, _| {
tx.try_send(()).ok();
});
let duration = if std::env::var("CI").is_ok() {
Duration::from_secs(5)
} else {
Duration::from_secs(1)
};
async move {
let notification = crate::util::timeout(duration, rx.recv())
.await
.expect("next notification timed out");
drop(subscription);
notification.expect("model dropped while test was waiting for its next notification")
}
}
}
impl<V> View<V> { impl<V> View<V> {
pub fn condition<Evt>( pub fn condition<Evt>(
&self, &self,

View file

@ -87,6 +87,7 @@ pub trait ParentComponent<V: 'static> {
} }
trait ElementObject<V> { trait ElementObject<V> {
fn element_id(&self) -> Option<ElementId>;
fn layout(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) -> LayoutId; fn layout(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) -> LayoutId;
fn paint(&mut self, view_state: &mut V, cx: &mut ViewContext<V>); fn paint(&mut self, view_state: &mut V, cx: &mut ViewContext<V>);
fn measure( fn measure(
@ -144,6 +145,10 @@ where
E: Element<V>, E: Element<V>,
E::ElementState: 'static, E::ElementState: 'static,
{ {
fn element_id(&self) -> Option<ElementId> {
self.element.element_id()
}
fn layout(&mut self, state: &mut V, cx: &mut ViewContext<V>) -> LayoutId { fn layout(&mut self, state: &mut V, cx: &mut ViewContext<V>) -> LayoutId {
let (layout_id, frame_state) = match mem::take(&mut self.phase) { let (layout_id, frame_state) = match mem::take(&mut self.phase) {
ElementRenderPhase::Start => { ElementRenderPhase::Start => {
@ -266,6 +271,10 @@ impl<V> AnyElement<V> {
AnyElement(Box::new(RenderedElement::new(element))) AnyElement(Box::new(RenderedElement::new(element)))
} }
pub fn element_id(&self) -> Option<ElementId> {
self.0.element_id()
}
pub fn layout(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) -> LayoutId { pub fn layout(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) -> LayoutId {
self.0.layout(view_state, cx) self.0.layout(view_state, cx)
} }

View file

@ -281,17 +281,17 @@ impl<V: Render> From<WeakView<V>> for AnyWeakView {
} }
} }
impl<T, E> Render for T // impl<T, E> Render for T
where // where
T: 'static + FnMut(&mut WindowContext) -> E, // T: 'static + FnMut(&mut WindowContext) -> E,
E: 'static + Send + Element<T>, // E: 'static + Send + Element<T>,
{ // {
type Element = E; // type Element = E;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element { // fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
(self)(cx) // (self)(cx)
} // }
} // }
pub struct RenderViewWith<C, V> { pub struct RenderViewWith<C, V> {
view: View<V>, view: View<V>,

View file

@ -2,14 +2,14 @@ use crate::{
key_dispatch::DispatchActionListener, px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, key_dispatch::DispatchActionListener, px, size, Action, AnyBox, AnyDrag, AnyView, AppContext,
AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners, CursorStyle, AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners, CursorStyle,
DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity, EntityId, DevicePixels, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect, Entity, EntityId,
EventEmitter, FileDropEvent, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla, ImageData, EventEmitter, FileDropEvent, Flatten, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla,
InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, LayoutId, Model, ModelContext, ImageData, InputEvent, IsZero, KeyBinding, KeyContext, KeyDownEvent, LayoutId, Model,
Modifiers, MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent,
Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler, PlatformWindow, Point, MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformInputHandler,
PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams, PlatformWindow, Point, PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams,
RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, SubscriberSet, RenderImageParams, RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size,
Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext, Style, SubscriberSet, Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View,
WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS, VisualContext, WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
}; };
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use collections::HashMap; use collections::HashMap;
@ -2411,6 +2411,17 @@ impl<V: 'static + Render> WindowHandle<V> {
} }
} }
pub fn root<C>(&self, cx: &mut C) -> Result<View<V>>
where
C: Context,
{
Flatten::flatten(cx.update_window(self.any_handle, |root_view, _| {
root_view
.downcast::<V>()
.map_err(|_| anyhow!("the type of the window's root view has changed"))
}))
}
pub fn update<C, R>( pub fn update<C, R>(
&self, &self,
cx: &mut C, cx: &mut C,
@ -2556,6 +2567,18 @@ pub enum ElementId {
FocusHandle(FocusId), FocusHandle(FocusId),
} }
impl TryInto<SharedString> for ElementId {
type Error = anyhow::Error;
fn try_into(self) -> anyhow::Result<SharedString> {
if let ElementId::Name(name) = self {
Ok(name)
} else {
Err(anyhow!("element id is not string"))
}
}
}
impl From<EntityId> for ElementId { impl From<EntityId> for ElementId {
fn from(id: EntityId) -> Self { fn from(id: EntityId) -> Self {
ElementId::View(id) ElementId::View(id)

View file

@ -143,10 +143,10 @@ impl<D: PickerDelegate> Picker<D> {
fn on_input_editor_event( fn on_input_editor_event(
&mut self, &mut self,
_: View<Editor>, _: View<Editor>,
event: &editor::Event, event: &editor::EditorEvent,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
if let editor::Event::BufferEdited = event { if let editor::EditorEvent::BufferEdited = event {
let query = self.editor.read(cx).text(cx); let query = self.editor.read(cx).text(cx);
self.update_matches(query, cx); self.update_matches(query, cx);
} }

View file

@ -199,10 +199,11 @@ impl ProjectPanel {
let filename_editor = cx.build_view(|cx| Editor::single_line(cx)); let filename_editor = cx.build_view(|cx| Editor::single_line(cx));
cx.subscribe(&filename_editor, |this, _, event, cx| match event { cx.subscribe(&filename_editor, |this, _, event, cx| match event {
editor::Event::BufferEdited | editor::Event::SelectionsChanged { .. } => { editor::EditorEvent::BufferEdited
| editor::EditorEvent::SelectionsChanged { .. } => {
this.autoscroll(cx); this.autoscroll(cx);
} }
editor::Event::Blurred => { editor::EditorEvent::Blurred => {
if this if this
.edit_state .edit_state
.as_ref() .as_ref()

View file

@ -1,6 +1,6 @@
use gpui::Hsla; use gpui::Hsla;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy, Default)]
pub struct PlayerColor { pub struct PlayerColor {
pub cursor: Hsla, pub cursor: Hsla,
pub background: Hsla, pub background: Hsla,

View file

@ -130,7 +130,7 @@ impl Theme {
} }
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug, Default)]
pub struct DiagnosticStyle { pub struct DiagnosticStyle {
pub error: Hsla, pub error: Hsla,
pub warning: Hsla, pub warning: Hsla,

View file

@ -16,8 +16,12 @@ pub enum Icon {
ArrowLeft, ArrowLeft,
ArrowRight, ArrowRight,
ArrowUpRight, ArrowUpRight,
AtSign,
AudioOff, AudioOff,
AudioOn, AudioOn,
Bell,
BellOff,
BellRing,
Bolt, Bolt,
Check, Check,
ChevronDown, ChevronDown,
@ -26,12 +30,14 @@ pub enum Icon {
ChevronUp, ChevronUp,
Close, Close,
Collab, Collab,
Copilot,
Dash, Dash,
Exit, Envelope,
ExclamationTriangle, ExclamationTriangle,
Exit,
File, File,
FileGeneric,
FileDoc, FileDoc,
FileGeneric,
FileGit, FileGit,
FileLock, FileLock,
FileRust, FileRust,
@ -44,6 +50,7 @@ pub enum Icon {
InlayHint, InlayHint,
MagicWand, MagicWand,
MagnifyingGlass, MagnifyingGlass,
MailOpen,
Maximize, Maximize,
Menu, Menu,
MessageBubbles, MessageBubbles,
@ -59,13 +66,6 @@ pub enum Icon {
SplitMessage, SplitMessage,
Terminal, Terminal,
XCircle, XCircle,
Copilot,
Envelope,
Bell,
BellOff,
BellRing,
MailOpen,
AtSign,
} }
impl Icon { impl Icon {
@ -75,8 +75,12 @@ impl Icon {
Icon::ArrowLeft => "icons/arrow_left.svg", Icon::ArrowLeft => "icons/arrow_left.svg",
Icon::ArrowRight => "icons/arrow_right.svg", Icon::ArrowRight => "icons/arrow_right.svg",
Icon::ArrowUpRight => "icons/arrow_up_right.svg", Icon::ArrowUpRight => "icons/arrow_up_right.svg",
Icon::AtSign => "icons/at-sign.svg",
Icon::AudioOff => "icons/speaker-off.svg", Icon::AudioOff => "icons/speaker-off.svg",
Icon::AudioOn => "icons/speaker-loud.svg", Icon::AudioOn => "icons/speaker-loud.svg",
Icon::Bell => "icons/bell.svg",
Icon::BellOff => "icons/bell-off.svg",
Icon::BellRing => "icons/bell-ring.svg",
Icon::Bolt => "icons/bolt.svg", Icon::Bolt => "icons/bolt.svg",
Icon::Check => "icons/check.svg", Icon::Check => "icons/check.svg",
Icon::ChevronDown => "icons/chevron_down.svg", Icon::ChevronDown => "icons/chevron_down.svg",
@ -85,12 +89,14 @@ impl Icon {
Icon::ChevronUp => "icons/chevron_up.svg", Icon::ChevronUp => "icons/chevron_up.svg",
Icon::Close => "icons/x.svg", Icon::Close => "icons/x.svg",
Icon::Collab => "icons/user_group_16.svg", Icon::Collab => "icons/user_group_16.svg",
Icon::Copilot => "icons/copilot.svg",
Icon::Dash => "icons/dash.svg", Icon::Dash => "icons/dash.svg",
Icon::Exit => "icons/exit.svg", Icon::Envelope => "icons/feedback.svg",
Icon::ExclamationTriangle => "icons/warning.svg", Icon::ExclamationTriangle => "icons/warning.svg",
Icon::Exit => "icons/exit.svg",
Icon::File => "icons/file.svg", Icon::File => "icons/file.svg",
Icon::FileGeneric => "icons/file_icons/file.svg",
Icon::FileDoc => "icons/file_icons/book.svg", Icon::FileDoc => "icons/file_icons/book.svg",
Icon::FileGeneric => "icons/file_icons/file.svg",
Icon::FileGit => "icons/file_icons/git.svg", Icon::FileGit => "icons/file_icons/git.svg",
Icon::FileLock => "icons/file_icons/lock.svg", Icon::FileLock => "icons/file_icons/lock.svg",
Icon::FileRust => "icons/file_icons/rust.svg", Icon::FileRust => "icons/file_icons/rust.svg",
@ -103,6 +109,7 @@ impl Icon {
Icon::InlayHint => "icons/inlay_hint.svg", Icon::InlayHint => "icons/inlay_hint.svg",
Icon::MagicWand => "icons/magic-wand.svg", Icon::MagicWand => "icons/magic-wand.svg",
Icon::MagnifyingGlass => "icons/magnifying_glass.svg", Icon::MagnifyingGlass => "icons/magnifying_glass.svg",
Icon::MailOpen => "icons/mail-open.svg",
Icon::Maximize => "icons/maximize.svg", Icon::Maximize => "icons/maximize.svg",
Icon::Menu => "icons/menu.svg", Icon::Menu => "icons/menu.svg",
Icon::MessageBubbles => "icons/conversations.svg", Icon::MessageBubbles => "icons/conversations.svg",
@ -118,13 +125,6 @@ impl Icon {
Icon::SplitMessage => "icons/split_message.svg", Icon::SplitMessage => "icons/split_message.svg",
Icon::Terminal => "icons/terminal.svg", Icon::Terminal => "icons/terminal.svg",
Icon::XCircle => "icons/error.svg", Icon::XCircle => "icons/error.svg",
Icon::Copilot => "icons/copilot.svg",
Icon::Envelope => "icons/feedback.svg",
Icon::Bell => "icons/bell.svg",
Icon::BellOff => "icons/bell-off.svg",
Icon::BellRing => "icons/bell-ring.svg",
Icon::MailOpen => "icons/mail-open.svg",
Icon::AtSign => "icons/at-sign.svg",
} }
} }
} }

View file

@ -64,7 +64,7 @@ use std::{
time::Duration, time::Duration,
}; };
use theme2::{ActiveTheme, ThemeSettings}; use theme2::{ActiveTheme, ThemeSettings};
pub use toolbar::{ToolbarItemLocation, ToolbarItemView}; pub use toolbar::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
pub use ui; pub use ui;
use util::ResultExt; use util::ResultExt;
use uuid::Uuid; use uuid::Uuid;

View file

@ -31,7 +31,7 @@ client = { package = "client2", path = "../client2" }
# clock = { path = "../clock" } # clock = { path = "../clock" }
copilot = { package = "copilot2", path = "../copilot2" } copilot = { package = "copilot2", path = "../copilot2" }
# copilot_button = { path = "../copilot_button" } # copilot_button = { path = "../copilot_button" }
# diagnostics = { path = "../diagnostics" } diagnostics = { package = "diagnostics2", path = "../diagnostics2" }
db = { package = "db2", path = "../db2" } db = { package = "db2", path = "../db2" }
editor = { package="editor2", path = "../editor2" } editor = { package="editor2", path = "../editor2" }
# feedback = { path = "../feedback" } # feedback = { path = "../feedback" }

View file

@ -146,6 +146,7 @@ fn main() {
command_palette::init(cx); command_palette::init(cx);
language::init(cx); language::init(cx);
editor::init(cx); editor::init(cx);
diagnostics::init(cx);
copilot::init( copilot::init(
copilot_language_server_id, copilot_language_server_id,
http.clone(), http.clone(),

View file

@ -104,8 +104,8 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
// QuickActionBar::new(buffer_search_bar, workspace) // QuickActionBar::new(buffer_search_bar, workspace)
// }); // });
// toolbar.add_item(quick_action_bar, cx); // toolbar.add_item(quick_action_bar, cx);
// let diagnostic_editor_controls = let diagnostic_editor_controls =
// cx.add_view(|_| diagnostics2::ToolbarControls::new()); cx.build_view(|_| diagnostics::ToolbarControls::new());
// toolbar.add_item(diagnostic_editor_controls, cx); // toolbar.add_item(diagnostic_editor_controls, cx);
// let project_search_bar = cx.add_view(|_| ProjectSearchBar::new()); // let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
// toolbar.add_item(project_search_bar, cx); // toolbar.add_item(project_search_bar, cx);
@ -137,8 +137,8 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
// let copilot = // let copilot =
// cx.add_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx)); // cx.add_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
// let diagnostic_summary = let diagnostic_summary =
// cx.add_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx)); cx.build_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
// let activity_indicator = activity_indicator::ActivityIndicator::new( // let activity_indicator = activity_indicator::ActivityIndicator::new(
// workspace, // workspace,
// app_state.languages.clone(), // app_state.languages.clone(),
@ -152,7 +152,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
// }); // });
// let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new()); // let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
workspace.status_bar().update(cx, |status_bar, cx| { workspace.status_bar().update(cx, |status_bar, cx| {
// status_bar.add_left_item(diagnostic_summary, cx); status_bar.add_left_item(diagnostic_summary, cx);
// status_bar.add_left_item(activity_indicator, cx); // status_bar.add_left_item(activity_indicator, cx);
// status_bar.add_right_item(feedback_button, cx); // status_bar.add_right_item(feedback_button, cx);