Merge branch 'main' into completion-menu-detail-layout
This commit is contained in:
commit
1810824bc4
46 changed files with 1694 additions and 432 deletions
|
@ -536,7 +536,7 @@ impl DisplaySnapshot {
|
|||
// Omit underlines for HINT/INFO diagnostics on 'unnecessary' code.
|
||||
if severity <= DiagnosticSeverity::WARNING || !chunk.is_unnecessary {
|
||||
let diagnostic_color =
|
||||
super::diagnostic_style(severity, true, &editor_style.diagnostic_style);
|
||||
super::diagnostic_style(severity, true, &editor_style.status);
|
||||
diagnostic_highlight.underline = Some(UnderlineStyle {
|
||||
color: Some(diagnostic_color),
|
||||
thickness: 1.0.into(),
|
||||
|
|
|
@ -97,7 +97,7 @@ use std::{
|
|||
pub use sum_tree::Bias;
|
||||
use sum_tree::TreeMap;
|
||||
use text::{OffsetUtf16, Rope};
|
||||
use theme::{ActiveTheme, DiagnosticStyle, PlayerColor, SyntaxTheme, ThemeColors, ThemeSettings};
|
||||
use theme::{ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, ThemeColors, ThemeSettings};
|
||||
use ui::{
|
||||
h_stack, ButtonSize, ButtonStyle, Icon, IconButton, ListItem, ListItemSpacing, Popover, Tooltip,
|
||||
};
|
||||
|
@ -514,7 +514,7 @@ pub struct EditorStyle {
|
|||
pub text: TextStyle,
|
||||
pub scrollbar_width: Pixels,
|
||||
pub syntax: Arc<SyntaxTheme>,
|
||||
pub diagnostic_style: DiagnosticStyle,
|
||||
pub status: StatusColors,
|
||||
pub inlays_style: HighlightStyle,
|
||||
pub suggestions_style: HighlightStyle,
|
||||
}
|
||||
|
@ -1197,7 +1197,6 @@ impl CompletionsMenu {
|
|||
.min_w(px(260.))
|
||||
.max_w(px(640.))
|
||||
.w(px(500.))
|
||||
.text_ui()
|
||||
.overflow_y_scroll()
|
||||
// Prevent a mouse down on documentation from being propagated to the editor,
|
||||
// because that would move the cursor.
|
||||
|
@ -1420,7 +1419,6 @@ impl CodeActionsMenu {
|
|||
let colors = cx.theme().colors();
|
||||
div()
|
||||
.px_2()
|
||||
.text_ui()
|
||||
.text_color(colors.text)
|
||||
.when(selected, |style| {
|
||||
style
|
||||
|
@ -7657,10 +7655,7 @@ impl Editor {
|
|||
text: text_style,
|
||||
scrollbar_width: cx.editor_style.scrollbar_width,
|
||||
syntax: cx.editor_style.syntax.clone(),
|
||||
diagnostic_style: cx
|
||||
.editor_style
|
||||
.diagnostic_style
|
||||
.clone(),
|
||||
status: cx.editor_style.status.clone(),
|
||||
// todo!("what about the rest of the highlight style parts for inlays and suggestions?")
|
||||
inlays_style: HighlightStyle {
|
||||
color: Some(cx.theme().status().hint),
|
||||
|
@ -9330,7 +9325,7 @@ impl Render for Editor {
|
|||
text: text_style,
|
||||
scrollbar_width: px(12.),
|
||||
syntax: cx.theme().syntax().clone(),
|
||||
diagnostic_style: cx.theme().diagnostic_style(),
|
||||
status: cx.theme().status().clone(),
|
||||
// todo!("what about the rest of the highlight style parts?")
|
||||
inlays_style: HighlightStyle {
|
||||
color: Some(cx.theme().status().hint),
|
||||
|
@ -9784,21 +9779,17 @@ pub fn highlight_diagnostic_message(diagnostic: &Diagnostic) -> (SharedString, V
|
|||
(text_without_backticks.into(), code_ranges)
|
||||
}
|
||||
|
||||
pub fn diagnostic_style(
|
||||
severity: DiagnosticSeverity,
|
||||
valid: bool,
|
||||
style: &DiagnosticStyle,
|
||||
) -> Hsla {
|
||||
pub fn diagnostic_style(severity: DiagnosticSeverity, valid: bool, colors: &StatusColors) -> Hsla {
|
||||
match (severity, valid) {
|
||||
(DiagnosticSeverity::ERROR, true) => style.error,
|
||||
(DiagnosticSeverity::ERROR, false) => style.error,
|
||||
(DiagnosticSeverity::WARNING, true) => style.warning,
|
||||
(DiagnosticSeverity::WARNING, false) => style.warning,
|
||||
(DiagnosticSeverity::INFORMATION, true) => style.info,
|
||||
(DiagnosticSeverity::INFORMATION, false) => style.info,
|
||||
(DiagnosticSeverity::HINT, true) => style.info,
|
||||
(DiagnosticSeverity::HINT, false) => style.info,
|
||||
_ => style.ignored,
|
||||
(DiagnosticSeverity::ERROR, true) => colors.error,
|
||||
(DiagnosticSeverity::ERROR, false) => colors.error,
|
||||
(DiagnosticSeverity::WARNING, true) => colors.warning,
|
||||
(DiagnosticSeverity::WARNING, false) => colors.warning,
|
||||
(DiagnosticSeverity::INFORMATION, true) => colors.info,
|
||||
(DiagnosticSeverity::INFORMATION, false) => colors.info,
|
||||
(DiagnosticSeverity::HINT, true) => colors.info,
|
||||
(DiagnosticSeverity::HINT, false) => colors.info,
|
||||
_ => colors.ignored,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ use std::{
|
|||
use sum_tree::Bias;
|
||||
use theme::{ActiveTheme, PlayerColor};
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, ButtonLike, ButtonStyle, IconButton, Label, Tooltip};
|
||||
use ui::{h_stack, ButtonLike, ButtonStyle, IconButton, Tooltip};
|
||||
use util::ResultExt;
|
||||
use workspace::item::Item;
|
||||
|
||||
|
@ -2305,13 +2305,17 @@ impl EditorElement {
|
|||
h_stack().gap_3().child(
|
||||
h_stack()
|
||||
.gap_2()
|
||||
.child(Label::new(
|
||||
.child(
|
||||
filename
|
||||
.map(SharedString::from)
|
||||
.unwrap_or_else(|| "untitled".into()),
|
||||
))
|
||||
)
|
||||
.when_some(parent_path, |then, path| {
|
||||
then.child(Label::new(path).color(Color::Muted))
|
||||
then.child(
|
||||
div().child(path).text_color(
|
||||
cx.theme().colors().text_muted,
|
||||
),
|
||||
)
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
@ -2373,8 +2377,6 @@ impl EditorElement {
|
|||
this.child(div().size_full().bg(gpui::green()))
|
||||
}
|
||||
})
|
||||
// .child("⋯")
|
||||
// .children(jump_icon) // .p_x(gutter_padding)
|
||||
};
|
||||
element.into_any()
|
||||
}
|
||||
|
@ -2811,50 +2813,65 @@ impl Element for EditorElement {
|
|||
) {
|
||||
let editor = self.editor.clone();
|
||||
|
||||
let mut layout = self.compute_layout(bounds, cx);
|
||||
let gutter_bounds = Bounds {
|
||||
origin: bounds.origin,
|
||||
size: layout.gutter_size,
|
||||
};
|
||||
let text_bounds = Bounds {
|
||||
origin: gutter_bounds.upper_right(),
|
||||
size: layout.text_size,
|
||||
};
|
||||
cx.with_text_style(
|
||||
Some(gpui::TextStyleRefinement {
|
||||
font_size: Some(self.style.text.font_size),
|
||||
..Default::default()
|
||||
}),
|
||||
|cx| {
|
||||
let mut layout = self.compute_layout(bounds, cx);
|
||||
let gutter_bounds = Bounds {
|
||||
origin: bounds.origin,
|
||||
size: layout.gutter_size,
|
||||
};
|
||||
let text_bounds = Bounds {
|
||||
origin: gutter_bounds.upper_right(),
|
||||
size: layout.text_size,
|
||||
};
|
||||
|
||||
let focus_handle = editor.focus_handle(cx);
|
||||
let key_context = self.editor.read(cx).key_context(cx);
|
||||
cx.with_key_dispatch(Some(key_context), Some(focus_handle.clone()), |_, cx| {
|
||||
self.register_actions(cx);
|
||||
self.register_key_listeners(cx);
|
||||
let focus_handle = editor.focus_handle(cx);
|
||||
let key_context = self.editor.read(cx).key_context(cx);
|
||||
cx.with_key_dispatch(Some(key_context), Some(focus_handle.clone()), |_, cx| {
|
||||
self.register_actions(cx);
|
||||
self.register_key_listeners(cx);
|
||||
|
||||
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||
let input_handler = ElementInputHandler::new(bounds, self.editor.clone(), cx);
|
||||
cx.handle_input(&focus_handle, input_handler);
|
||||
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||
let input_handler =
|
||||
ElementInputHandler::new(bounds, self.editor.clone(), cx);
|
||||
cx.handle_input(&focus_handle, input_handler);
|
||||
|
||||
self.paint_background(gutter_bounds, text_bounds, &layout, cx);
|
||||
if layout.gutter_size.width > Pixels::ZERO {
|
||||
self.paint_gutter(gutter_bounds, &mut layout, cx);
|
||||
}
|
||||
self.paint_text(text_bounds, &mut layout, cx);
|
||||
self.paint_background(gutter_bounds, text_bounds, &layout, cx);
|
||||
if layout.gutter_size.width > Pixels::ZERO {
|
||||
self.paint_gutter(gutter_bounds, &mut layout, cx);
|
||||
}
|
||||
self.paint_text(text_bounds, &mut layout, cx);
|
||||
|
||||
cx.with_z_index(0, |cx| {
|
||||
self.paint_mouse_listeners(bounds, gutter_bounds, text_bounds, &layout, cx);
|
||||
});
|
||||
if !layout.blocks.is_empty() {
|
||||
cx.with_z_index(0, |cx| {
|
||||
cx.with_element_id(Some("editor_blocks"), |cx| {
|
||||
self.paint_blocks(bounds, &mut layout, cx);
|
||||
cx.with_z_index(0, |cx| {
|
||||
self.paint_mouse_listeners(
|
||||
bounds,
|
||||
gutter_bounds,
|
||||
text_bounds,
|
||||
&layout,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
})
|
||||
}
|
||||
if !layout.blocks.is_empty() {
|
||||
cx.with_z_index(0, |cx| {
|
||||
cx.with_element_id(Some("editor_blocks"), |cx| {
|
||||
self.paint_blocks(bounds, &mut layout, cx);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
cx.with_z_index(1, |cx| {
|
||||
self.paint_overlays(text_bounds, &mut layout, cx);
|
||||
});
|
||||
cx.with_z_index(1, |cx| {
|
||||
self.paint_overlays(text_bounds, &mut layout, cx);
|
||||
});
|
||||
|
||||
cx.with_z_index(2, |cx| self.paint_scrollbar(bounds, &mut layout, cx));
|
||||
});
|
||||
})
|
||||
cx.with_z_index(2, |cx| self.paint_scrollbar(bounds, &mut layout, cx));
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@ use crate::{
|
|||
};
|
||||
use futures::FutureExt;
|
||||
use gpui::{
|
||||
actions, div, px, AnyElement, CursorStyle, InteractiveElement, IntoElement, Model, MouseButton,
|
||||
ParentElement, Pixels, SharedString, Size, StatefulInteractiveElement, Styled, Task,
|
||||
ViewContext, WeakView,
|
||||
actions, div, px, AnyElement, CursorStyle, Hsla, InteractiveElement, IntoElement, Model,
|
||||
MouseButton, ParentElement, Pixels, SharedString, Size, StatefulInteractiveElement, Styled,
|
||||
Task, ViewContext, WeakView,
|
||||
};
|
||||
use language::{markdown, Bias, DiagnosticEntry, Language, LanguageRegistry, ParsedMarkdown};
|
||||
|
||||
use lsp::DiagnosticSeverity;
|
||||
use project::{HoverBlock, HoverBlockKind, InlayHintLabelPart, Project};
|
||||
use settings::Settings;
|
||||
use std::{ops::Range, sync::Arc, time::Duration};
|
||||
|
@ -477,7 +478,6 @@ impl InfoPopover {
|
|||
div()
|
||||
.id("info_popover")
|
||||
.elevation_2(cx)
|
||||
.text_ui()
|
||||
.p_2()
|
||||
.overflow_y_scroll()
|
||||
.max_w(max_size.width)
|
||||
|
@ -514,16 +514,50 @@ impl DiagnosticPopover {
|
|||
None => self.local_diagnostic.diagnostic.message.clone(),
|
||||
};
|
||||
|
||||
let container_bg = crate::diagnostic_style(
|
||||
self.local_diagnostic.diagnostic.severity,
|
||||
true,
|
||||
&style.diagnostic_style,
|
||||
);
|
||||
struct DiagnosticColors {
|
||||
pub text: Hsla,
|
||||
pub background: Hsla,
|
||||
pub border: Hsla,
|
||||
}
|
||||
|
||||
let diagnostic_colors = match self.local_diagnostic.diagnostic.severity {
|
||||
DiagnosticSeverity::ERROR => DiagnosticColors {
|
||||
text: style.status.error,
|
||||
background: style.status.error_background,
|
||||
border: style.status.error_border,
|
||||
},
|
||||
DiagnosticSeverity::WARNING => DiagnosticColors {
|
||||
text: style.status.warning,
|
||||
background: style.status.warning_background,
|
||||
border: style.status.warning_border,
|
||||
},
|
||||
DiagnosticSeverity::INFORMATION => DiagnosticColors {
|
||||
text: style.status.info,
|
||||
background: style.status.info_background,
|
||||
border: style.status.info_border,
|
||||
},
|
||||
DiagnosticSeverity::HINT => DiagnosticColors {
|
||||
text: style.status.hint,
|
||||
background: style.status.hint_background,
|
||||
border: style.status.hint_border,
|
||||
},
|
||||
_ => DiagnosticColors {
|
||||
text: style.status.ignored,
|
||||
background: style.status.ignored_background,
|
||||
border: style.status.ignored_border,
|
||||
},
|
||||
};
|
||||
|
||||
div()
|
||||
.id("diagnostic")
|
||||
.overflow_y_scroll()
|
||||
.bg(container_bg)
|
||||
.px_2()
|
||||
.py_1()
|
||||
.bg(diagnostic_colors.background)
|
||||
.text_color(diagnostic_colors.text)
|
||||
.border_1()
|
||||
.border_color(diagnostic_colors.border)
|
||||
.rounded_md()
|
||||
.max_w(max_size.width)
|
||||
.max_h(max_size.height)
|
||||
.cursor(CursorStyle::PointingHand)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue