co-authored-by: conrad <conrad@zed.dev>
co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Mikayla 2023-11-20 14:46:01 -08:00
parent 6985b70859
commit 2c4d83c9af
No known key found for this signature in database
96 changed files with 1926 additions and 1955 deletions

View file

@ -16,7 +16,7 @@ use gpui::{
actions, div, AnyElement, AnyView, AppContext, Context, Div, EventEmitter, FocusEvent,
FocusHandle, Focusable, FocusableElement, FocusableView, InteractiveElement, Model,
ParentElement, Render, RenderOnce, SharedString, Styled, Subscription, Task, View, ViewContext,
VisualContext, WeakView,
VisualContext, WeakView, WindowContext,
};
use language::{
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
@ -90,8 +90,8 @@ struct DiagnosticGroupState {
impl EventEmitter<ItemEvent> for ProjectDiagnosticsEditor {}
impl Render<Self> for ProjectDiagnosticsEditor {
type Element = Focusable<Self, Div<Self>>;
impl Render for ProjectDiagnosticsEditor {
type Element = Focusable<Div>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let child = if self.path_states.is_empty() {
@ -109,8 +109,8 @@ impl Render<Self> for ProjectDiagnosticsEditor {
div()
.track_focus(&self.focus_handle)
.size_full()
.on_focus_in(Self::focus_in)
.on_action(Self::toggle_warnings)
.on_focus_in(cx.listener(Self::focus_in))
.on_action(cx.listener(Self::toggle_warnings))
.child(child)
}
}
@ -662,7 +662,7 @@ impl Item for ProjectDiagnosticsEditor {
Some("Project Diagnostics".into())
}
fn tab_content<T: 'static>(&self, _detail: Option<usize>, _: &AppContext) -> AnyElement<T> {
fn tab_content(&self, _detail: Option<usize>, _: &WindowContext) -> AnyElement {
render_summary(&self.summary)
}
@ -796,11 +796,10 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
})
}
pub(crate) fn render_summary<T: 'static>(summary: &DiagnosticSummary) -> AnyElement<T> {
pub(crate) fn render_summary(summary: &DiagnosticSummary) -> AnyElement {
if summary.error_count == 0 && summary.warning_count == 0 {
let label = Label::new("No problems");
label.render_into_any()
//.render()
} else {
h_stack()
.bg(gpui::red())

View file

@ -21,8 +21,8 @@ pub struct DiagnosticIndicator {
_observe_active_editor: Option<Subscription>,
}
impl Render<Self> for DiagnosticIndicator {
type Element = Stateful<Self, Div<Self>>;
impl Render for DiagnosticIndicator {
type Element = Stateful<Div>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
@ -45,7 +45,7 @@ impl Render<Self> for DiagnosticIndicator {
h_stack()
.id(cx.entity_id())
.on_action(Self::go_to_next_diagnostic)
.on_action(cx.listener(Self::go_to_next_diagnostic))
.rounded_md()
.flex_none()
.h(rems(1.375))
@ -54,14 +54,14 @@ impl Render<Self> for DiagnosticIndicator {
.bg(cx.theme().colors().ghost_element_background)
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover))
.active(|style| style.bg(cx.theme().colors().ghost_element_active))
.tooltip(|_, cx| Tooltip::text("Project Diagnostics", cx))
.on_click(|this, _, cx| {
.tooltip(|cx| Tooltip::text("Project Diagnostics", cx))
.on_click(cx.listener(|this, _, cx| {
if let Some(workspace) = this.workspace.upgrade() {
workspace.update(cx, |workspace, cx| {
ProjectDiagnosticsEditor::deploy(workspace, &Default::default(), cx)
})
}
})
}))
.child(diagnostic_indicator)
}
}

View file

@ -7,8 +7,8 @@ pub struct ToolbarControls {
editor: Option<WeakView<ProjectDiagnosticsEditor>>,
}
impl Render<Self> for ToolbarControls {
type Element = Div<Self>;
impl Render for ToolbarControls {
type Element = Div;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let include_warnings = self
@ -26,14 +26,14 @@ impl Render<Self> for ToolbarControls {
div().child(
IconButton::new("toggle-warnings", Icon::ExclamationTriangle)
.tooltip(move |_, cx| Tooltip::text(tooltip, cx))
.on_click(|this: &mut Self, cx| {
.tooltip(move |cx| Tooltip::text(tooltip, cx))
.on_click(cx.listener(|this, _, 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);
});
}
}),
})),
)
}
}