`.replace` replacing removed code
fisker opened this issue · comments
fisker Cheung commented
> new (require('magic-string'))('00').remove(0, 1).replace('0', '1').toString()
'10'
Shouldn't the result be 1
?
Anthony Fu commented
.replace
matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.
fisker Cheung commented
I'm not sure exactly how it works, I generated a new MagicString before replacing for now. prettier/prettier@77ac062
Tal500 commented
.replace
matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.
Is it problematic to get as parameter if the user wants to perform the search on the original string or not?