@pierre/diffs 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor/editor.js +2 -2
- package/dist/editor/editor2.js +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +39 -0
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/worker/worker-portable.js +39 -0
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +39 -0
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/worker/worker.js
CHANGED
|
@@ -1432,12 +1432,51 @@ function renderDiffWithHighlighter(diff, highlighter, options, { forcePlainText,
|
|
|
1432
1432
|
baseThemeType
|
|
1433
1433
|
};
|
|
1434
1434
|
}
|
|
1435
|
+
function pushWordLineDecorations(lineDiff, { deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations }) {
|
|
1436
|
+
let deletionOffset = 0;
|
|
1437
|
+
let additionOffset = 0;
|
|
1438
|
+
let deletionStart = -1;
|
|
1439
|
+
let deletionEnd = 0;
|
|
1440
|
+
let additionStart = -1;
|
|
1441
|
+
let additionEnd = 0;
|
|
1442
|
+
for (const { value, added, removed } of lineDiff) if (removed) {
|
|
1443
|
+
if (deletionStart === -1) deletionStart = deletionOffset;
|
|
1444
|
+
deletionOffset += value.length;
|
|
1445
|
+
deletionEnd = deletionOffset;
|
|
1446
|
+
} else if (added) {
|
|
1447
|
+
if (additionStart === -1) additionStart = additionOffset;
|
|
1448
|
+
additionOffset += value.length;
|
|
1449
|
+
additionEnd = additionOffset;
|
|
1450
|
+
} else {
|
|
1451
|
+
deletionOffset += value.length;
|
|
1452
|
+
additionOffset += value.length;
|
|
1453
|
+
}
|
|
1454
|
+
if (deletionStart !== -1) deletionDecorations.push(createDiffSpanDecoration({
|
|
1455
|
+
line: deletionLineIndex,
|
|
1456
|
+
spanStart: deletionStart,
|
|
1457
|
+
spanLength: deletionEnd - deletionStart
|
|
1458
|
+
}));
|
|
1459
|
+
if (additionStart !== -1) additionDecorations.push(createDiffSpanDecoration({
|
|
1460
|
+
line: additionLineIndex,
|
|
1461
|
+
spanStart: additionStart,
|
|
1462
|
+
spanLength: additionEnd - additionStart
|
|
1463
|
+
}));
|
|
1464
|
+
}
|
|
1435
1465
|
function computeLineDiffDecorations({ deletionLine, additionLine, deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations, lineDiffType, maxLineDiffLength }) {
|
|
1436
1466
|
if (deletionLine == null || additionLine == null || lineDiffType === "none") return;
|
|
1437
1467
|
deletionLine = cleanLastNewline(deletionLine);
|
|
1438
1468
|
additionLine = cleanLastNewline(additionLine);
|
|
1439
1469
|
if (deletionLine.length > maxLineDiffLength || additionLine.length > maxLineDiffLength) return;
|
|
1440
1470
|
const lineDiff = lineDiffType === "char" ? diffChars(deletionLine, additionLine) : diffWordsWithSpace(deletionLine, additionLine);
|
|
1471
|
+
if (lineDiffType === "word-line") {
|
|
1472
|
+
pushWordLineDecorations(lineDiff, {
|
|
1473
|
+
deletionLineIndex,
|
|
1474
|
+
additionLineIndex,
|
|
1475
|
+
deletionDecorations,
|
|
1476
|
+
additionDecorations
|
|
1477
|
+
});
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1441
1480
|
const deletionSpans = [];
|
|
1442
1481
|
const additionSpans = [];
|
|
1443
1482
|
const enableJoin = lineDiffType === "word-alt";
|