void () { if (getEditor() != null) { Editor hostEditor = getEditor() instanceof EditorWindow ? ((EditorWindow)getEditor()).getDelegate() : getEditor(); PsiFile hostFile = myFile == null ? null : InjectedLanguageManager.getInstance(getProject()).getTopLevelFile(myFile); Ref<EditorWindow> editorWindowRef = new Ref<>(); hostEditor.getCaretModel().runForEachCaret(caret -> { Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(hostEditor, hostFile); if (caret == hostEditor.getCaretModel().getPrimaryCaret() && editor instanceof EditorWindow) { editorWindowRef.set((EditorWindow)editor); } }); if (!editorWindowRef.isNull()) { myEditor = editorWindowRef.get(); myFile = editorWindowRef.get().getInjectedFile(); myVFile = myFile.getVirtualFile(); } } }