Store settings as a global via a gpui app_state
This commit is contained in:
+105
-162
@@ -40,7 +40,6 @@ pub use multi_buffer::{
|
||||
Anchor, AnchorRangeExt, ExcerptId, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint,
|
||||
};
|
||||
use ordered_float::OrderedFloat;
|
||||
use postage::watch;
|
||||
use project::{Project, ProjectTransaction};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smallvec::SmallVec;
|
||||
@@ -428,7 +427,6 @@ pub struct Editor {
|
||||
scroll_position: Vector2F,
|
||||
scroll_top_anchor: Option<Anchor>,
|
||||
autoscroll_request: Option<Autoscroll>,
|
||||
settings: watch::Receiver<Settings>,
|
||||
soft_wrap_mode_override: Option<settings::SoftWrap>,
|
||||
get_field_editor_theme: Option<GetFieldEditorTheme>,
|
||||
project: Option<ModelHandle<Project>>,
|
||||
@@ -795,25 +793,16 @@ pub struct NavigationData {
|
||||
|
||||
impl Editor {
|
||||
pub fn single_line(
|
||||
settings: watch::Receiver<Settings>,
|
||||
field_editor_style: Option<GetFieldEditorTheme>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, String::new(), cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(
|
||||
EditorMode::SingleLine,
|
||||
buffer,
|
||||
None,
|
||||
settings,
|
||||
field_editor_style,
|
||||
cx,
|
||||
)
|
||||
Self::new(EditorMode::SingleLine, buffer, None, field_editor_style, cx)
|
||||
}
|
||||
|
||||
pub fn auto_height(
|
||||
max_lines: usize,
|
||||
settings: watch::Receiver<Settings>,
|
||||
field_editor_style: Option<GetFieldEditorTheme>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
@@ -823,7 +812,6 @@ impl Editor {
|
||||
EditorMode::AutoHeight { max_lines },
|
||||
buffer,
|
||||
None,
|
||||
settings,
|
||||
field_editor_style,
|
||||
cx,
|
||||
)
|
||||
@@ -832,10 +820,9 @@ impl Editor {
|
||||
pub fn for_buffer(
|
||||
buffer: ModelHandle<MultiBuffer>,
|
||||
project: Option<ModelHandle<Project>>,
|
||||
settings: watch::Receiver<Settings>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
Self::new(EditorMode::Full, buffer, project, settings, None, cx)
|
||||
Self::new(EditorMode::Full, buffer, project, None, cx)
|
||||
}
|
||||
|
||||
pub fn clone(&self, nav_history: ItemNavHistory, cx: &mut ViewContext<Self>) -> Self {
|
||||
@@ -843,7 +830,6 @@ impl Editor {
|
||||
self.mode,
|
||||
self.buffer.clone(),
|
||||
self.project.clone(),
|
||||
self.settings.clone(),
|
||||
self.get_field_editor_theme,
|
||||
cx,
|
||||
);
|
||||
@@ -858,13 +844,12 @@ impl Editor {
|
||||
mode: EditorMode,
|
||||
buffer: ModelHandle<MultiBuffer>,
|
||||
project: Option<ModelHandle<Project>>,
|
||||
settings: watch::Receiver<Settings>,
|
||||
get_field_editor_theme: Option<GetFieldEditorTheme>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let display_map = cx.add_model(|cx| {
|
||||
let settings = settings.borrow();
|
||||
let style = build_style(&*settings, get_field_editor_theme, cx);
|
||||
let settings = cx.app_state::<Settings>();
|
||||
let style = build_style(settings, get_field_editor_theme, cx);
|
||||
DisplayMap::new(
|
||||
buffer.clone(),
|
||||
settings.tab_size,
|
||||
@@ -905,7 +890,6 @@ impl Editor {
|
||||
snippet_stack: Default::default(),
|
||||
select_larger_syntax_node_stack: Vec::new(),
|
||||
active_diagnostics: None,
|
||||
settings,
|
||||
soft_wrap_mode_override: None,
|
||||
get_field_editor_theme,
|
||||
project,
|
||||
@@ -982,7 +966,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
fn style(&self, cx: &AppContext) -> EditorStyle {
|
||||
build_style(&*self.settings.borrow(), self.get_field_editor_theme, cx)
|
||||
build_style(cx.app_state::<Settings>(), self.get_field_editor_theme, cx)
|
||||
}
|
||||
|
||||
pub fn set_placeholder_text(
|
||||
@@ -2691,7 +2675,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
self.start_transaction(cx);
|
||||
let tab_size = self.settings.borrow().tab_size;
|
||||
let tab_size = cx.app_state::<Settings>().tab_size;
|
||||
let mut selections = self.local_selections::<Point>(cx);
|
||||
let mut last_indent = None;
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
@@ -2768,7 +2752,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
self.start_transaction(cx);
|
||||
let tab_size = self.settings.borrow().tab_size;
|
||||
let tab_size = cx.app_state::<Settings>().tab_size;
|
||||
let selections = self.local_selections::<Point>(cx);
|
||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let mut deletion_ranges = Vec::new();
|
||||
@@ -4404,7 +4388,7 @@ impl Editor {
|
||||
|
||||
// Position the selection in the rename editor so that it matches the current selection.
|
||||
let rename_editor = cx.add_view(|cx| {
|
||||
let mut editor = Editor::single_line(this.settings.clone(), None, cx);
|
||||
let mut editor = Editor::single_line(None, cx);
|
||||
editor
|
||||
.buffer
|
||||
.update(cx, |buffer, cx| buffer.edit([0..0], &old_name, cx));
|
||||
@@ -4588,11 +4572,7 @@ impl Editor {
|
||||
for (block_id, diagnostic) in &active_diagnostics.blocks {
|
||||
new_styles.insert(
|
||||
*block_id,
|
||||
diagnostic_block_renderer(
|
||||
diagnostic.clone(),
|
||||
is_valid,
|
||||
self.settings.clone(),
|
||||
),
|
||||
diagnostic_block_renderer(diagnostic.clone(), is_valid),
|
||||
);
|
||||
}
|
||||
self.display_map
|
||||
@@ -4635,11 +4615,7 @@ impl Editor {
|
||||
BlockProperties {
|
||||
position: buffer.anchor_after(entry.range.start),
|
||||
height: message_height,
|
||||
render: diagnostic_block_renderer(
|
||||
diagnostic,
|
||||
true,
|
||||
self.settings.clone(),
|
||||
),
|
||||
render: diagnostic_block_renderer(diagnostic, true),
|
||||
disposition: BlockDisposition::Below,
|
||||
}
|
||||
}),
|
||||
@@ -5257,7 +5233,7 @@ impl Editor {
|
||||
|
||||
pub fn soft_wrap_mode(&self, cx: &AppContext) -> SoftWrap {
|
||||
let language = self.language(cx);
|
||||
let settings = self.settings.borrow();
|
||||
let settings = cx.app_state::<Settings>();
|
||||
let mode = self
|
||||
.soft_wrap_mode_override
|
||||
.unwrap_or_else(|| settings.soft_wrap(language));
|
||||
@@ -5799,18 +5775,14 @@ impl Deref for EditorStyle {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn diagnostic_block_renderer(
|
||||
diagnostic: Diagnostic,
|
||||
is_valid: bool,
|
||||
settings: watch::Receiver<Settings>,
|
||||
) -> RenderBlock {
|
||||
pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> RenderBlock {
|
||||
let mut highlighted_lines = Vec::new();
|
||||
for line in diagnostic.message.lines() {
|
||||
highlighted_lines.push(highlight_diagnostic_message(line));
|
||||
}
|
||||
|
||||
Arc::new(move |cx: &BlockContext| {
|
||||
let settings = settings.borrow();
|
||||
let settings = cx.app_state::<Settings>();
|
||||
let theme = &settings.theme.editor;
|
||||
let style = diagnostic_style(diagnostic.severity, is_valid, theme);
|
||||
let font_size = (style.text_scale_factor * settings.buffer_font_size).round();
|
||||
@@ -6005,14 +5977,12 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_undo_redo_with_selection_restoration(cx: &mut MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let mut now = Instant::now();
|
||||
let buffer = cx.add_model(|cx| language::Buffer::new(0, "123456", cx));
|
||||
let group_interval = buffer.read(cx).transaction_group_interval();
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let settings = Settings::test(cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.start_transaction_at(now, cx);
|
||||
@@ -6076,10 +6046,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_selection_with_mouse(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||
let settings = Settings::test(cx);
|
||||
let (_, editor) =
|
||||
cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
||||
editor.update(cx, |view, cx| {
|
||||
view.begin_selection(DisplayPoint::new(2, 2), false, 1, cx);
|
||||
@@ -6143,9 +6112,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_canceling_pending_selection(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||
let settings = Settings::test(cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.begin_selection(DisplayPoint::new(2, 2), false, 1, cx);
|
||||
@@ -6175,12 +6144,13 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
use workspace::ItemView;
|
||||
let nav_history = Rc::new(RefCell::new(workspace::NavHistory::default()));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(30, 5, 'a'), cx);
|
||||
|
||||
cx.add_window(Default::default(), |cx| {
|
||||
use workspace::ItemView;
|
||||
let nav_history = Rc::new(RefCell::new(workspace::NavHistory::default()));
|
||||
let settings = Settings::test(&cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(30, 5, 'a'), cx);
|
||||
let mut editor = build_editor(buffer.clone(), settings, cx);
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
editor.nav_history = Some(ItemNavHistory::new(nav_history.clone(), &cx.handle()));
|
||||
|
||||
// Move the cursor a small distance.
|
||||
@@ -6232,9 +6202,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_cancel(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||
let settings = Settings::test(cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.begin_selection(DisplayPoint::new(3, 4), false, 1, cx);
|
||||
@@ -6272,6 +6242,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_fold(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(
|
||||
&"
|
||||
impl Foo {
|
||||
@@ -6293,10 +6264,7 @@ mod tests {
|
||||
.unindent(),
|
||||
cx,
|
||||
);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(&[DisplayPoint::new(8, 0)..DisplayPoint::new(12, 0)], cx);
|
||||
@@ -6359,11 +6327,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.edit(
|
||||
@@ -6435,11 +6401,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor_multibyte(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε\n", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
assert_eq!('ⓐ'.len_utf8(), 3);
|
||||
assert_eq!('α'.len_utf8(), 2);
|
||||
@@ -6538,11 +6502,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor_different_line_lengths(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(&[empty_range(0, "ⓐⓑⓒⓓⓔ".len())], cx);
|
||||
view.move_down(&MoveDown, cx);
|
||||
@@ -6585,9 +6547,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_beginning_end_of_line(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\n def", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -6726,9 +6688,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_prev_next_word_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("use std::str::{foo, bar}\n\n {baz.qux()}", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -6864,9 +6826,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("use one::{\n two::three::four::five\n};", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.set_wrap_width(Some(140.), cx);
|
||||
@@ -6917,11 +6879,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_delete_to_word_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("one two three four", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
@@ -6956,11 +6916,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_newline(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
@@ -6979,6 +6937,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_newline_with_old_selections(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(
|
||||
"
|
||||
a
|
||||
@@ -6994,9 +6953,8 @@ mod tests {
|
||||
cx,
|
||||
);
|
||||
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
let mut editor = build_editor(buffer.clone(), settings, cx);
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
editor.select_ranges(
|
||||
[
|
||||
Point::new(2, 4)..Point::new(2, 5),
|
||||
@@ -7064,11 +7022,10 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_insert_with_old_selections(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
|
||||
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
let mut editor = build_editor(buffer.clone(), settings, cx);
|
||||
let mut editor = build_editor(buffer.clone(), cx);
|
||||
editor.select_ranges([3..4, 11..12, 19..20], None, cx);
|
||||
editor
|
||||
});
|
||||
@@ -7092,11 +7049,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_indent_outdent(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(" one two\nthree\n four", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
// two selections on the same line
|
||||
@@ -7168,9 +7123,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_backspace(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(MultiBuffer::build_simple("", cx), settings, cx)
|
||||
build_editor(MultiBuffer::build_simple("", cx), cx)
|
||||
});
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
@@ -7213,12 +7168,10 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_delete(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer =
|
||||
MultiBuffer::build_simple("one two three\nfour five six\nseven eight nine\nten\n", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
@@ -7243,9 +7196,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_delete_line(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -7266,9 +7219,9 @@ mod tests {
|
||||
);
|
||||
});
|
||||
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(&[DisplayPoint::new(2, 0)..DisplayPoint::new(0, 1)], cx);
|
||||
view.delete_line(&DeleteLine, cx);
|
||||
@@ -7282,9 +7235,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_duplicate_line(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -7308,9 +7261,8 @@ mod tests {
|
||||
);
|
||||
});
|
||||
|
||||
let settings = Settings::test(&cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -7333,9 +7285,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_down(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.fold_ranges(
|
||||
vec![
|
||||
@@ -7429,11 +7381,10 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_down_with_blocks(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||
let snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, editor) =
|
||||
cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.insert_blocks(
|
||||
[BlockProperties {
|
||||
@@ -7451,12 +7402,10 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_clipboard(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("one✅ two three four five six ", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let view = cx
|
||||
.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
})
|
||||
.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx))
|
||||
.1;
|
||||
|
||||
// Cut with three selections. Clipboard text is divided into three slices.
|
||||
@@ -7582,9 +7531,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_select_all(cx: &mut gpui::MutableAppContext) {
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\nde\nfgh", cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_all(&SelectAll, cx);
|
||||
assert_eq!(
|
||||
@@ -7596,9 +7545,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_select_line(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(
|
||||
&[
|
||||
@@ -7641,9 +7590,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_split_selection_into_lines(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(9, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.fold_ranges(
|
||||
vec![
|
||||
@@ -7707,9 +7656,9 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_add_selection_above_below(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(&cx);
|
||||
populate_settings(cx);
|
||||
let buffer = MultiBuffer::build_simple("abc\ndefghi\n\njk\nlmno\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_display_ranges(&[DisplayPoint::new(1, 3)..DisplayPoint::new(1, 3)], cx);
|
||||
@@ -7876,7 +7825,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig::default(),
|
||||
Some(tree_sitter_rust::language()),
|
||||
@@ -7893,7 +7842,7 @@ mod tests {
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
@@ -8017,7 +7966,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
let language = Arc::new(
|
||||
Language::new(
|
||||
LanguageConfig {
|
||||
@@ -8052,7 +8001,7 @@ mod tests {
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
editor
|
||||
.condition(&cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
@@ -8074,7 +8023,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_autoclose_pairs(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
brackets: vec![
|
||||
@@ -8106,7 +8055,7 @@ mod tests {
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
@@ -8217,7 +8166,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_snippets(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
|
||||
let text = "
|
||||
a. b
|
||||
@@ -8226,7 +8175,7 @@ mod tests {
|
||||
"
|
||||
.unindent();
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
|
||||
editor.update(cx, |editor, cx| {
|
||||
let buffer = &editor.snapshot(cx).buffer_snapshot;
|
||||
@@ -8324,7 +8273,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_completion(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
|
||||
let (mut language_server_config, mut fake_servers) = LanguageServerConfig::fake();
|
||||
language_server_config.set_fake_capabilities(lsp::ServerCapabilities {
|
||||
@@ -8372,7 +8321,7 @@ mod tests {
|
||||
let mut fake_server = fake_servers.next().await.unwrap();
|
||||
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, editor) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.project = Some(project);
|
||||
@@ -8558,7 +8507,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_toggle_comment(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
line_comment: Some("// ".to_string()),
|
||||
@@ -8578,7 +8527,7 @@ mod tests {
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
|
||||
view.update(cx, |editor, cx| {
|
||||
// If multiple selections intersect a line, the line is only
|
||||
@@ -8638,7 +8587,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_editing_disjoint_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
populate_settings(cx);
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let multibuffer = cx.add_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
@@ -8655,9 +8604,7 @@ mod tests {
|
||||
|
||||
assert_eq!(multibuffer.read(cx).read(cx).text(), "aaaa\nbbbb");
|
||||
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(multibuffer, settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(multibuffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
assert_eq!(view.text(cx), "aaaa\nbbbb");
|
||||
view.select_ranges(
|
||||
@@ -8683,7 +8630,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_editing_overlapping_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
populate_settings(cx);
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let multibuffer = cx.add_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
@@ -8703,9 +8650,7 @@ mod tests {
|
||||
"aaaa\nbbbb\nbbbb\ncccc"
|
||||
);
|
||||
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(multibuffer, settings, cx)
|
||||
});
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(multibuffer, cx));
|
||||
view.update(cx, |view, cx| {
|
||||
view.select_ranges(
|
||||
[
|
||||
@@ -8740,7 +8685,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
fn test_refresh_selections(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
populate_settings(cx);
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let mut excerpt1_id = None;
|
||||
let multibuffer = cx.add_model(|cx| {
|
||||
@@ -8763,7 +8708,7 @@ mod tests {
|
||||
"aaaa\nbbbb\nbbbb\ncccc"
|
||||
);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
let mut editor = build_editor(multibuffer.clone(), settings, cx);
|
||||
let mut editor = build_editor(multibuffer.clone(), cx);
|
||||
editor.select_ranges(
|
||||
[
|
||||
Point::new(1, 3)..Point::new(1, 3),
|
||||
@@ -8815,7 +8760,7 @@ mod tests {
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
||||
let settings = cx.read(Settings::test);
|
||||
cx.update(populate_settings);
|
||||
let language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
brackets: vec![
|
||||
@@ -8847,7 +8792,7 @@ mod tests {
|
||||
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx).with_language(language, cx));
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, settings, cx));
|
||||
let (_, view) = cx.add_window(|cx| build_editor(buffer, cx));
|
||||
view.condition(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx))
|
||||
.await;
|
||||
|
||||
@@ -8883,10 +8828,8 @@ mod tests {
|
||||
#[gpui::test]
|
||||
fn test_highlighted_ranges(cx: &mut gpui::MutableAppContext) {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(16, 8, 'a'), cx);
|
||||
let settings = Settings::test(&cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
build_editor(buffer.clone(), settings, cx)
|
||||
});
|
||||
populate_settings(cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
editor.update(cx, |editor, cx| {
|
||||
struct Type1;
|
||||
@@ -9036,13 +8979,13 @@ mod tests {
|
||||
point..point
|
||||
}
|
||||
|
||||
fn build_editor(
|
||||
buffer: ModelHandle<MultiBuffer>,
|
||||
settings: Settings,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) -> Editor {
|
||||
let settings = watch::channel_with(settings);
|
||||
Editor::new(EditorMode::Full, buffer, None, settings.1, None, cx)
|
||||
fn build_editor(buffer: ModelHandle<MultiBuffer>, cx: &mut ViewContext<Editor>) -> Editor {
|
||||
Editor::new(EditorMode::Full, buffer, None, None, cx)
|
||||
}
|
||||
|
||||
fn populate_settings(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
cx.add_app_state(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1378,16 +1378,15 @@ fn scale_horizontal_mouse_autoscroll_delta(delta: f32) -> f32 {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{Editor, MultiBuffer};
|
||||
use postage::watch;
|
||||
use util::test::sample_text;
|
||||
use workspace::Settings;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_layout_line_numbers(cx: &mut gpui::MutableAppContext) {
|
||||
let settings = watch::channel_with(Settings::test(cx));
|
||||
cx.add_app_state(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||
Editor::new(EditorMode::Full, buffer, None, settings.1, None, cx)
|
||||
Editor::new(EditorMode::Full, buffer, None, None, cx)
|
||||
});
|
||||
let element = EditorElement::new(editor.downgrade(), editor.read(cx).style(cx));
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ use gpui::{
|
||||
Subscription, Task, View, ViewContext, ViewHandle, WeakModelHandle,
|
||||
};
|
||||
use language::{Bias, Buffer, Diagnostic, File as _};
|
||||
use postage::watch;
|
||||
use project::{File, Project, ProjectPath};
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
@@ -57,12 +56,7 @@ impl ItemHandle for BufferItemHandle {
|
||||
) -> Box<dyn ItemViewHandle> {
|
||||
let buffer = cx.add_model(|cx| MultiBuffer::singleton(self.0.clone(), cx));
|
||||
Box::new(cx.add_view(window_id, |cx| {
|
||||
let mut editor = Editor::for_buffer(
|
||||
buffer,
|
||||
Some(workspace.project().clone()),
|
||||
workspace.settings(),
|
||||
cx,
|
||||
);
|
||||
let mut editor = Editor::for_buffer(buffer, Some(workspace.project().clone()), cx);
|
||||
editor.nav_history = Some(ItemNavHistory::new(nav_history, &cx.handle()));
|
||||
editor
|
||||
}))
|
||||
@@ -101,12 +95,8 @@ impl ItemHandle for MultiBufferItemHandle {
|
||||
cx: &mut MutableAppContext,
|
||||
) -> Box<dyn ItemViewHandle> {
|
||||
Box::new(cx.add_view(window_id, |cx| {
|
||||
let mut editor = Editor::for_buffer(
|
||||
self.0.clone(),
|
||||
Some(workspace.project().clone()),
|
||||
workspace.settings(),
|
||||
cx,
|
||||
);
|
||||
let mut editor =
|
||||
Editor::for_buffer(self.0.clone(), Some(workspace.project().clone()), cx);
|
||||
editor.nav_history = Some(ItemNavHistory::new(nav_history, &cx.handle()));
|
||||
editor
|
||||
}))
|
||||
@@ -288,16 +278,14 @@ impl ItemView for Editor {
|
||||
pub struct CursorPosition {
|
||||
position: Option<Point>,
|
||||
selected_count: usize,
|
||||
settings: watch::Receiver<Settings>,
|
||||
_observe_active_editor: Option<Subscription>,
|
||||
}
|
||||
|
||||
impl CursorPosition {
|
||||
pub fn new(settings: watch::Receiver<Settings>) -> Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
position: None,
|
||||
selected_count: 0,
|
||||
settings,
|
||||
_observe_active_editor: None,
|
||||
}
|
||||
}
|
||||
@@ -332,9 +320,9 @@ impl View for CursorPosition {
|
||||
"CursorPosition"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||
if let Some(position) = self.position {
|
||||
let theme = &self.settings.borrow().theme.workspace.status_bar;
|
||||
let theme = &cx.app_state::<Settings>().theme.workspace.status_bar;
|
||||
let mut text = format!("{},{}", position.row + 1, position.column + 1);
|
||||
if self.selected_count > 0 {
|
||||
write!(text, " ({} selected)", self.selected_count).unwrap();
|
||||
@@ -365,16 +353,14 @@ impl StatusItemView for CursorPosition {
|
||||
}
|
||||
|
||||
pub struct DiagnosticMessage {
|
||||
settings: watch::Receiver<Settings>,
|
||||
diagnostic: Option<Diagnostic>,
|
||||
_observe_active_editor: Option<Subscription>,
|
||||
}
|
||||
|
||||
impl DiagnosticMessage {
|
||||
pub fn new(settings: watch::Receiver<Settings>) -> Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
diagnostic: None,
|
||||
settings,
|
||||
_observe_active_editor: None,
|
||||
}
|
||||
}
|
||||
@@ -407,9 +393,9 @@ impl View for DiagnosticMessage {
|
||||
"DiagnosticMessage"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||
if let Some(diagnostic) = &self.diagnostic {
|
||||
let theme = &self.settings.borrow().theme.workspace.status_bar;
|
||||
let theme = &cx.app_state::<Settings>().theme.workspace.status_bar;
|
||||
Label::new(
|
||||
diagnostic.message.split('\n').next().unwrap().to_string(),
|
||||
theme.diagnostic_message.clone(),
|
||||
|
||||
Reference in New Issue
Block a user