mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Fix bad matching bug with empty lines
This commit is contained in:
@@ -1054,6 +1054,23 @@ function sum(a, b) {
|
|||||||
expect(result.content).toBe('function sum(a, b) {\n return a + b + 1;\n}')
|
expect(result.content).toBe('function sum(a, b) {\n return a + b + 1;\n}')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not exact match empty lines', () => {
|
||||||
|
const originalContent = 'function sum(a, b) {\n\n return a + b;\n}'
|
||||||
|
const diffContent = `test.ts
|
||||||
|
<<<<<<< SEARCH
|
||||||
|
function sum(a, b) {
|
||||||
|
=======
|
||||||
|
import { a } from "a";
|
||||||
|
function sum(a, b) {
|
||||||
|
>>>>>>> REPLACE`
|
||||||
|
|
||||||
|
const result = strategy.applyDiff(originalContent, diffContent)
|
||||||
|
expect(result.success).toBe(true)
|
||||||
|
if (result.success) {
|
||||||
|
expect(result.content).toBe('import { a } from "a";\nfunction sum(a, b) {\n\n return a + b;\n}')
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('line-constrained search', () => {
|
describe('line-constrained search', () => {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function levenshteinDistance(a: string, b: string): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSimilarity(original: string, search: string): number {
|
function getSimilarity(original: string, search: string): number {
|
||||||
if (original === '' || search === '') {
|
if (search === '') {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user