@@ -14703,6 +14703,7 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ let stop_at_indent = action.stop_at_indent && !self.mode.is_single_line();
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
self.change_selections(Default::default(), window, cx, |s| {
s.move_cursors_with(&mut |map, head, _| {
@@ -14711,7 +14712,7 @@ impl Editor {
map,
head,
action.stop_at_soft_wraps,
- action.stop_at_indent,
+ stop_at_indent,
),
SelectionGoal::None,
)
@@ -14725,6 +14726,7 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ let stop_at_indent = action.stop_at_indent && !self.mode.is_single_line();
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
self.change_selections(Default::default(), window, cx, |s| {
s.move_heads_with(&mut |map, head, _| {
@@ -14733,7 +14735,7 @@ impl Editor {
map,
head,
action.stop_at_soft_wraps,
- action.stop_at_indent,
+ stop_at_indent,
),
SelectionGoal::None,
)
@@ -1868,6 +1868,56 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) {
});
}
+#[gpui::test]
+fn test_beginning_of_line_single_line_editor(cx: &mut TestAppContext) {
+ init_test(cx, |_| {});
+
+ let editor = cx.add_window(|window, cx| Editor::single_line(window, cx));
+
+ _ = editor.update(cx, |editor, window, cx| {
+ editor.set_text(" indented text", window, cx);
+ editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
+ s.select_display_ranges([
+ DisplayPoint::new(DisplayRow(0), 10)..DisplayPoint::new(DisplayRow(0), 10)
+ ]);
+ });
+
+ editor.move_to_beginning_of_line(
+ &MoveToBeginningOfLine {
+ stop_at_soft_wraps: true,
+ stop_at_indent: true,
+ },
+ window,
+ cx,
+ );
+ assert_eq!(
+ display_ranges(editor, cx),
+ &[DisplayPoint::new(DisplayRow(0), 0)..DisplayPoint::new(DisplayRow(0), 0)]
+ );
+ });
+
+ _ = editor.update(cx, |editor, window, cx| {
+ editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
+ s.select_display_ranges([
+ DisplayPoint::new(DisplayRow(0), 10)..DisplayPoint::new(DisplayRow(0), 10)
+ ]);
+ });
+
+ editor.select_to_beginning_of_line(
+ &SelectToBeginningOfLine {
+ stop_at_soft_wraps: true,
+ stop_at_indent: true,
+ },
+ window,
+ cx,
+ );
+ assert_eq!(
+ display_ranges(editor, cx),
+ &[DisplayPoint::new(DisplayRow(0), 10)..DisplayPoint::new(DisplayRow(0), 0)]
+ );
+ });
+}
+
#[gpui::test]
fn test_beginning_end_of_line_ignore_soft_wrap(cx: &mut TestAppContext) {
init_test(cx, |_| {});