Block Closing in EnterHandlerDelegate
Hello. I am wondering how I would go about implementing an auto block-closing feature, similar to when you press enter after opening a curly brace, but with keywords instead.
If I start a line with function hello() and then press enter, I would like the resulting code to be:
function hello()
// Caret indented
endfunction
The main questions are:
- How can I get the text / PsiElement of the current line in my EnterHandlerDelegate so I can check how it should be closed?
- How can I force an indent when I press enter?
- How can I add text after the newline? I have found file.add(psiElement), but I'm not sure how to create the element.
Thanks
Please sign in to leave a comment.
Sorry this got lost. See com.intellij.codeInsight.editorActions.enter.EnterAfterUnmatchedBraceHandler as reference implementation.