Commit aecf968
committed
fix: improve diff matching by handling invisible whitespace
Before normalization:
- Only collapsed multiple whitespace characters into a single space
- Only trimmed leading/trailing whitespace
- Treated different line endings (\r\n vs \n) as different
- Treated tabs and spaces as different characters
- Zero-width spaces and other invisible characters were preserved
After normalization:
- Standardizes all line endings to \n
- Converts tabs to spaces for consistent comparison
- Still collapses multiple whitespace into single space
- Removes zero-width spaces and other invisible Unicode characters
- Still trims leading/trailing whitespace
This fix applies to both:
- Single search-replace functionality (search-replace.ts)
- Multi-block diff functionality (multi-search-replace.ts)
Users will encounter fewer "No sufficiently similar match found" errors across all diff operations when the content is semantically the same but has minor formatting differences.1 parent 70a5d2b commit aecf968
File tree
2 files changed
+14
-2
lines changed- src/core/diff/strategies
2 files changed
+14
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
0 commit comments