Editor (@NotNull VirtualFile file, @NotNull DataContext dataContext) { Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (editor != null && file.equals(editor.getVirtualFile())) { return editor; } return JBIterable.of( dataContext.getData(PlatformCoreDataKeys.FILE_EDITOR), dataContext.getData(PlatformDataKeys.LAST_ACTIVE_FILE_EDITOR) ) .filterNotNull() .filter(it -> file.equals(it.getFile())) .filter(TextEditor.class) .map(it -> it.getEditor()) .first(); }