fix: toolwindow response editor diff action

This commit is contained in:
Carl-Robert Linnupuu 2024-10-14 23:54:48 +03:00
parent 516183ee3f
commit 2c68d2e1be

View file

@ -27,23 +27,14 @@ object EditorDiffUtil {
val mainEditor = project.service<FileEditorManager>().selectedTextEditor ?: return
val mainEditorFile =
service<FileDocumentManager>().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<FileDocumentManager>().getFile(toolwindowEditor.document)
?: throw IllegalStateException("Toolwindow editor file not found")
return LightVirtualFile("content_diff_${toolwindowEditorFile.name}", diffContent)
}
private fun createTempDiffContent(
mainEditor: Editor,
toolwindowEditor: Editor,