-
Notifications
You must be signed in to change notification settings - Fork 5.8k
editor: Ignore soft wrapped lines when adding selection above or below #40190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move the `start_of_relative_buffer_row` function from the `vim::motion` module to the `editor::display_map::DisplaySnapshot` implementation as a method, which will come in handy when updating the `AddSelectionBelow` and `AddSelectionAbove` logic. Callers of the previous `start_of_relative_buffer_row` implementation have also been updated.
Update the behavior for both `AddSelectionAbove` and `AddSelectionBelow` so that soft wrapped lines are ignored.
Update the `AddSelectionAbove` and `AddSelectionBelow` editor actions with an optional field, `skip_soft_wrap`, which when set to `true` will jump over soft wrapped lines when expanding the selection. This is now set by default to `true` in order to mimick VS Code's default behavior, but can still be overriden by users in their keymap. Co-authored-by: Smit Barmase <[email protected]>
Update the tests for the `AddSelectionAbove` and `AddSelectionBelow` when `skip_soft_wrap` is enabled or disabled. Co-authored-by: Smit Barmase <[email protected]>
9000464 to
d972f21
Compare
|
@smitbarmase I've pushed the final commit – d972f21 ✅ Feel free to take a look at the test and let me know if it looks good! I've also removed the implementation of the |
xipeng-jin
pushed a commit
to xipeng-jin/zed
that referenced
this pull request
Oct 17, 2025
zed-industries#40190) - Add `skip_soft_wrap` field to both `AddSelectionAbove` and `AddSelectionBelow` actions. When set to `true`, which is now the default this will skip soft wrapped lines when extending the selections. - Move the `start_of_relative_buffer_row` function from the `vim::motion` module to the `editor::display_map::DisplaySnapshot` implementation as a method. - Update the default behavior for both `editor: add selection above` and `editor: add selection below` commands in order to skip over soft wrapped lines by default, mirroring VS Code's default behavior. - Update existing keymaps to specify this `skip_soft_wrap` value for both `AddSelectionAbove` and `AddSelectionBelow` actions. Closes zed-industries#16979 Release Notes: - Updated both the `editor: add selection above` and `editor: add selection below` commands to ignore soft wrapped lines. If you wish to restore the old behavior, add the following to your keymap file: ``` { "context": "Editor", "bindings": { "cmd-alt-up": ["editor::AddSelectionAbove", { "skip_soft_wrap": false }], "cmd-alt-down": ["editor::AddSelectionBelow", { "skip_soft_wrap": false }] } } ``` --------- Co-authored-by: Smit Barmase <[email protected]>
P1n3appl3
pushed a commit
to P1n3appl3/zed
that referenced
this pull request
Oct 18, 2025
zed-industries#40190) - Add `skip_soft_wrap` field to both `AddSelectionAbove` and `AddSelectionBelow` actions. When set to `true`, which is now the default this will skip soft wrapped lines when extending the selections. - Move the `start_of_relative_buffer_row` function from the `vim::motion` module to the `editor::display_map::DisplaySnapshot` implementation as a method. - Update the default behavior for both `editor: add selection above` and `editor: add selection below` commands in order to skip over soft wrapped lines by default, mirroring VS Code's default behavior. - Update existing keymaps to specify this `skip_soft_wrap` value for both `AddSelectionAbove` and `AddSelectionBelow` actions. Closes zed-industries#16979 Release Notes: - Updated both the `editor: add selection above` and `editor: add selection below` commands to ignore soft wrapped lines. If you wish to restore the old behavior, add the following to your keymap file: ``` { "context": "Editor", "bindings": { "cmd-alt-up": ["editor::AddSelectionAbove", { "skip_soft_wrap": false }], "cmd-alt-down": ["editor::AddSelectionBelow", { "skip_soft_wrap": false }] } } ``` --------- Co-authored-by: Smit Barmase <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
start_of_relative_buffer_rowfunction from thevim::motionmodule to theeditor::display_map::DisplaySnapshotimplementation as a method.skip_soft_wrapfield to bothAddSelectionAboveandAddSelectionBelowactions. When set totrue, this will skip soft wrapped lines when extending the selections.editor: add selection aboveandeditor: add selection belowcommands in order to skip over soft wrapped lines by default, mirroring VS Code's default behavior.skip_soft_wrapvalue for bothAddSelectionAboveandAddSelectionBelowactions.Closes #16979
Release Notes:
editor: add selection aboveandeditor: add selection belowcommands to ignore soft wrapped lines. If you wish to restore the old behavior, add the following to your keymap file: