Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix first/last item margin on scroll (#8880)

Jason Lee0b34b1de7b74
diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs
index 0cd7f581def..c8a98962c90 100644
--- a/crates/command_palette/src/command_palette.rs
+++ b/crates/command_palette/src/command_palette.rs
@@ -396,6 +396,7 @@ impl PickerDelegate for CommandPaletteDelegate {
.child(
h_flex()
.w_full()
+ .py_px()
.justify_between()
.child(HighlightedLabel::new(
command.name.clone(),
diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs
index a8349a63357..5f2c874457d 100644
--- a/crates/file_finder/src/file_finder.rs
+++ b/crates/file_finder/src/file_finder.rs
@@ -880,6 +880,7 @@ impl PickerDelegate for FileFinderDelegate {
.child(
h_flex()
.gap_2()
+ .py_px()
.child(HighlightedLabel::new(file_name, file_name_positions))
.child(
HighlightedLabel::new(full_path, full_path_positions)
diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs
index f449862668f..90dd8da0c25 100644
--- a/crates/gpui/src/elements/list.rs
+++ b/crates/gpui/src/elements/list.rs
@@ -241,7 +241,7 @@ impl ListState {
let mut cursor = state.items.cursor::<ListItemSummary>();
cursor.seek(&Count(ix + 1), Bias::Right, &());
let bottom = cursor.start().height + padding.top;
- let goal_top = px(0.).max(bottom - height);
+ let goal_top = px(0.).max(bottom - height + padding.bottom);
cursor.seek(&Height(goal_top), Bias::Left, &());
let start_ix = cursor.start().count;
diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs
index 8a6651524b5..2d708f270e6 100644
--- a/crates/gpui/src/elements/uniform_list.rs
+++ b/crates/gpui/src/elements/uniform_list.rs
@@ -221,10 +221,10 @@ impl Element for UniformList {
let item_top = item_height * ix + padding.top;
let item_bottom = item_top + item_height;
let scroll_top = -updated_scroll_offset.y;
- if item_top < scroll_top {
- updated_scroll_offset.y = -item_top;
- } else if item_bottom > scroll_top + list_height {
- updated_scroll_offset.y = -(item_bottom - list_height);
+ if item_top < scroll_top + padding.top {
+ updated_scroll_offset.y = -(item_top) + padding.top;
+ } else if item_bottom > scroll_top + list_height - padding.bottom {
+ updated_scroll_offset.y = -(item_bottom - list_height) - padding.bottom;
}
scroll_offset = *updated_scroll_offset;
}