diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-19 18:39:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 18:39:43 -0500 |
commit | 1e927dd66e24b72ac3ba129dfb578746ce896ce2 (patch) | |
tree | b678d6de8cf61440c6c10ef6e9568ccff6ffe5b9 /ext/js | |
parent | 6a6d7ba84e778d1e5917f905748fe752a8712016 (diff) |
Fix translation regex replacements (#1423)
* Fix regex replacements having issues at the start of scanned text
* Fix test cases
* Add tests
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/language/translator.js | 2 |
1 files changed, 1 insertions, 1 deletions
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); } |