I've created a TypedHandlerDelegate, what I wanted to do was to reindent the line after a certain character was pressed at the start of a line (using CodeStyleManager.adjustLineIndent()). However I was getting errors that the text of the document didn't correspond with the PSI. I managed to fix this by committing the document beforehand - is this correct or is there a better way to do it?
Relevant code snippet:
if (shouldApplyTo(c, lineText))
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
int newPos = codeStyleManager.adjustLineIndent(file, lineStart);