MPS-extensions icon indicating copy to clipboard operation
MPS-extensions copied to clipboard

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

Open digital-ember opened this issue 9 months ago • 4 comments

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 avatar May 10 '24 13:05 digital-ember

Keymaps also seem to be ignored ....

digital-ember avatar May 10 '24 13:05 digital-ember

In your mentioned case:

  • BACKSPACE = delete character to the left of cursor -> there is no text, so jump to cell to the left and re-execute action
  • DELETE = delete character to the right of cursor -> there is no text, jump to cell to the right and re-execute action

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.

alexanderpann avatar May 13 '24 14:05 alexanderpann

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?

digital-ember avatar May 13 '24 14:05 digital-ember

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.

alexanderpann avatar May 13 '24 14:05 alexanderpann