Skip to content

Commit 0ba9fd7

Browse files
committed
fix(issue-457-edit-unsuccessfull): Correct the documented default for diffFuzzyThreshold and fix failure-diagnostics assertions unconditional
1 parent e79c5e3 commit 0ba9fd7

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

packages/types/src/global-settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const globalSettingsSchema = z.object({
114114
/**
115115
* Fuzzy matching threshold for the multi-search-replace diff strategy.
116116
* Range: 0.5 (50% minimum similarity) to 1.0 (exact match only).
117-
* `@default` 0.9
117+
* `@default` 1.0
118118
*/
119119
diffFuzzyThreshold: z.number().min(0.5).max(1).optional(),
120120
requestDelaySeconds: z.number().optional(),

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,13 +1419,12 @@ function sum(a, b) {
14191419

14201420
const result = await strategy.applyDiff(originalContent, diff)
14211421
expect(result.success).toBe(false)
1422-
if (!result.success && result.failParts) {
1423-
const failedPart = result.failParts[0]
1424-
if (failedPart && "error" in failedPart && failedPart.error) {
1425-
expect(failedPart.error).toContain("No sufficiently similar match found")
1426-
} else {
1427-
throw new Error("Expected failedPart to have an error property")
1428-
}
1422+
if (!result.success) {
1423+
expect(result.failParts).toBeDefined()
1424+
expect(result.failParts!.length).toBeGreaterThan(0)
1425+
const failedPart = result.failParts![0]
1426+
expect(failedPart).toHaveProperty("error")
1427+
expect((failedPart as { error: string }).error).toContain("No sufficiently similar match found")
14291428
}
14301429
})
14311430

@@ -1446,19 +1445,18 @@ function sum(a, b) {
14461445

14471446
const result = await strategy.applyDiff(originalContent, diff)
14481447
expect(result.success).toBe(false)
1449-
if (!result.success && result.failParts) {
1450-
const failedPart = result.failParts[0]
1451-
if (failedPart && "error" in failedPart && failedPart.error) {
1452-
const errorMsg = failedPart.error
1453-
expect(errorMsg).toContain("Debug Info:")
1454-
expect(errorMsg).toContain("Similarity Score:")
1455-
expect(errorMsg).toContain("Required Threshold: 95%")
1456-
expect(errorMsg).toContain("Levenshtein Distance:")
1457-
expect(errorMsg).toContain("Search Length:")
1458-
expect(errorMsg).toContain("Best Match Length:")
1459-
} else {
1460-
throw new Error("Expected failedPart to have an error property")
1461-
}
1448+
if (!result.success) {
1449+
expect(result.failParts).toBeDefined()
1450+
expect(result.failParts!.length).toBeGreaterThan(0)
1451+
const failedPart = result.failParts![0]
1452+
expect(failedPart).toHaveProperty("error")
1453+
const errorMsg = (failedPart as { error: string }).error
1454+
expect(errorMsg).toContain("Debug Info:")
1455+
expect(errorMsg).toContain("Similarity Score:")
1456+
expect(errorMsg).toContain("Required Threshold: 95%")
1457+
expect(errorMsg).toContain("Levenshtein Distance:")
1458+
expect(errorMsg).toContain("Search Length:")
1459+
expect(errorMsg).toContain("Best Match Length:")
14621460
}
14631461
})
14641462
})

0 commit comments

Comments
 (0)