Avoid overwriting mouse wheel scroll with selection auto-scroll
This commit is contained in:
parent
c5465d26f8
commit
a2aa47aba2
3 changed files with 27 additions and 8 deletions
|
@ -281,7 +281,7 @@ pub enum SelectPhase {
|
||||||
Update {
|
Update {
|
||||||
position: DisplayPoint,
|
position: DisplayPoint,
|
||||||
goal_column: u32,
|
goal_column: u32,
|
||||||
scroll_position: gpui::Point<f32>,
|
scroll_delta: gpui::Point<f32>,
|
||||||
},
|
},
|
||||||
End,
|
End,
|
||||||
}
|
}
|
||||||
|
@ -1928,8 +1928,8 @@ impl Editor {
|
||||||
SelectPhase::Update {
|
SelectPhase::Update {
|
||||||
position,
|
position,
|
||||||
goal_column,
|
goal_column,
|
||||||
scroll_position,
|
scroll_delta,
|
||||||
} => self.update_selection(position, goal_column, scroll_position, cx),
|
} => self.update_selection(position, goal_column, scroll_delta, cx),
|
||||||
SelectPhase::End => self.end_selection(cx),
|
SelectPhase::End => self.end_selection(cx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2063,7 +2063,7 @@ impl Editor {
|
||||||
&mut self,
|
&mut self,
|
||||||
position: DisplayPoint,
|
position: DisplayPoint,
|
||||||
goal_column: u32,
|
goal_column: u32,
|
||||||
scroll_position: gpui::Point<f32>,
|
scroll_delta: gpui::Point<f32>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
@ -2152,7 +2152,7 @@ impl Editor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_scroll_position(scroll_position, cx);
|
self.apply_scroll_delta(scroll_delta, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -531,8 +531,7 @@ impl EditorElement {
|
||||||
SelectPhase::Update {
|
SelectPhase::Update {
|
||||||
position: point_for_position.previous_valid,
|
position: point_for_position.previous_valid,
|
||||||
goal_column: point_for_position.exact_unclipped.column(),
|
goal_column: point_for_position.exact_unclipped.column(),
|
||||||
scroll_position: (position_map.snapshot.scroll_position() + scroll_delta)
|
scroll_delta,
|
||||||
.clamp(&gpui::Point::default(), &position_map.scroll_max),
|
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
@ -327,6 +327,16 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn apply_scroll_delta(
|
||||||
|
&mut self,
|
||||||
|
scroll_delta: gpui::Point<f32>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
|
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
let position = self.scroll_manager.anchor.scroll_position(&display_map) + scroll_delta;
|
||||||
|
self.set_scroll_position_taking_display_map(position, true, false, display_map, cx);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_scroll_position(
|
pub fn set_scroll_position(
|
||||||
&mut self,
|
&mut self,
|
||||||
scroll_position: gpui::Point<f32>,
|
scroll_position: gpui::Point<f32>,
|
||||||
|
@ -343,12 +353,22 @@ impl Editor {
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
let map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
let map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
|
self.set_scroll_position_taking_display_map(scroll_position, local, autoscroll, map, cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_scroll_position_taking_display_map(
|
||||||
|
&mut self,
|
||||||
|
scroll_position: gpui::Point<f32>,
|
||||||
|
local: bool,
|
||||||
|
autoscroll: bool,
|
||||||
|
display_map: DisplaySnapshot,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
hide_hover(self, cx);
|
hide_hover(self, cx);
|
||||||
let workspace_id = self.workspace.as_ref().map(|workspace| workspace.1);
|
let workspace_id = self.workspace.as_ref().map(|workspace| workspace.1);
|
||||||
self.scroll_manager.set_scroll_position(
|
self.scroll_manager.set_scroll_position(
|
||||||
scroll_position,
|
scroll_position,
|
||||||
&map,
|
&display_map,
|
||||||
local,
|
local,
|
||||||
autoscroll,
|
autoscroll,
|
||||||
workspace_id,
|
workspace_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue