Allow ignoring soft wraps when moving to line ends (#11153)
Release Notes: - Fixed #10888 This patch addresses behavior of `Editor::move_to_{beginning|end}_of_line`. It adds a setting, `stop_at_soft_wraps` when defining a keymap for the `editor::MoveToBeginningOfLine` and `editor::MoveToEndOfLine` actions. When `true`, it causes movement to the either end of the line (via, for example Home or End), to go to the logical end, as opposed to the nearest soft wrap point in the respective direction. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
parent
c81230405f
commit
edff78e722
6 changed files with 140 additions and 27 deletions
|
@ -6240,13 +6240,13 @@ impl Editor {
|
|||
|
||||
pub fn move_to_beginning_of_line(
|
||||
&mut self,
|
||||
_: &MoveToBeginningOfLine,
|
||||
action: &MoveToBeginningOfLine,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_cursors_with(|map, head, _| {
|
||||
(
|
||||
movement::indented_line_beginning(map, head, true),
|
||||
movement::indented_line_beginning(map, head, action.stop_at_soft_wraps),
|
||||
SelectionGoal::None,
|
||||
)
|
||||
});
|
||||
|
@ -6290,10 +6290,13 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn move_to_end_of_line(&mut self, _: &MoveToEndOfLine, cx: &mut ViewContext<Self>) {
|
||||
pub fn move_to_end_of_line(&mut self, action: &MoveToEndOfLine, cx: &mut ViewContext<Self>) {
|
||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.move_cursors_with(|map, head, _| {
|
||||
(movement::line_end(map, head, true), SelectionGoal::None)
|
||||
(
|
||||
movement::line_end(map, head, action.stop_at_soft_wraps),
|
||||
SelectionGoal::None,
|
||||
)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue