void () { typeInText("abc\n\n\n\n\n\n\n"); executeEditorAction(getFirstEditor(), IdeActions.ACTION_EDITOR_TEXT_START); typeInText(" "); executeEditorAction(getFirstEditor(), IdeActions.ACTION_EDITOR_TEXT_END); // recreate editor Document document = getFirstEditor().getDocument(); EditorFactory.getInstance().releaseEditor(getFirstEditor()); myEditors[0] = EditorFactory.getInstance().createEditor(document, myProject); UIUtil.dispatchAllInvocationEvents(); // remove references to original editor from event queue System.gc(); // make sure weak references to original editor are cleared undoFirstEditor(); checkEditorText(" abc\n\n\n\n\n\n\n"); undoFirstEditor(); checkEditorText("abc\n\n\n\n\n\n\n"); }