Improve multibuffer excerpt affordances (#22167)

Changes:
- [x] Increase expand affordance surface area
- [x] Ensure expand buttons have tooltips with keybindings
- [x] Make line numbers clickable to jump you to location (only in
multibuffers)
- [x] Hide the "Jump To File" element in not-focused excerpts

Before merging it:

- [x] Fix off-by-one header focus styles glitch

Improvements to consider for follow-up PRs:

1. Experiment with increasing the width of the clickable surface area
for line numbers
2. Don't show (or disable) the "expand excerpt" button when at the top
or bottom edge of the file
3. Once you jump to location, centralize the cursor scroll position

Release Notes:

- Improved multibuffer's "expand excerpt" affordance
- Fixed "jump to file/location" and "expand excerpt" keybinding display
- Made clicking on line numbers in multibuffers jump you to cursor
location in file

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Danilo Leal
2024-12-30 12:23:11 +00:00
committed by GitHub
co-authored by Thorsten Ball Agus Zubiaga Kirill Bulatov Agus Zubiaga
parent 3f33ca01a8
commit ad51df7644
6 changed files with 513 additions and 316 deletions
+18
View File
@@ -3449,6 +3449,24 @@ impl MultiBufferSnapshot {
}
}
pub fn buffer_ids_in_selected_rows(
&self,
selection: Selection<Point>,
) -> impl Iterator<Item = BufferId> + '_ {
let mut cursor = self.excerpts.cursor::<Point>(&());
cursor.seek(&Point::new(selection.start.row, 0), Bias::Right, &());
cursor.prev(&());
iter::from_fn(move || {
cursor.next(&());
if cursor.start().row <= selection.end.row {
cursor.item().map(|item| item.buffer_id)
} else {
None
}
})
}
pub fn excerpts(
&self,
) -> impl Iterator<Item = (ExcerptId, &BufferSnapshot, ExcerptRange<text::Anchor>)> {