Commit b0ec9ae
committed
fix(filesystem): preserve literal $ in edit_file newText (closes #4157)
The prior code passed `normalizedNew` as String.prototype.replace's replacement
argument. JS interprets `$$`, `$&`, `$'`, `$``, and `$n` as replacement
patterns in that form, so any actual `$` characters in the user's
newText - price tags, regex backreferences in docs, shell examples -
get expanded or dropped.
The callback form (`replace(..., () => string)`) disables pattern
interpretation, so the string is written verbatim.
Two regression tests pin the callback form.
Closes #4157.1 parent b1e1eb1 commit b0ec9ae
2 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
443 | 477 | | |
444 | 478 | | |
445 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
0 commit comments