New excerpt controls (#24428)

Release Notes:

- Multibuffers now use less vertical space for excerpt boundaries.
Additionally the expand up/down arrows are hidden at the start and end
of the buffers

---------

Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Zed AI <claude-3.5-sonnet@zed.dev>
This commit is contained in:
Conrad Irwin 2025-03-13 15:52:47 -06:00 committed by GitHub
parent 3935e8343a
commit e3c0f56a96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 513 additions and 707 deletions

View file

@ -196,7 +196,6 @@ use crate::signature_help::{SignatureHelpHiddenBy, SignatureHelpState};
pub const FILE_HEADER_HEIGHT: u32 = 2;
pub const MULTI_BUFFER_EXCERPT_HEADER_HEIGHT: u32 = 1;
pub const MULTI_BUFFER_EXCERPT_FOOTER_HEIGHT: u32 = 1;
pub const DEFAULT_MULTIBUFFER_CONTEXT: u32 = 2;
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
const MAX_LINE_LEN: usize = 1024;
@ -1092,7 +1091,6 @@ impl Editor {
EditorMode::SingleLine { auto_width: false },
buffer,
None,
false,
window,
cx,
)
@ -1101,7 +1099,7 @@ impl Editor {
pub fn multi_line(window: &mut Window, cx: &mut Context<Self>) -> Self {
let buffer = cx.new(|cx| Buffer::local("", cx));
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
Self::new(EditorMode::Full, buffer, None, false, window, cx)
Self::new(EditorMode::Full, buffer, None, window, cx)
}
pub fn auto_width(window: &mut Window, cx: &mut Context<Self>) -> Self {
@ -1111,7 +1109,6 @@ impl Editor {
EditorMode::SingleLine { auto_width: true },
buffer,
None,
false,
window,
cx,
)
@ -1124,7 +1121,6 @@ impl Editor {
EditorMode::AutoHeight { max_lines },
buffer,
None,
false,
window,
cx,
)
@ -1137,33 +1133,23 @@ impl Editor {
cx: &mut Context<Self>,
) -> Self {
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
Self::new(EditorMode::Full, buffer, project, false, window, cx)
Self::new(EditorMode::Full, buffer, project, window, cx)
}
pub fn for_multibuffer(
buffer: Entity<MultiBuffer>,
project: Option<Entity<Project>>,
show_excerpt_controls: bool,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
Self::new(
EditorMode::Full,
buffer,
project,
show_excerpt_controls,
window,
cx,
)
Self::new(EditorMode::Full, buffer, project, window, cx)
}
pub fn clone(&self, window: &mut Window, cx: &mut Context<Self>) -> Self {
let show_excerpt_controls = self.display_map.read(cx).show_excerpt_controls();
let mut clone = Self::new(
self.mode,
self.buffer.clone(),
self.project.clone(),
show_excerpt_controls,
window,
cx,
);
@ -1183,7 +1169,6 @@ impl Editor {
mode: EditorMode,
buffer: Entity<MultiBuffer>,
project: Option<Entity<Project>>,
show_excerpt_controls: bool,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
@ -1228,10 +1213,8 @@ impl Editor {
style.font(),
font_size,
None,
show_excerpt_controls,
FILE_HEADER_HEIGHT,
MULTI_BUFFER_EXCERPT_HEADER_HEIGHT,
MULTI_BUFFER_EXCERPT_FOOTER_HEIGHT,
fold_placeholder,
cx,
)
@ -4693,8 +4676,8 @@ impl Editor {
workspace.update_in(&mut cx, |workspace, window, cx| {
let project = workspace.project().clone();
let editor = cx
.new(|cx| Editor::for_multibuffer(excerpt_buffer, Some(project), true, window, cx));
let editor =
cx.new(|cx| Editor::for_multibuffer(excerpt_buffer, Some(project), window, cx));
workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx);
editor.update(cx, |editor, cx| {
editor.highlight_background::<Self>(
@ -12381,7 +12364,6 @@ impl Editor {
Editor::for_multibuffer(
excerpt_buffer,
Some(workspace.project().clone()),
true,
window,
cx,
)