Skip to content

Infinite loop when removing in empty string. #280

Description

@mysteryven

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions