Progress on diagnostic multibuffer
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
parent
03ebf0a5a9
commit
2bf48872b6
3 changed files with 71 additions and 11 deletions
|
@ -2225,7 +2225,8 @@ impl EditorElement {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
|
.map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let jump_icon = project::File::from_dyn(buffer.file()).map(|file| {
|
|
||||||
|
let jump_handler = project::File::from_dyn(buffer.file()).map(|file| {
|
||||||
let jump_path = ProjectPath {
|
let jump_path = ProjectPath {
|
||||||
worktree_id: file.worktree_id(cx),
|
worktree_id: file.worktree_id(cx),
|
||||||
path: file.path.clone(),
|
path: file.path.clone(),
|
||||||
|
@ -2236,12 +2237,11 @@ impl EditorElement {
|
||||||
.map_or(range.context.start, |primary| primary.start);
|
.map_or(range.context.start, |primary| primary.start);
|
||||||
let jump_position = language::ToPoint::to_point(&jump_anchor, buffer);
|
let jump_position = language::ToPoint::to_point(&jump_anchor, buffer);
|
||||||
|
|
||||||
IconButton::new(block_id, Icon::ArrowUpRight)
|
let jump_handler = cx.listener_for(&self.editor, move |editor, e, cx| {
|
||||||
.style(ButtonStyle::Subtle)
|
editor.jump(jump_path.clone(), jump_position, jump_anchor, cx);
|
||||||
.on_click(cx.listener_for(&self.editor, move |editor, e, cx| {
|
});
|
||||||
editor.jump(jump_path.clone(), jump_position, jump_anchor, cx);
|
|
||||||
}))
|
jump_handler
|
||||||
.tooltip(|cx| Tooltip::for_action("Jump to Buffer", &OpenExcerpts, cx))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let element = if *starts_new_buffer {
|
let element = if *starts_new_buffer {
|
||||||
|
@ -2303,16 +2303,61 @@ impl EditorElement {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.children(jump_icon), // .p_x(gutter_padding)
|
.children(jump_handler.map(|jump_handler| {
|
||||||
|
IconButton::new(block_id, Icon::ArrowUpRight)
|
||||||
|
.style(ButtonStyle::Subtle)
|
||||||
|
.on_click(jump_handler)
|
||||||
|
.tooltip(|cx| {
|
||||||
|
Tooltip::for_action("Jump to Buffer", &OpenExcerpts, cx)
|
||||||
|
})
|
||||||
|
})), // .p_x(gutter_padding)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let text_style = style.text.clone();
|
let text_style = style.text.clone();
|
||||||
h_stack()
|
h_stack()
|
||||||
.id("collapsed context")
|
.id("collapsed context")
|
||||||
.size_full()
|
.size_full()
|
||||||
.bg(gpui::red())
|
.gap(gutter_padding)
|
||||||
.child("⋯")
|
.child(
|
||||||
.children(jump_icon) // .p_x(gutter_padding)
|
h_stack()
|
||||||
|
.justify_end()
|
||||||
|
.flex_none()
|
||||||
|
.w(gutter_width - gutter_padding)
|
||||||
|
.h_full()
|
||||||
|
.text_buffer(cx)
|
||||||
|
.text_color(cx.theme().colors().editor_line_number)
|
||||||
|
.child("..."),
|
||||||
|
)
|
||||||
|
.map(|this| {
|
||||||
|
if let Some(jump_handler) = jump_handler {
|
||||||
|
this.child(
|
||||||
|
ButtonLike::new("jump to collapsed context")
|
||||||
|
.style(ButtonStyle::Transparent)
|
||||||
|
.full_width()
|
||||||
|
.on_click(jump_handler)
|
||||||
|
.tooltip(|cx| {
|
||||||
|
Tooltip::for_action(
|
||||||
|
"Jump to Buffer",
|
||||||
|
&OpenExcerpts,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
|
.h_px()
|
||||||
|
.w_full()
|
||||||
|
.bg(cx.theme().colors().border_variant)
|
||||||
|
.group_hover("", |style| {
|
||||||
|
style.bg(cx.theme().colors().border)
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.child(div().size_full().bg(gpui::green()))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// .child("⋯")
|
||||||
|
// .children(jump_icon) // .p_x(gutter_padding)
|
||||||
};
|
};
|
||||||
element.into_any()
|
element.into_any()
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,7 @@ impl RenderOnce for ButtonLike {
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
h_stack()
|
h_stack()
|
||||||
.id(self.id.clone())
|
.id(self.id.clone())
|
||||||
|
.group("")
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.h(self.size.height())
|
.h(self.size.height())
|
||||||
.when_some(self.width, |this, width| this.w(width))
|
.when_some(self.width, |this, width| this.w(width))
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use gpui::{px, Styled, WindowContext};
|
use gpui::{px, Styled, WindowContext};
|
||||||
|
use settings::Settings;
|
||||||
|
use theme::ThemeSettings;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{ElevationIndex, UITextSize};
|
use crate::{ElevationIndex, UITextSize};
|
||||||
|
@ -60,6 +62,18 @@ pub trait StyledExt: Styled + Sized {
|
||||||
self.text_size(size)
|
self.text_size(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The font size for buffer text.
|
||||||
|
///
|
||||||
|
/// Retrieves the default font size, or the user's custom font size if set.
|
||||||
|
///
|
||||||
|
/// This should only be used for text that is displayed in a buffer,
|
||||||
|
/// or other places that text needs to match the user's buffer font size.
|
||||||
|
fn text_buffer(self, cx: &mut WindowContext) -> Self {
|
||||||
|
let settings = ThemeSettings::get_global(cx);
|
||||||
|
|
||||||
|
self.text_size(settings.buffer_font_size)
|
||||||
|
}
|
||||||
|
|
||||||
/// The [`Surface`](ui2::ElevationIndex::Surface) elevation level, located above the app background, is the standard level for all elements
|
/// The [`Surface`](ui2::ElevationIndex::Surface) elevation level, located above the app background, is the standard level for all elements
|
||||||
///
|
///
|
||||||
/// Sets `bg()`, `rounded_lg()`, `border()`, `border_color()`, `shadow()`
|
/// Sets `bg()`, `rounded_lg()`, `border()`, `border_color()`, `shadow()`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue