Fix markers errors

This commit is contained in:
yflory 2020-04-20 16:37:40 +02:00
parent 0ca779dbd1
commit 49eacf752b
1 changed files with 19 additions and 7 deletions

View File

@ -219,6 +219,8 @@ define([
var toKeep = []; var toKeep = [];
var toJoin = {}; var toJoin = {};
var firstMarks = first.marks.slice();
debug('error', "Fix marks"); debug('error', "Fix marks");
debug('warn', first); debug('warn', first);
debug('warn', last); debug('warn', last);
@ -258,9 +260,15 @@ define([
// If we still have markers in "first", store the last one so that we can "join" // If we still have markers in "first", store the last one so that we can "join"
// everything at the end // everything at the end
// NOTE: we only join if the marks were joined initially!
if (first.marks.length) { if (first.marks.length) {
var toJoinMark = first.marks[first.marks.length - 1].slice(); var idx = first.marks.length - 1;
var toJoinMark = first.marks[index].slice();
toJoin = parseMark(toJoinMark); toJoin = parseMark(toJoinMark);
var next = parseMark(firstMarks[idx + 1]); // always an object
if (toJoin.endLine !== next.startLine || toJoin.endCh !== next.startCh) {
toJoin.overlapOnly = true;
}
} }
@ -302,13 +310,17 @@ define([
&& typeof(toJoin.endCh) !== "undefined") { && typeof(toJoin.endCh) !== "undefined") {
// Make sure the marks are joined correctly: // Make sure the marks are joined correctly:
// fix the start position of the marks to keep // fix the start position of the marks to keep
// Note: we must preserve the same end for this mark if it was single line! var overlap = toKeepEnd[0][1] < toJoin.endLine ||
if (typeof(toKeepEnd[0][4]) === "undefined") { // Single line (toKeepEnd[0][1] === toJoin.endLine && toKeepEnd[0][2] < toJoin.endCh);
toKeepEnd[0][4] = toKeepEnd[0][3] || (toKeepEnd[0][2]+1); // preserve end ch if (!toJoin.overlapOnly || overlap) {
toKeepEnd[0][3] = toKeepEnd[0][1]; // preserve end line // Note: we must preserve the same end for this mark if it was single line!
if (typeof(toKeepEnd[0][4]) === "undefined") { // Single line
toKeepEnd[0][4] = toKeepEnd[0][3] || (toKeepEnd[0][2]+1); // preserve end ch
toKeepEnd[0][3] = toKeepEnd[0][1]; // preserve end line
}
toKeepEnd[0][1] = toJoin.endLine;
toKeepEnd[0][2] = toJoin.endCh;
} }
toKeepEnd[0][1] = toJoin.endLine;
toKeepEnd[0][2] = toJoin.endCh;
} }
debug('log', 'Fixed'); debug('log', 'Fixed');