@Override
      public void editorReleased(@NotNull EditorFactoryEvent event) {
        Editor editor = event.getEditor();
        if (editor.getProject() != null && editor.getProject() != myProject) return;
        if (myProject.isDisposed() || !myProject.isOpen()) return;
        TemplateState state = getTemplateState(editor);
        if (state != null) {
          state.gotoEnd();
        }
        TemplateState prevState = clearTemplateState(editor);
        if (prevState != null) {
          Disposer.dispose(prevState);
        }
      }
@Override
      public void editorReleased(@NotNull EditorFactoryEvent event)