From 252006db4c454deb3bb756e4e7a449936aac8853 Mon Sep 17 00:00:00 2001 From: Carl-Robert Linnupuu Date: Wed, 4 Jun 2025 17:41:53 +0100 Subject: [PATCH] fix: sse search/replace processing --- CHANGELOG.md | 4 ++++ .../chat/editor/diff/DiffEditorManager.kt | 8 ------- .../chat/parser/SseMessageParser.kt | 22 +------------------ 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad63981f..1e67cce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/diff/DiffEditorManager.kt b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/diff/DiffEditorManager.kt index da6f2d9f..1ba5e182 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/diff/DiffEditorManager.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/editor/diff/DiffEditorManager.kt @@ -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) - } - } } \ No newline at end of file diff --git a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/parser/SseMessageParser.kt b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/parser/SseMessageParser.kt index f14d86a1..8d31433c 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/parser/SseMessageParser.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/parser/SseMessageParser.kt @@ -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 } } }