Skip to content

Commit 2f6da5d

Browse files
committed
fix: remove omission detection logic to fix false positives
Removes the detectCodeOmission function and all its usages as per discussion in issue #9785. The omission detection was causing false positives with legitimate documentation comments in markdown files and other file types. With modern models having larger context windows and max output tokens, this validation is no longer necessary. Fixes #9785
1 parent 23605be commit 2f6da5d

File tree

4 files changed

+0
-195
lines changed

4 files changed

+0
-195
lines changed

src/core/tools/WriteToFileTool.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { fileExistsAtPath, createDirectoriesForFile } from "../../utils/fs"
1111
import { stripLineNumbers, everyLineHasLineNumbers } from "../../integrations/misc/extract-text"
1212
import { getReadablePath } from "../../utils/path"
1313
import { isPathOutsideWorkspace } from "../../utils/pathUtils"
14-
import { detectCodeOmission } from "../../integrations/editor/detect-omission"
1514
import { unescapeHtmlEntities } from "../../utils/text-normalization"
1615
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
1716
import { EXPERIMENT_IDS, experiments } from "../../shared/experiments"
@@ -125,32 +124,6 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
125124
task.diffViewProvider.originalContent = ""
126125
}
127126

128-
if (detectCodeOmission(task.diffViewProvider.originalContent || "", newContent)) {
129-
if (task.diffStrategy) {
130-
pushToolResult(
131-
formatResponse.toolError(
132-
`Content appears to contain comments indicating omitted code (e.g., '// rest of code unchanged', '/* previous code */'). Please provide the complete file content without any omissions if possible, or otherwise use the 'apply_diff' tool to apply the diff to the original file.`,
133-
),
134-
)
135-
return
136-
} else {
137-
vscode.window
138-
.showWarningMessage(
139-
"Potential code truncation detected. This happens when the AI reaches its max output limit.",
140-
"Follow guide to fix the issue",
141-
)
142-
.then((selection) => {
143-
if (selection === "Follow guide to fix the issue") {
144-
vscode.env.openExternal(
145-
vscode.Uri.parse(
146-
"https://github.com/cline/cline/wiki/Troubleshooting-%E2%80%90-Cline-Deleting-Code-with-%22Rest-of-Code-Here%22-Comments",
147-
),
148-
)
149-
}
150-
})
151-
}
152-
}
153-
154127
let unified = fileExists
155128
? formatResponse.createPrettyPatch(relPath, task.diffViewProvider.originalContent, newContent)
156129
: convertNewFileToUnifiedDiff(newContent, relPath)
@@ -183,34 +156,6 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
183156
await delay(300)
184157
task.diffViewProvider.scrollToFirstDiff()
185158

186-
if (detectCodeOmission(task.diffViewProvider.originalContent || "", newContent)) {
187-
if (task.diffStrategy) {
188-
await task.diffViewProvider.revertChanges()
189-
190-
pushToolResult(
191-
formatResponse.toolError(
192-
`Content appears to contain comments indicating omitted code (e.g., '// rest of code unchanged', '/* previous code */'). Please provide the complete file content without any omissions if possible, or otherwise use the 'apply_diff' tool to apply the diff to the original file.`,
193-
),
194-
)
195-
return
196-
} else {
197-
vscode.window
198-
.showWarningMessage(
199-
"Potential code truncation detected. This happens when the AI reaches its max output limit.",
200-
"Follow guide to fix the issue",
201-
)
202-
.then((selection) => {
203-
if (selection === "Follow guide to fix the issue") {
204-
vscode.env.openExternal(
205-
vscode.Uri.parse(
206-
"https://github.com/cline/cline/wiki/Troubleshooting-%E2%80%90-Cline-Deleting-Code-with-%22Rest-of-Code-Here%22-Comments",
207-
),
208-
)
209-
}
210-
})
211-
}
212-
}
213-
214159
let unified = fileExists
215160
? formatResponse.createPrettyPatch(relPath, task.diffViewProvider.originalContent, newContent)
216161
: convertNewFileToUnifiedDiff(newContent, relPath)

src/core/tools/__tests__/writeToFileTool.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as path from "path"
33
import type { MockedFunction } from "vitest"
44

55
import { fileExistsAtPath, createDirectoriesForFile } from "../../../utils/fs"
6-
import { detectCodeOmission } from "../../../integrations/editor/detect-omission"
76
import { isPathOutsideWorkspace } from "../../../utils/pathUtils"
87
import { getReadablePath } from "../../../utils/path"
98
import { unescapeHtmlEntities } from "../../../utils/text-normalization"
@@ -40,10 +39,6 @@ vi.mock("../../prompts/responses", () => ({
4039
},
4140
}))
4241

43-
vi.mock("../../../integrations/editor/detect-omission", () => ({
44-
detectCodeOmission: vi.fn().mockReturnValue(false),
45-
}))
46-
4742
vi.mock("../../../utils/pathUtils", () => ({
4843
isPathOutsideWorkspace: vi.fn().mockReturnValue(false),
4944
}))
@@ -100,7 +95,6 @@ describe("writeToFileTool", () => {
10095
// Mocked functions with correct types
10196
const mockedFileExistsAtPath = fileExistsAtPath as MockedFunction<typeof fileExistsAtPath>
10297
const mockedCreateDirectoriesForFile = createDirectoriesForFile as MockedFunction<typeof createDirectoriesForFile>
103-
const mockedDetectCodeOmission = detectCodeOmission as MockedFunction<typeof detectCodeOmission>
10498
const mockedIsPathOutsideWorkspace = isPathOutsideWorkspace as MockedFunction<typeof isPathOutsideWorkspace>
10599
const mockedGetReadablePath = getReadablePath as MockedFunction<typeof getReadablePath>
106100
const mockedUnescapeHtmlEntities = unescapeHtmlEntities as MockedFunction<typeof unescapeHtmlEntities>
@@ -120,7 +114,6 @@ describe("writeToFileTool", () => {
120114

121115
mockedPathResolve.mockReturnValue(absoluteFilePath)
122116
mockedFileExistsAtPath.mockResolvedValue(false)
123-
mockedDetectCodeOmission.mockReturnValue(false)
124117
mockedIsPathOutsideWorkspace.mockReturnValue(false)
125118
mockedGetReadablePath.mockReturnValue("test/path.txt")
126119
mockedUnescapeHtmlEntities.mockImplementation((content) => content)

src/integrations/editor/__tests__/detect-omission.spec.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/integrations/editor/detect-omission.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)