Skip to content
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

Option Shift text selection on Mac OS #10242

Closed
1 task done
jish opened this issue Apr 6, 2024 · 7 comments
Closed
1 task done

Option Shift text selection on Mac OS #10242

jish opened this issue Apr 6, 2024 · 7 comments
Labels
defect [core label] good first issue Issue suitable for first-time contributors keymap / key binding Feedback for keyboard shortcuts, key mapping, etc

Comments

@jish
Copy link

jish commented Apr 6, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Selecting text using the option key, shift, and the arrow keys is a common part of my text editing workflow. I feel that the selection behavior is not quite right when using the "base_keymap": "TextMate" configuration.

Here is an example of the behavior in Zed when pressing option + shift + left-arrow:

zed-base-keymap-textmate-option-shift-arrow.mov

Here is the exact same source code file, and keystrokes in TextMate:

textmate-option-shift-arrow.mov

Now, if I change base keymap setting to use Sublime instead "base_keymap": "SublimeText" then I get slightly different behavior:

zed-base-keymap-sublimetext-option-shift-arrow.mov

Environment

Zed: v0.129.2 (Zed)
OS: macOS 14.1.1
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

I believe selecting text with option shift and arrow keys should have logical stops to progressively select more and more text, instead of selecting the entire line.

textmate-option-shift-arrow.mov

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

@jish jish added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels Apr 6, 2024
@jish
Copy link
Author

jish commented Apr 6, 2024

I can fix this issue by copying the "alt-shift-left" and "alt-shift-right" configurations from Default Key Bindings to my ~/.config/zed/keymap.json:

[
  {
    "context": "Editor",
    "bindings": {
      "alt-shift-left": "editor::SelectToPreviousWordStart",
      "alt-shift-right": "editor::SelectToNextWordEnd"
    }
  }
]

Maybe this could be solved by removing the "alt-shift-left" and "alt-shift-right" overrides from assets/keymaps/textmate.json?

"alt-shift-left": [
"editor::SelectToBeginningOfLine",
{
"stop_at_soft_wraps": true
}
],
"alt-shift-right": [
"editor::SelectToEndOfLine",
{
"stop_at_soft_wraps": true
}
],

@JosephTLyons JosephTLyons added keymap / key binding Feedback for keyboard shortcuts, key mapping, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Apr 8, 2024
@JosephTLyons
Copy link
Contributor

JosephTLyons commented Apr 8, 2024

If TextMate ships with the behavior of jumping by words, rather than to the beginning of the line, we should change it to that. Hey @caius, curious what you think here. Caius did the work adding in the TextMate keymap originally, back when they keymaps were in the keymaps repository, before the Zed repository was open source.

@JosephTLyons
Copy link
Contributor

Just checked - I downloaded TextMate and its default behavior is as described by @jish.

@caius
Copy link
Contributor

caius commented Apr 8, 2024

Ha, this annoys me on occasion too. I either missed there was select to previous/next word start, or they’ve been added since we setup the keymap and I’ve not noticed.

We should remove the overrides as suggested if the default keymap behaves correctly from TextMate’s point of view.

@jish thanks for raising an issue for it, doubt I’d have noticed otherwise 🙂

@JosephTLyons JosephTLyons added the good first issue Issue suitable for first-time contributors label Apr 8, 2024
@JosephTLyons
Copy link
Contributor

JosephTLyons commented Apr 8, 2024

Would we want to simply remove those? The default bindings use the same keys, but they do not explicitly set "stop_at_soft_wraps": true, as these do in the TextMate keymap.

At any rate, I've marked this as a good first issue - feel free to open a PR here, @jish. :)

jish added a commit to jish/zed that referenced this issue Apr 14, 2024
By default when pressing the option+shift+arrow keys selection should
jump to words along the way rather than selecting the entire line.

zed-industries#10242
mrnugget pushed a commit that referenced this issue May 3, 2024
Not sure what the etiquette is here, but in the interest of fixing
#10242, I've re-implemented @jish's PR
#10535 and have signed the CLA


Release Notes:

- Fixed `alt-shift-left` and `alt-shift-right` in the Textmate default
keybindings.
([#10242](#10242))

TextMate keymap uses default option shift arrow selection
@JosephTLyons
Copy link
Contributor

This should be fixed now in v0.135.0-pre.

@ylluminate
Copy link

I've always used and preferred option-click-drag for selection of regions vs having to add shift to the mix. What can we do to rectify this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect [core label] good first issue Issue suitable for first-time contributors keymap / key binding Feedback for keyboard shortcuts, key mapping, etc
Projects
None yet
Development

No branches or pull requests

4 participants