diff --git a/.zed/settings.json b/.zed/settings.json index 41adfdbf59..a8e356a73e 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -14,12 +14,12 @@ }, "JSON": { "tab_size": 2, - "preferred_line_length": 100, + "preferred_line_length": 120, "formatter": "prettier" }, "JSONC": { "tab_size": 2, - "preferred_line_length": 100, + "preferred_line_length": 120, "formatter": "prettier" }, "JavaScript": { diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 1b4a3c9523..849bb98c91 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -84,7 +84,7 @@ "pageup": "editor::MovePageUp", "alt-pageup": "editor::PageUp", "shift-pageup": "editor::SelectPageUp", - "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true }], + "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], "down": "editor::MoveDown", "pagedown": "editor::MovePageDown", "alt-pagedown": "editor::PageDown", @@ -107,9 +107,9 @@ "ctrl-a": "editor::SelectAll", "ctrl-l": "editor::SelectLine", "ctrl-shift-i": "editor::Format", - // "cmd-shift-left": ["editor::SelectToBeginningOfLine", {"stop_at_soft_wraps": true }], - // "ctrl-shift-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], - "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], + // "cmd-shift-left": ["editor::SelectToBeginningOfLine", {"stop_at_soft_wraps": true, "stop_at_indent": true }], + // "ctrl-shift-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], + "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], // "cmd-shift-right": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], // "ctrl-shift-e": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], "shift-end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index a5867b3708..e1b5992f76 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -91,9 +91,9 @@ "ctrl-l": "editor::ScrollCursorCenter", "alt-left": "editor::MoveToPreviousWordStart", "alt-right": "editor::MoveToNextWordEnd", - "cmd-left": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true }], - "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], - "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true }], + "cmd-left": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], + "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false, "stop_at_indent": true }], + "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], "cmd-right": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": true }], "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], "end": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": true }], @@ -118,9 +118,9 @@ "cmd-a": "editor::SelectAll", "cmd-l": "editor::SelectLine", "cmd-shift-i": "editor::Format", - "cmd-shift-left": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], - "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], - "ctrl-shift-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true }], + "cmd-shift-left": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], + "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], + "ctrl-shift-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": true, "stop_at_indent": true }], "cmd-shift-right": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], "shift-end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], "ctrl-shift-e": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": true }], diff --git a/assets/keymaps/linux/emacs.json b/assets/keymaps/linux/emacs.json index cf1afd309c..4a0f55fd06 100755 --- a/assets/keymaps/linux/emacs.json +++ b/assets/keymaps/linux/emacs.json @@ -28,6 +28,7 @@ "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line "shift-end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line + "alt-m": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false, "stop_at_indent": true }], // back-to-indentation "alt-f": "editor::MoveToNextSubwordEnd", // forward-word "alt-b": "editor::MoveToPreviousSubwordStart", // backward-word "alt-u": "editor::ConvertToUpperCase", // upcase-word diff --git a/assets/keymaps/macos/emacs.json b/assets/keymaps/macos/emacs.json index cf1afd309c..4a0f55fd06 100755 --- a/assets/keymaps/macos/emacs.json +++ b/assets/keymaps/macos/emacs.json @@ -28,6 +28,7 @@ "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line "shift-end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line + "alt-m": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false, "stop_at_indent": true }], // back-to-indentation "alt-f": "editor::MoveToNextSubwordEnd", // forward-word "alt-b": "editor::MoveToPreviousSubwordStart", // backward-word "alt-u": "editor::ConvertToUpperCase", // upcase-word diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index fad77993fa..f01a869171 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -22,6 +22,8 @@ pub struct SelectPrevious { pub struct MoveToBeginningOfLine { #[serde(default = "default_true")] pub stop_at_soft_wraps: bool, + #[serde(default)] + pub stop_at_indent: bool, } #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)] @@ -29,6 +31,8 @@ pub struct MoveToBeginningOfLine { pub struct SelectToBeginningOfLine { #[serde(default)] pub(super) stop_at_soft_wraps: bool, + #[serde(default)] + pub stop_at_indent: bool, } #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)] diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 62c3b39fde..801b500e8c 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9371,7 +9371,12 @@ impl Editor { self.change_selections(Some(Autoscroll::fit()), window, cx, |s| { s.move_cursors_with(|map, head, _| { ( - movement::indented_line_beginning(map, head, action.stop_at_soft_wraps), + movement::indented_line_beginning( + map, + head, + action.stop_at_soft_wraps, + action.stop_at_indent, + ), SelectionGoal::None, ) }); @@ -9387,7 +9392,12 @@ impl Editor { self.change_selections(Some(Autoscroll::fit()), window, cx, |s| { s.move_heads_with(|map, head, _| { ( - movement::indented_line_beginning(map, head, action.stop_at_soft_wraps), + movement::indented_line_beginning( + map, + head, + action.stop_at_soft_wraps, + action.stop_at_indent, + ), SelectionGoal::None, ) }); @@ -9410,6 +9420,7 @@ impl Editor { this.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: false, + stop_at_indent: false, }, window, cx, diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index aeff3dcc61..ebcff06152 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -1510,6 +1510,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { init_test(cx, |_| {}); let move_to_beg = MoveToBeginningOfLine { stop_at_soft_wraps: true, + stop_at_indent: true, }; let move_to_end = MoveToEndOfLine { @@ -1590,6 +1591,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { editor.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: true, + stop_at_indent: true, }, window, cx, @@ -1607,6 +1609,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { editor.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: true, + stop_at_indent: true, }, window, cx, @@ -1624,6 +1627,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { editor.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: true, + stop_at_indent: true, }, window, cx, @@ -1684,6 +1688,7 @@ fn test_beginning_end_of_line_ignore_soft_wrap(cx: &mut TestAppContext) { init_test(cx, |_| {}); let move_to_beg = MoveToBeginningOfLine { stop_at_soft_wraps: false, + stop_at_indent: false, }; let move_to_end = MoveToEndOfLine { diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index fb4b6683c6..abf66ace2d 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -214,6 +214,7 @@ pub fn indented_line_beginning( map: &DisplaySnapshot, display_point: DisplayPoint, stop_at_soft_boundaries: bool, + stop_at_indent: bool, ) -> DisplayPoint { let point = display_point.to_point(map); let soft_line_start = map.clip_point(DisplayPoint::new(display_point.row(), 0), Bias::Right); @@ -229,7 +230,7 @@ pub fn indented_line_beginning( if stop_at_soft_boundaries && soft_line_start > indent_start && display_point != soft_line_start { soft_line_start - } else if stop_at_soft_boundaries && display_point != indent_start { + } else if stop_at_indent && display_point != indent_start { indent_start } else { line_start diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index f04905cd91..de5a68ac3f 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1034,6 +1034,7 @@ impl ProjectPanel { editor.move_to_beginning_of_line( &editor::actions::MoveToBeginningOfLine { stop_at_soft_wraps: false, + stop_at_indent: false, }, window, cx, diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index e2266f5f69..8b6e94c630 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -188,7 +188,7 @@ impl Vim { ) .0; } - cursor = movement::indented_line_beginning(map, cursor, true); + cursor = movement::indented_line_beginning(map, cursor, true, true); } else if !is_multiline && !vim.temp_mode { cursor = movement::saturating_left(map, cursor) }