mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fix first/last item margin on scroll (#8880)
![output](https://github.com/zed-industries/zed/assets/5518/e39a3600-99c4-4d3c-baee-efd53a474f38) Before: https://github.com/zed-industries/zed/assets/5518/f7a4563a-504a-4a41-bfd4-21e9439cd02b After: https://github.com/zed-industries/zed/assets/5518/0ba41527-46fd-404f-8207-1b8c5cf37434 Release Notes: - Fixed first and last item margin when scroll view has padding
This commit is contained in:
parent
537d92533c
commit
0b34b1de7b
@ -396,6 +396,7 @@ impl PickerDelegate for CommandPaletteDelegate {
|
||||
.child(
|
||||
h_flex()
|
||||
.w_full()
|
||||
.py_px()
|
||||
.justify_between()
|
||||
.child(HighlightedLabel::new(
|
||||
command.name.clone(),
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user