Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 68299b6

Browse files
committed
fix: enforce mandatory :start_line: in apply_diff tool
- Make :start_line: mandatory in the regex pattern (was optional) - Add :start_line: presence tracking in validateMarkerSequencing - Add early validation in ApplyDiffTool before calling applyDiff - Add sayAndCreateMissingStartLineError helper method on Task - Update error messages to reflect :start_line: requirement - Update all existing tests to include :start_line: directive - Add new test for rejecting diffs without :start_line: Closes #12199
1 parent ad25634 commit 68299b6

5 files changed

Lines changed: 186 additions & 22 deletions

File tree

src/core/diff/strategies/__tests__/multi-search-replace-trailing-newline.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ describe("MultiSearchReplaceDiffStrategy - trailing newline preservation", () =>
1616
}
1717
}`
1818
const diffContent = `<<<<<<< SEARCH
19+
:start_line:1
20+
-------
1921
1 | class Example {
2022
2 | constructor() {
2123
3 | this.value = 0;
@@ -43,6 +45,8 @@ class Example {
4345
it("should handle Windows line endings with trailing newlines and line numbers", async () => {
4446
const originalContent = "function test() {\r\n return true;\r\n}\r\n"
4547
const diffContent = `<<<<<<< SEARCH
48+
:start_line:1
49+
-------
4650
1 | function test() {
4751
2 | return true;
4852
3 | }
@@ -69,6 +73,8 @@ function two() {
6973
return 2;
7074
}`
7175
const diffContent = `<<<<<<< SEARCH
76+
:start_line:1
77+
-------
7278
1 | function one() {
7379
2 | return 1;
7480
3 | }
@@ -79,6 +85,8 @@ function one() {
7985
>>>>>>> REPLACE
8086
8187
<<<<<<< SEARCH
88+
:start_line:5
89+
-------
8290
5 | function two() {
8391
6 | return 2;
8492
7 | }
@@ -109,6 +117,8 @@ function two() {
109117
+ CollectionUtils.size(personIdentityInfoList));`
110118

111119
const diffContent = `<<<<<<< SEARCH
120+
:start_line:1
121+
-------
112122
1476 | List<ContactInfoItemResp> addressInfoList = new ArrayList<>(CollectionUtils.size(repairInfoList) > 10 ? 10
113123
1477 | : CollectionUtils.size(repairInfoList) + CollectionUtils.size(homeAddressInfoList)
114124
1478 | + CollectionUtils.size(idNoAddressInfoList) + CollectionUtils.size(workAddressInfoList)
@@ -143,6 +153,8 @@ function two() {
143153
it("should correctly strip line numbers even when last line has no trailing newline", async () => {
144154
const originalContent = "line 1\nline 2\nline 3" // No trailing newline
145155
const diffContent = `<<<<<<< SEARCH
156+
:start_line:1
157+
-------
146158
1 | line 1
147159
2 | line 2
148160
3 | line 3

0 commit comments

Comments
 (0)