Skip to content

Conversation

@dinocosta
Copy link
Contributor

@dinocosta dinocosta commented Oct 14, 2025

  • Move the start_of_relative_buffer_row function from the vim::motion module to the editor::display_map::DisplaySnapshot implementation as a method.
  • Add skip_soft_wrap field to both AddSelectionAbove and AddSelectionBelow actions. When set to true, this will skip soft wrapped lines when extending the selections.
  • 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 #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 }]
      }
    }
    

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.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 14, 2025
@dinocosta dinocosta self-assigned this Oct 14, 2025
dinocosta and others added 3 commits October 14, 2025 16:36
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]>
@dinocosta dinocosta force-pushed the 16979-add-selection-fix branch from 9000464 to d972f21 Compare October 15, 2025 12:27
@dinocosta dinocosta marked this pull request as ready for review October 15, 2025 12:50
@dinocosta
Copy link
Contributor Author

@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 Default trait for both AddSelectionAbove and AddSelectionBelow, as I've confirmed that Serde's #[serde(default = ...)] is only meant for deserialization, to know which values to use if fields are not specified 👍

@dinocosta dinocosta requested a review from smitbarmase October 15, 2025 12:51
@dinocosta dinocosta merged commit 5c4f1e6 into main Oct 16, 2025
24 checks passed
@dinocosta dinocosta deleted the 16979-add-selection-fix branch October 16, 2025 10:56
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

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddSelectionAbove/AddSelectionBelow adds selection on the same line if soft-wrapped

2 participants