michael / svedit

https://svedit.vercel.app
MIT License
96 stars 3 forks source link

Implement word deletion #14

Open buhodev opened 1 week ago

buhodev commented 1 week ago

Allow to delete complete words by pressing ctrl + backspace or ctrl + delete.

Repro

Expected behavior

michael commented 1 week ago

Right, that's not yet implemented. Just to be sure, the expectation is that the text at the current line is deleted right?

There's just a challenge here in the case of Svedit, as our internal model does not know about lines (and where lines break), so if you typed a paragraph and hit ctrl+backspace, it would be easy to remove the whole text until you find a newline character for instance. But it would be hard to delete the text of the current line (as it is rendered).

Do you think it would it be an acceptable compromise to delete the current word (instead of the current line) on ctrl+backspace?

johannesmutter commented 6 days ago

Ctrl + Backspace is more common for deleting the previous word.

Whereas Cmd + Backspace is more commonly used to delete up to the beginning of the current line. Which actually feels a bit weird in "prose". It makes sense when there's a closed "unit of meaning" per line (e.g. in a code editor), but when a paragraph is broken over several lines (and the container adjusts responsively its width), it doesn't feel right.

I would then rather expect to delete until the next sentence fragment (separated by e.g. ;,.: \n)

These are the common shortcuts in Word/ iA Writer/ Pages / VS Code/ etc.

Action Mac Windows
Delete previous word Option + Backspace OR: Ctrl + Backspace Ctrl + Backspace
Delete to start of line Cmd + Backspace Home, then Shift + Home, then Backspace (???)
Delete next word Option + Delete OR: Fn + Option + Backspace Ctrl + Delete
Delete to end of Block Ctrl + K Shift + End, then Delete