JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
80 stars 47 forks source link

BACKSPACE and DELETE in multiline text does not behave as expected if text is empty #839

Open digital-ember opened 1 month ago

digital-ember commented 1 month ago

I don't quite understand the implementation for DELETE and BACKSPACE in the multiline runtime EditorCell_Word.executeTextAction() . If the caret is at the beginning (BACKSPACE) or at the end (DELETE), the action is "transfered" to the next label cell, if one exists. I guess it makes sense for the cases where the text itself is not empty AND the next cell it trasnfers to is editable.

However, I have a case where a multiline text cell is surrounded by read-only constant cells and if the text is empty, both BACKSPACE and DELETE should allow the user to delete the containing node, or at least allow me as the language author to define what should happen.

Unfortunately, adding a action map to the multiline cell is ignored by the multiline runtime :(

digital-ember commented 1 month ago

Keymaps also seem to be ignored ....

alexanderpann commented 1 month ago

In your mentioned case:

We would need to see some other use cases if deleting the node always makes sense if the text is empty. Otherwise, we could add a style item that can influence the behavior.

digital-ember commented 1 month ago

Thanks, I understand why it behaves like it does, but I wonder how one is supposed to delete a multiline text field with the keyboard? Notice that the surrounding cells in my case are read-only, so the behavior of navigating there does not make sense in my opinion. If there is another editable cell, like a property or reference, maybe, but even then I would argue that it would be closer to how a regular text editor behaves if in the a case of a "empty paragraph", pressing backspace / delete does not just set the cursor to the next or previous paragraph, but also removes the current one, wouldn't you agree?

alexanderpann commented 1 month ago

Yes, I agree. As far as I can tell, this behavior was implemented for the richtext language in TextCellModifier#modifyIWordCell. The feature you want, sounds like the auto-deletable style item which we could support.