pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.24k stars 137 forks source link

Rename some line-movement commands to remove confusion #1041

Open savetheclocktower opened 3 months ago

savetheclocktower commented 3 months ago

Thanks in advance for your bug report!

What happened?

In investigating the regression from #810, we discovered some strange things about how these commands behave.

Here are three commands and how they are mapped in macOS right now:

So we have several problems:

Which methods are affected?

Let's go down the rabbit hole and study what happens when you invoke each of these.

What do we do about it?

First of all, we need not change how any existing API method behaves. But we should add some new methods that are unambiguous about whether they refer to buffer lines or screen lines.

If you look through TextEditor, you’d be hard-pressed to find other methods that are ambiguous about which coordinate system they use. They were all renamed long ago to avoid this kind of confusion.

These operate on buffer lines:

We should keep them that way, but deprecate them; they should be aliases for other methods in which Line is replaced with BufferLine.

(There are no TextEditor#cutToBeginningOfLine or Selection#cutToBeginningOfLine methods, and I think we should keep it that way.)

These operate on screen lines:

We should keep them that way, but deprecate them; they should be aliases for other methods in which Line is replaced with ScreenLine.

Some of these methods exist already, though

Selection…

…has selectToBeginningOfLine and selectToEndOfLine (which operate on buffer and screen coordinates, respectively) but also selectToEndOfBufferLine. There is no corresponding selectToBeginningOfBufferLine.

It has cutToEndOfBufferLine already.

Cursor…

…is a special case. It already has moveTo(Beginning|End)OfScreenLine, but its corresponding buffer versions are just called moveTo(Beginning|End)OfLine. These latter two should be deprecated and aliases should be added called moveTo(Beginning|End)OfBufferLine.

In summary…

Create these methods:

Deprecate and alias these methods:

What do we do about the command names?

We can use the same strategy: keep the old command names, keep them doing the same things they've always done, but introduce new command names that are unambiguous.

And what do we do about the macOS keybindings?

That's up for discussion. I don't have any problem with remapping Cmd+Delete and Ctrl+K to match VS Code and Sublime Text, even if it's a change in behavior. Any user that is negatively affected by this will have an easy workaround; we can even mention it in the changelog if we want to.

But I'd be more than happy to hear rebuttals.

Pulsar version

1.118 (and all previous versions)

Which OS does this happen on?

❓ Other(Please specify in the OS details field below)

OS details

all OSes

Which CPU architecture are you running this on?

None

What steps are needed to reproduce this?

.

Additional Information:

No response