fix: sse search/replace processing

This commit is contained in:
Carl-Robert Linnupuu 2025-06-04 17:41:53 +01:00
parent c7b9f2902d
commit 252006db4c
3 changed files with 5 additions and 29 deletions

View file

@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Invalid line separators exception on Windows
## [3.4.0-233] - 2025-06-02
### Added

View file

@ -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
@ -82,11 +81,4 @@ class DiffEditorManager(
ScrollType.CENTER
)
}
private fun ensureDocumentWritable(project: Project, document: Document) {
if (!document.isWritable) {
DiffUtil.makeWritable(project, document)
document.setReadOnly(false)
}
}
}

View file

@ -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,25 +210,7 @@ class SseMessageParser : MessageParser {
)
)
parserState = ParserState.InReplace(state.header, state.searchContent, newReplace)
val nlIdx = buffer.indexOf(NEWLINE)
if (nlIdx < 0) return false
val line = buffer.substring(0, nlIdx)
if (line.trim().startsWith(REPLACE_MARKER)) {
consumeFromBuffer(nlIdx + 1)
segments.add(
SearchReplace(
state.searchContent,
newReplace,
state.header.language,
state.header.filePath
)
)
return true
}
false
true
}
}
}