Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add method to restore previously removed range #218

Closed
aleclarson opened this issue Jul 6, 2022 · 3 comments
Closed

Comments

@aleclarson
Copy link

const string = new MagicString("abcd")

string.remove(0, 3)
string.toString() // => "d"

// ...later on...
string.restore(2, 3)
string.toString() // => "cd"
@aleclarson
Copy link
Author

aleclarson commented Jul 6, 2022

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
Copy link
Collaborator

antfu commented Jul 7, 2022

That makes sense to me. PR welcome :)

KermanX added a commit to KermanX/magic-string that referenced this issue Feb 3, 2024
@KermanX
Copy link
Contributor

KermanX commented Feb 3, 2024

I opened #271 for this feature.

The method introduced in that PR is reset, rather than restore, because of its actual behavior

antfu pushed a commit that referenced this issue Feb 5, 2024
@antfu antfu closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants