Prefer revealing items in the middle of the list for outline and project panels (#20349)
Closes https://github.com/zed-industries/zed/issues/18255 Zed does not scroll always, but only if the item is out of sight, this is preserved for now. Otherwise, if the item is out of sight, project and outline panels + the syntax tree view now attempt to scroll it into the middle, if there's enough elements above and below. Release Notes: - Improved revealing items for outline and project panels (now center of the list is preferred)
This commit is contained in:
@@ -2,8 +2,8 @@ use editor::{scroll::Autoscroll, Anchor, Editor, ExcerptId};
|
||||
use gpui::{
|
||||
actions, div, rems, uniform_list, AppContext, Div, EventEmitter, FocusHandle, FocusableView,
|
||||
Hsla, InteractiveElement, IntoElement, Model, MouseButton, MouseDownEvent, MouseMoveEvent,
|
||||
ParentElement, Render, SharedString, Styled, UniformListScrollHandle, View, ViewContext,
|
||||
VisualContext, WeakView, WindowContext,
|
||||
ParentElement, Render, ScrollStrategy, SharedString, Styled, UniformListScrollHandle, View,
|
||||
ViewContext, VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use language::{Buffer, OwnedSyntaxLayer};
|
||||
use std::{mem, ops::Range};
|
||||
@@ -199,7 +199,8 @@ impl SyntaxTreeView {
|
||||
|
||||
let descendant_ix = cursor.descendant_index();
|
||||
self.selected_descendant_ix = Some(descendant_ix);
|
||||
self.list_scroll_handle.scroll_to_item(descendant_ix);
|
||||
self.list_scroll_handle
|
||||
.scroll_to_item(descendant_ix, ScrollStrategy::Center);
|
||||
|
||||
cx.notify();
|
||||
Some(())
|
||||
|
||||
Reference in New Issue
Block a user