override fun getDiffRequestChain()

in idea-plugin/src/main/java/org/jetbrains/bunches/idea/actions/BunchCompareFilesAction.kt [33:59]


    override fun getDiffRequestChain(e: AnActionEvent): DiffRequestChain? {
        val project = e.project ?: return null
        val bunchFile = getFile(e) ?: return null
        val baseFile = getMainFile(bunchFile, project)

        if (baseFile == null) {
            Notification(
                "Bunch tool",
                "Bunch tool error",
                "Base file was not found",
                NotificationType.ERROR
            ).notify(project)
            return null
        }

        val chain = BaseShowDiffAction.createMutableChainFromFiles(project, baseFile, bunchFile)

        val editorContent = chain.content2
        if (editorContent is DocumentContent) {
            val editors = EditorFactory.getInstance().getEditors(editorContent.document)
            if (editors.isNotEmpty()) {
                val currentLine = editors.first().caretModel.logicalPosition.line
                chain.putRequestUserData(DiffUserDataKeys.SCROLL_TO_LINE, Pair.create(Side.RIGHT, currentLine))
            }
        }
        return chain
    }