mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
This commit is contained in:
parent
86a03798d5
commit
6db30afc74
2 changed files with 52 additions and 0 deletions
|
|
@ -2332,6 +2332,54 @@ function two() {
|
|||
|
||||
function three() {
|
||||
return "three";
|
||||
}`)
|
||||
}
|
||||
})
|
||||
|
||||
it("should deduce start_line when include line number in search and replace content", async () => {
|
||||
const originalContent = `
|
||||
function one() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function process() {
|
||||
return "target";
|
||||
}
|
||||
|
||||
function process() {
|
||||
return "target";
|
||||
}
|
||||
|
||||
function two() {
|
||||
return 2;
|
||||
}
|
||||
`.trim()
|
||||
const diffContent = `test.ts
|
||||
<<<<<<< SEARCH
|
||||
9 | function process() {
|
||||
10 | return "target";
|
||||
=======
|
||||
9 | function process2() {
|
||||
10 | return "target222";
|
||||
>>>>>>> REPLACE`
|
||||
|
||||
const result = await strategy.applyDiff(originalContent, diffContent)
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.content).toBe(`function one() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function process() {
|
||||
return "target";
|
||||
}
|
||||
|
||||
function process2() {
|
||||
return "target222";
|
||||
}
|
||||
|
||||
function two() {
|
||||
return 2;
|
||||
}`)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -380,6 +380,10 @@ Only use a single line of '=======' between search and replacement content, beca
|
|||
(everyLineHasLineNumbers(searchContent) && everyLineHasLineNumbers(replaceContent)) ||
|
||||
(everyLineHasLineNumbers(searchContent) && replaceContent.trim() === "")
|
||||
|
||||
if (hasAllLineNumbers && startLine === 0) {
|
||||
startLine = parseInt(searchContent.split("\n")[0].split("|")[0])
|
||||
}
|
||||
|
||||
if (hasAllLineNumbers) {
|
||||
searchContent = stripLineNumbers(searchContent)
|
||||
replaceContent = stripLineNumbers(replaceContent)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue