From 1e927dd66e24b72ac3ba129dfb578746ce896ce2 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 19 Feb 2021 18:39:43 -0500 Subject: Fix translation regex replacements (#1423) * Fix regex replacements having issues at the start of scanned text * Fix test cases * Add tests --- ext/js/language/translator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/js') diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 729c8294..fc71bf7f 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -1361,8 +1361,8 @@ class Translator { pattern.lastIndex += delta; if (actualReplacementLength > 0) { - sourceMap.combine(Math.max(0, index - 1), matchText.length); sourceMap.insert(index, ...(new Array(actualReplacementLength).fill(0))); + sourceMap.combine(index - 1 + actualReplacementLength, matchText.length); } else { sourceMap.combine(index, matchText.length); } -- cgit v1.2.3