diff --git a/src/main/kotlin/ee/carlrobert/codegpt/util/EditorDiffUtil.kt b/src/main/kotlin/ee/carlrobert/codegpt/util/EditorDiffUtil.kt index f8e6fd04..18e1a03f 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/util/EditorDiffUtil.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/util/EditorDiffUtil.kt @@ -27,23 +27,14 @@ object EditorDiffUtil { val mainEditor = project.service().selectedTextEditor ?: return val mainEditorFile = service().getFile(mainEditor.document) ?: return - val tempFile = createTempDiffFile(mainEditor, toolwindowEditor, highlightedText) + val tempFile = LightVirtualFile( + mainEditorFile.name, + createTempDiffContent(mainEditor, toolwindowEditor, highlightedText) + ) DiffManager.getInstance() .showDiff(project, createDiffRequest(project, tempFile, mainEditor, mainEditorFile)) } - private fun createTempDiffFile( - mainEditor: Editor, - toolwindowEditor: Editor, - highlightedText: String - ): VirtualFile { - val diffContent = createTempDiffContent(mainEditor, toolwindowEditor, highlightedText) - val toolwindowEditorFile = - service().getFile(toolwindowEditor.document) - ?: throw IllegalStateException("Toolwindow editor file not found") - return LightVirtualFile("content_diff_${toolwindowEditorFile.name}", diffContent) - } - private fun createTempDiffContent( mainEditor: Editor, toolwindowEditor: Editor,