From cb64acbf7a9f321d1eb3c9228c05beb8028d2409 Mon Sep 17 00:00:00 2001 From: steve02081504 Date: Thu, 30 Oct 2025 10:21:44 +0800 Subject: [PATCH] fix #305 --- src/TransformableString.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TransformableString.js b/src/TransformableString.js index afdeb0f..7888804 100644 --- a/src/TransformableString.js +++ b/src/TransformableString.js @@ -25,7 +25,7 @@ function locationToIndex(location, lineStarts) { } function indexToLocation(index, lineStarts) { - if (index < 0) throw new Error("Invalid index") + if (index < 0) return let line = 0 while (line + 1 < lineStarts.length && lineStarts[line + 1] <= index) { @@ -106,7 +106,7 @@ module.exports = class TransformableString { } } if (index < 0 || index > this._original.length) { - throw new Error("Invalid index") + return } if (index == this._original.length) { if (block.to && block.to === this._original.length) {