MCPcopy Create free account
hub / github.com/bigcode-project/jupytercoder / calcOldNewLineCount

Function calcOldNewLineCount

src/diff.js:1472–1509  ·  view source on GitHub ↗
(lines)

Source from the content-addressed store, hash-verified

1470 }
1471
1472 function calcOldNewLineCount(lines) {
1473 var oldLines = 0;
1474 var newLines = 0;
1475 lines.forEach(function (line) {
1476 if (typeof line !== 'string') {
1477 var myCount = calcOldNewLineCount(line.mine);
1478 var theirCount = calcOldNewLineCount(line.theirs);
1479
1480 if (oldLines !== undefined) {
1481 if (myCount.oldLines === theirCount.oldLines) {
1482 oldLines += myCount.oldLines;
1483 } else {
1484 oldLines = undefined;
1485 }
1486 }
1487
1488 if (newLines !== undefined) {
1489 if (myCount.newLines === theirCount.newLines) {
1490 newLines += myCount.newLines;
1491 } else {
1492 newLines = undefined;
1493 }
1494 }
1495 } else {
1496 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
1497 newLines++;
1498 }
1499
1500 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
1501 oldLines++;
1502 }
1503 }
1504 });
1505 return {
1506 oldLines: oldLines,
1507 newLines: newLines
1508 };
1509 }
1510
1511 // See: http://code.google.com/p/google-diff-match-patch/wiki/API
1512 function convertChangesToDMP(changes) {

Callers 1

calcLineCountFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected