void () { initText("a<caret>bc"); runWriteCommand(() -> { DocumentEx document = (DocumentEx)getEditor().getDocument(); DocumentUtil.executeInBulk(document, ()-> { document.insertString(0, "\n "); // we're changing number of visual lines, and invalidating text layout for caret line }); }); checkResultByText("\n a<caret>bc"); }