Repository navigation
Commit d95dd2f
fix(filesystem): keep line endings and indentation in edit_file
edit_file read the file with its CRLF line endings normalized to LF and
wrote it back that way, so any edit to a CRLF file silently rewrote every
line ending. It now detects the file's predominant line ending and writes
the edited file back with it (modelcontextprotocol#4991).
When there is no exact match, the whitespace-tolerant matcher reindented
only the first replacement line from the file; later lines whose oldText
line or own line had no indentation were inserted as given, and indented
ones were anchored at the first line. Each replacement line now takes the
indentation of the file line it replaces, shifted by its indentation
relative to the matching oldText line (clamped at none); lines beyond
oldText's length are placed relative to its last line, and blank lines are
kept as given (modelcontextprotocol#4990).
The pinning tests now assert the correct behavior and lose their KNOWN BUG
markers; the matcher's other reindentation pins are updated to the new rule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>1 parent 571e2b3 commit d95dd2f
3 files changed
Lines changed: 139 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
164 | 185 | | |
165 | 186 | | |
166 | 187 | | |
| |||
804 | 825 | | |
805 | 826 | | |
806 | 827 | | |
807 | | - | |
| 828 | + | |
808 | 829 | | |
809 | 830 | | |
810 | 831 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
695 | | - | |
696 | | - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
701 | 713 | | |
702 | | - | |
| 714 | + | |
703 | 715 | | |
704 | 716 | | |
705 | 717 | | |
706 | 718 | | |
707 | | - | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
708 | 722 | | |
709 | | - | |
710 | 723 | | |
711 | 724 | | |
712 | 725 | | |
| |||
717 | 730 | | |
718 | 731 | | |
719 | 732 | | |
720 | | - | |
721 | | - | |
| 733 | + | |
722 | 734 | | |
723 | | - | |
| 735 | + | |
724 | 736 | | |
725 | 737 | | |
726 | 738 | | |
727 | | - | |
728 | 739 | | |
729 | 740 | | |
730 | 741 | | |
| |||
736 | 747 | | |
737 | 748 | | |
738 | 749 | | |
739 | | - | |
740 | | - | |
741 | | - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
742 | 768 | | |
743 | | - | |
| 769 | + | |
744 | 770 | | |
745 | 771 | | |
746 | 772 | | |
747 | | - | |
| 773 | + | |
748 | 774 | | |
749 | 775 | | |
750 | 776 | | |
751 | 777 | | |
752 | 778 | | |
753 | | - | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
754 | 799 | | |
755 | 800 | | |
756 | | - | |
757 | | - | |
| 801 | + | |
| 802 | + | |
758 | 803 | | |
759 | 804 | | |
760 | | - | |
| 805 | + | |
761 | 806 | | |
762 | | - | |
| 807 | + | |
763 | 808 | | |
764 | 809 | | |
765 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
314 | 349 | | |
315 | 350 | | |
316 | 351 | | |
317 | 352 | | |
318 | 353 | | |
319 | | - | |
320 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
321 | 359 | | |
322 | 360 | | |
323 | 361 | | |
| |||
349 | 387 | | |
350 | 388 | | |
351 | 389 | | |
352 | | - | |
353 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
354 | 394 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 395 | + | |
| 396 | + | |
368 | 397 | | |
369 | 398 | | |
370 | 399 | | |
| |||
382 | 411 | | |
383 | 412 | | |
384 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
385 | 419 | | |
386 | 420 | | |
387 | 421 | | |
| |||
0 commit comments