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

Incorrect control-A and control-E behavior with soft_wrap #4554

Closed
1 task done
sethherr opened this issue Aug 3, 2023 · 4 comments
Closed
1 task done

Incorrect control-A and control-E behavior with soft_wrap #4554

sethherr opened this issue Aug 3, 2023 · 4 comments
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc

Comments

@sethherr
Copy link

sethherr commented Aug 3, 2023

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

When editing a file that with soft wrapping:

  • control-e goes to the end of the soft-wrap line
  • control-a goes to the beginning of the soft-wrap line

These should go to the beginning and end of the line, not the soft wrapped character limit.

control-k behaves correctly, and deletes to the end of the line, rather than the soft-wrap line.

Environment

Zed: v0.97.5 (stable)
OS: macOS 13.4.1
Memory: 32 GiB
Architecture: aarch64

@sethherr sethherr added admin read bug [core label] labels Aug 3, 2023
@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc and removed triage labels Aug 3, 2023
@failable
Copy link

failable commented Aug 4, 2023

I think that's desired behavior. If you want to go to the 'real' beginning/end of line, just ctrl a / ctrl e again.

@sethherr
Copy link
Author

sethherr commented Aug 4, 2023

Oh, I didn't know about double pressing to go to the real beginning of the line. That's great @liebkne!

It seems a little surprising though, do other apps have that behavior?

Would it make sense to make ctrl + k do the same thing?

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@notpeter
Copy link
Member

notpeter commented Jul 11, 2024

I don't like Zed's handling of ctrl-e and ctrl-a with soft-wrap enabled. It is surprising that behavior changes depending on the width of my editor pane: "ctrl-e goes to the end of the line, unless your window is narrow and then you have to press ctrl-e twice".

So I took a survey:

Editors that ignore soft wrap when jumping to the beginning/end with ctrl-a/ctrl-e

  • TextEdit
  • EMacs
  • VSCode
  • Atom
  • Sublime
  • Native MacOS controls (e.g. this textbox in Chrome)
  • Lapce (broken, but it tries)

Same as Zed (double tap when navigating thru a word wrap):

  • GNU nano (esc $ to enable softwrap)
  • Kate
  • IntelliJ (kinda broken). First ctrl-e goes to the last non space at end of the soft-wrapped line. A second ctrl-e moves one character over after the trailing space. A third ctrl-e will jump you to the real end of the line.

@notpeter
Copy link
Member

This is now supported via custom keymap. Here's what I use:

[
  {
    "context": "Editor",
    "bindings": {
      "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }],
      "end": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }],
      "cmd-left": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }],
      "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }],
      "cmd-right": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }],
      "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }]
    }
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc
Projects
None yet
Development

No branches or pull requests

4 participants