mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-19 07:54:46 +00:00
fix: sse search/replace processing
This commit is contained in:
parent
d8d03a5b2d
commit
c5bef675d5
2 changed files with 4 additions and 17 deletions
|
|
@ -6,7 +6,6 @@ import com.intellij.diff.util.DiffUtil
|
|||
import com.intellij.diff.util.Side
|
||||
import com.intellij.openapi.application.runInEdt
|
||||
import com.intellij.openapi.diff.DiffBundle
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.openapi.editor.ScrollType
|
||||
import com.intellij.openapi.project.Project
|
||||
|
|
@ -27,13 +26,14 @@ class DiffEditorManager(
|
|||
|
||||
application.executeOnPooledThread {
|
||||
runInEdt {
|
||||
ensureDocumentWritable(project, document)
|
||||
if (DiffUtil.executeWriteCommand(document, project, "Updating document") {
|
||||
document.setText(
|
||||
StringUtil.convertLineSeparators(
|
||||
currentText.replaceLast(searchContent.trim(), replaceContent.trim())
|
||||
)
|
||||
)
|
||||
|
||||
diffViewer.scheduleRediff()
|
||||
}) {
|
||||
diffViewer.rediff()
|
||||
scrollToLastChange(diffViewer)
|
||||
|
|
@ -50,8 +50,6 @@ class DiffEditorManager(
|
|||
|
||||
fun applyAllChanges(): List<UnifiedDiffChange> {
|
||||
val document = diffViewer.getDocument(Side.LEFT)
|
||||
ensureDocumentWritable(project, document)
|
||||
|
||||
val allChanges = mutableListOf<UnifiedDiffChange>()
|
||||
|
||||
while (true) {
|
||||
|
|
@ -66,9 +64,7 @@ class DiffEditorManager(
|
|||
DiffBundle.message("message.replace.change.command")
|
||||
) {
|
||||
diffViewer.replaceChange(change, Side.RIGHT)
|
||||
runInEdt {
|
||||
diffViewer.scheduleRediff()
|
||||
}
|
||||
diffViewer.scheduleRediff()
|
||||
}
|
||||
diffViewer.rediff(true)
|
||||
|
||||
|
|
@ -85,11 +81,4 @@ class DiffEditorManager(
|
|||
ScrollType.CENTER
|
||||
)
|
||||
}
|
||||
|
||||
private fun ensureDocumentWritable(project: Project, document: Document) {
|
||||
if (!document.isWritable) {
|
||||
DiffUtil.makeWritable(project, document)
|
||||
document.setReadOnly(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -193,8 +193,6 @@ class SseMessageParser : MessageParser {
|
|||
}
|
||||
|
||||
line.trim() == CODE_FENCE -> {
|
||||
// Invalid search/replace block - missing REPLACE marker
|
||||
// Mark done
|
||||
segments.add(CodeEnd(""))
|
||||
parserState = ParserState.Outside
|
||||
true
|
||||
|
|
@ -212,7 +210,7 @@ class SseMessageParser : MessageParser {
|
|||
)
|
||||
)
|
||||
parserState = ParserState.InReplace(state.header, state.searchContent, newReplace)
|
||||
false
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue