Commit e3e5e53
authored
fix (q chat): ensure generated files end with newline character, and no trailing whitespaces (#769)
* feat(fs_write): ensure files end with newline character
Fixes #768
This commit adds functionality to ensure all files created or modified by
the fs_write tool end with a newline character, following Unix text file
conventions. The change:
- Adds newline handling to create, str_replace, and insert operations
- Updates test cases to verify the new behavior
- Maintains backward compatibility with existing functionality
This improves compatibility with other tools and follows standard text
file best practices.
* fix: remove trailing whitespace in generated code
This commit adds a helper function to clean file content by:
1. Removing trailing whitespace from each line
2. Ensuring files end with a newline
The implementation refactors duplicate code across Create, StrReplace, and Insert
operations into a single clean_file_content helper function. This ensures consistent
handling of whitespace across all file operations.
Added unit tests to verify the helper function works correctly with various inputs.
Fixes issue with trailing whitespace in code generation.1 parent d219c0c commit e3e5e53
2 files changed
+59
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1146 | 1146 | | |
1147 | 1147 | | |
1148 | 1148 | | |
1149 | | - | |
| 1149 | + | |
1150 | 1150 | | |
1151 | 1151 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
53 | 66 | | |
54 | 67 | | |
55 | 68 | | |
| |||
70 | 83 | | |
71 | 84 | | |
72 | 85 | | |
73 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
74 | 89 | | |
75 | 90 | | |
76 | 91 | | |
| |||
89 | 104 | | |
90 | 105 | | |
91 | 106 | | |
92 | | - | |
| 107 | + | |
| 108 | + | |
93 | 109 | | |
94 | 110 | | |
95 | 111 | | |
| |||
120 | 136 | | |
121 | 137 | | |
122 | 138 | | |
123 | | - | |
| 139 | + | |
| 140 | + | |
124 | 141 | | |
125 | 142 | | |
126 | 143 | | |
| |||
435 | 452 | | |
436 | 453 | | |
437 | 454 | | |
438 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
439 | 459 | | |
440 | 460 | | |
441 | 461 | | |
| |||
449 | 469 | | |
450 | 470 | | |
451 | 471 | | |
452 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
453 | 477 | | |
454 | 478 | | |
455 | 479 | | |
| |||
463 | 487 | | |
464 | 488 | | |
465 | 489 | | |
466 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
467 | 494 | | |
468 | 495 | | |
469 | 496 | | |
| |||
613 | 640 | | |
614 | 641 | | |
615 | 642 | | |
616 | | - | |
| 643 | + | |
617 | 644 | | |
618 | 645 | | |
619 | 646 | | |
| |||
628 | 655 | | |
629 | 656 | | |
630 | 657 | | |
631 | | - | |
| 658 | + | |
632 | 659 | | |
633 | 660 | | |
634 | 661 | | |
| |||
683 | 710 | | |
684 | 711 | | |
685 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
686 | 736 | | |
0 commit comments