Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/agent_ui/src/entry_view_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ fn create_editor_diff(
editor.set_show_vertical_scrollbar(false, cx);
editor.set_minimap_visibility(MinimapVisibility::Disabled, window, cx);
editor.set_soft_wrap_mode(SoftWrap::None, cx);
editor.scroll_manager.set_forbid_vertical_scroll(true);
editor.set_forbid_vertical_scroll(true);
editor.set_show_indent_guides(false, cx);
editor.set_read_only(true);
editor.set_delegate_open_excerpts(true);
Expand Down
2 changes: 1 addition & 1 deletion crates/agent_ui/src/inline_assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ impl InlineAssistant {
editor.set_show_gutter(false, cx);
editor.set_offset_content(false, cx);
editor.disable_mouse_wheel_zoom();
editor.scroll_manager.set_forbid_vertical_scroll(true);
editor.set_forbid_vertical_scroll(true);
editor.set_read_only(true);
editor.set_show_edit_predictions(Some(false), window, cx);
editor.highlight_rows::<DeletedLines>(
Expand Down
7 changes: 6 additions & 1 deletion crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,12 @@ pub struct Editor {
pub display_map: Entity<DisplayMap>,
placeholder_display_map: Option<Entity<DisplayMap>>,
pub selections: SelectionsCollection,
pub scroll_manager: ScrollManager,
/// Manages the scroll position for the given editor.
///
/// Whenever you want to modify the scroll position of the editor, you should
/// usually use the existing available APIs as opposed to directly interacting
/// with the scroll manager.
pub(crate) scroll_manager: ScrollManager,
/// When inline assist editors are linked, they all render cursors because
/// typing enters text into each of them, even the ones that aren't focused.
pub(crate) show_cursor_when_unfocused: bool,
Expand Down
8 changes: 8 additions & 0 deletions crates/editor/src/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ impl Editor {
self.scroll_manager.has_autoscroll_request()
}

pub fn set_forbid_vertical_scroll(&mut self, forbid: bool) {
self.scroll_manager.set_forbid_vertical_scroll(forbid);
}

pub fn scroll_top_display_point(&self, snapshot: &DisplaySnapshot, cx: &App) -> DisplayPoint {
self.scroll_manager.scroll_top_display_point(snapshot, cx)
}

pub fn vertical_scroll_margin(&self) -> usize {
self.scroll_manager.vertical_scroll_margin as usize
}
Expand Down
8 changes: 2 additions & 6 deletions crates/vim/src/normal/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ impl Vim {
self.update_editor(cx, |vim, editor, cx| {
let should_move_cursor = editor.newest_selection_on_screen(cx).is_eq();
let display_snapshot = editor.display_map.update(cx, |map, cx| map.snapshot(cx));
let old_top = editor
.scroll_manager
.scroll_top_display_point(&display_snapshot, cx);
let old_top = editor.scroll_top_display_point(&display_snapshot, cx);

if editor.scroll_hover(amount, window, cx) {
return;
Expand Down Expand Up @@ -143,9 +141,7 @@ impl Vim {
};

let display_snapshot = editor.display_map.update(cx, |map, cx| map.snapshot(cx));
let top = editor
.scroll_manager
.scroll_top_display_point(&display_snapshot, cx);
let top = editor.scroll_top_display_point(&display_snapshot, cx);
let vertical_scroll_margin = EditorSettings::get_global(cx).vertical_scroll_margin;

let mut move_cursor = |map: &editor::display_map::DisplaySnapshot,
Expand Down
Loading