[Feature request] Add method to restore previously removed range
aleclarson opened this issue · 3 comments
aleclarson commented
const string = new MagicString("abcd")
string.remove(0, 3)
string.toString() // => "d"
// ...later on...
string.restore(2, 3)
string.toString() // => "cd"
aleclarson commented
Why not just insert the removed range with existing methods?
Because then I wouldn't be able to insert new content into the restored range.
👉 Example: https://stackblitz.com/edit/node-1gmfpo?file=index.js (backup gist)
antfu commented
That makes sense to me. PR welcome :)