sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.16k stars 210 forks source link

Home and End should operate on displayed lines #7714

Open novoselt opened 1 month ago

novoselt commented 1 month ago

Describe the bug A the moment Home/End operate on file lines/paragraphs.

To Reproduce Steps to reproduce the behavior:

  1. In an editor, e.g. Markdown, create a long line that gets wrapped, i.e. one "file line" gets broken into multiple "displayed lines".
  2. Press Home or End button while you are somewhere in that block of text.
  3. The cursor will go to the beginning/end of the file line!

Expected behavior I have never seen such a behaviour in any other editor. JupyterLab and VS Code launched from CoCalc operate on displayed lines (although VS Code has wrapping off by default, eliminating the chance of this problem).

This is of little consequence for editing code, which should have short enough lines to be readable. But when one writes plain prose, file lines correspond to paragraphs and can be quite long, so it makes little sense to jump to their start/end instead of start/end of the line that I see as being edited in front of me.

williamstein commented 1 month ago

This is what CodeMirror 5 does (see, e.g., this demo on their site: https://codemirror.net/5/demo/indentwrap.html). See https://github.com/sagemathinc/cocalc/issues/5401 for discussion about switching to CodeMirror 6, which is what JupyterLab uses.

Dupe of #5401 unless there is a configuration option for codemirror 5 to change this behavior (I didn't see one at https://codemirror.net/5/doc/manual.html#config, but there's a lot of options). You might also consider disabling line wrapping in your account prefs, if you don't want line wrapping.

For the arbitrariness of this behavior, I'll quote a random person on redit "The standard Home/End behavior has always been different on the Mac than in Windows, dating back to the 80s."

williamstein commented 1 month ago

For the record, my personal preference is probably what you're asking for. It also aligns with what Slate wyswiyg editing does. I just think it's something that is inherited from the choice of editor, hence #5401 .

Incidentally VS Code has the behavior you want -- just open a markdown file and line wrapping is ON by default, and it doesn't wrap by default.

williamstein commented 1 month ago

Why did you have to point this out? Now it is driving me crazy whenever I edit text in codemirror!