Repository navigation
Commit 7aa29c6
Python: Strip the whole line terminator before matching in file_access_grep
Ports the fix for the same defect found by review on the .NET side (microsoft#7671).
_search_file_content removed only the trailing "\n" before matching, so on a CRLF
file the pattern was applied to text such as "beta match\r" and an end-anchored
pattern like "match$" failed even though the line's text is exactly "beta match".
The terminator is not part of the line's text, so it is stripped in full now.
The per-line offset had to move with it: it advanced by len(scanned) + 1, which
was only correct while scanned still carried the "\r". It now advances by
len(line), whose terminator is already included, keeping the snippet anchored at
the match.
Also drops a stale claim in _split_lines_keepends' docstring, which still said it
reproduced _search_file_content's content.split("\n") — that dependency now runs
the other way round.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent d97afaa commit 7aa29c6
2 files changed
Lines changed: 45 additions & 8 deletions
File tree
- python/packages/core
- agent_framework/_harness
- tests/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
| |||
520 | 521 | | |
521 | 522 | | |
522 | 523 | | |
523 | | - | |
| 524 | + | |
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
| |||
529 | 530 | | |
530 | 531 | | |
531 | 532 | | |
532 | | - | |
533 | | - | |
| 533 | + | |
| 534 | + | |
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
1325 | 1326 | | |
1326 | 1327 | | |
1327 | 1328 | | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
1328 | 1364 | | |
1329 | 1365 | | |
1330 | 1366 | | |
| |||
0 commit comments