diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-10 12:25:24 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-10 12:25:24 -0400 |
commit | 0b7791c103508e4b23d57717a97644993edf76d5 (patch) | |
tree | bdacd63a0cc67c1ac6922d6a4299503662ba5077 /ext/bg/js/japanese.js | |
parent | 42a2917bf7aa3ab424ada2fc3acf224b74020a7f (diff) |
Fix source map for characters collapsed at the start of a string
Diffstat (limited to 'ext/bg/js/japanese.js')
-rw-r--r-- | ext/bg/js/japanese.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index e8b258cb..71fbebb5 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -377,11 +377,11 @@ // Miscellaneous - function collapseEmphaticSequences(sourceText, fullCollapse, sourceMap=null) { + function collapseEmphaticSequences(text, fullCollapse, sourceMap=null) { let result = ''; let collapseCodePoint = -1; const hasSourceMap = (sourceMap !== null); - for (const char of sourceText) { + for (const char of text) { const c = char.codePointAt(0); if (c === HIRAGANA_SMALL_TSU_CODE_POINT || c === KATAKANA_SMALL_TSU_CODE_POINT) { if (collapseCodePoint !== c) { @@ -398,10 +398,7 @@ } if (hasSourceMap) { - const index = result.length; - if (index > 0) { - sourceMap.combine(index - 1, 1); - } + sourceMap.combine(Math.max(0, result.length - 1), 1); } } return result; |