TemplateStateBase (@NotNull Editor editor) { TemplateStateBase prevState = getTemplateState(editor); if (prevState != null) { Editor stateEditor = prevState.getEditor(); if (stateEditor != null) { setTemplateState(stateEditor, null); } } return prevState; }