Hi. There are quite a few actions for the different delete actions (EditorBackSpace, EditorDelete, EditorDeleteToWordStart, EditorDeleteToWordEnd) but none of these seem to apply for when the user deletes text that is selected. Am I missing something or does a separate action for this really not exist? If so, is there a workaround I could use?
Hi,
Please describe your use case. What are you trying to achieve and why do you need the deletion action?
We have an autoformatting functionality in our plugin that formats a small part of the file the user is typing in whenever its content changes (I know this isn’t usually recommended, but we’re paying attention to performance and it’s only a small part of the file). We are currently using all actions that I listed as well as a TypedHandler to react to any changes in our files, however there doesn’t seem to be a way for us to react when a user deletes text that they selected, resulting in an unformatted file which could be confusing and annoying to our users.
EditorDelete
implemented with com.intellij.openapi.editor.actions.DeleteAction
is the one that is triggered when deleting text in the editor.
That is correct, and it works when no text is selected in the editor and I press delete. If text is selected however (ie. highlighted like the word “profiles” on the attached screenshot), the event does not seem to be triggered. Is that unintended behavior?
It works for me in both cases. Depending on the key I press, it invokes DeleteAction
or BackspaceAction
.
This is where I added a breakpoint: