Fix source map for characters collapsed at the start of a string
This commit is contained in:
parent
42a2917bf7
commit
0b7791c103
@ -377,11 +377,11 @@
|
|||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
|
||||||
function collapseEmphaticSequences(sourceText, fullCollapse, sourceMap=null) {
|
function collapseEmphaticSequences(text, fullCollapse, sourceMap=null) {
|
||||||
let result = '';
|
let result = '';
|
||||||
let collapseCodePoint = -1;
|
let collapseCodePoint = -1;
|
||||||
const hasSourceMap = (sourceMap !== null);
|
const hasSourceMap = (sourceMap !== null);
|
||||||
for (const char of sourceText) {
|
for (const char of text) {
|
||||||
const c = char.codePointAt(0);
|
const c = char.codePointAt(0);
|
||||||
if (c === HIRAGANA_SMALL_TSU_CODE_POINT || c === KATAKANA_SMALL_TSU_CODE_POINT) {
|
if (c === HIRAGANA_SMALL_TSU_CODE_POINT || c === KATAKANA_SMALL_TSU_CODE_POINT) {
|
||||||
if (collapseCodePoint !== c) {
|
if (collapseCodePoint !== c) {
|
||||||
@ -398,10 +398,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasSourceMap) {
|
if (hasSourceMap) {
|
||||||
const index = result.length;
|
sourceMap.combine(Math.max(0, result.length - 1), 1);
|
||||||
if (index > 0) {
|
|
||||||
sourceMap.combine(index - 1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user