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

Infinite loop when removing in empty string. #280

Closed
mysteryven opened this issue Jul 28, 2024 · 1 comment · Fixed by #281
Closed

Infinite loop when removing in empty string. #280

mysteryven opened this issue Jul 28, 2024 · 1 comment · Fixed by #281

Comments

@mysteryven
Copy link
Contributor

Description

When using a negative index to remove, it will cause infinite loop.

const magicString = require('magic-string');
let s = ""
let ms = new magicString(s);
ms.remove(-2, -1);
console.log(map);

https://stackblitz.com/edit/stackblitz-starters-qxzkza?file=index.js

To reproduce it, run node index.js in the terminal.

Expect behaviour

it should throw error: Character is out of bounds

@antfu
Copy link
Collaborator

antfu commented Jul 29, 2024

Would you like to send a quick PR? Thanks!

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

Successfully merging a pull request may close this issue.

2 participants