Skip to content

The agent that grows with you

docs(fuzzy_match): keep the comment next to the line it explains

kshitijk4poor7907762c8789
diff --git a/tools/fuzzy_match.py b/tools/fuzzy_match.py
index ae85a05cf98..c60d098405b 100644
--- a/tools/fuzzy_match.py
+++ b/tools/fuzzy_match.py
@@ -509,13 +509,12 @@ def _preserve_unicode_in_replacement(content: str, matches: list[Span],
if norm_old != _unicode_normalize(file_region):
return new_string # strategy shouldn't have fired; fall back
- # Strictly increasing (every UNICODE_MAP replacement is non-empty), so bisect finds the original
- # char owning a norm index, including one that falls inside a multi-char expansion (em-dash -> '--').
file_orig_to_norm = _build_orig_to_norm_map(file_region)
result_parts: list[str] = []
for tag, i1, i2, j1, j2 in SequenceMatcher(None, norm_old, new_string).get_opcodes():
if tag == "equal":
+ # The original char owning norm index i1, even one inside a multi-char expansion (em-dash -> '--').
orig_start = bisect.bisect_right(file_orig_to_norm, i1) - 1
orig_end = _norm_end_to_orig(file_orig_to_norm, orig_start, i2)
result_parts.append(file_region[orig_start:orig_end])