MCPcopy Create free account
hub / github.com/agegr/pi-web / flushChanges

Function flushChanges

lib/patch.ts:34–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33 const emptyCell = (): SplitDiffCell => ({ lineNo: null, text: "", type: "empty" });
34 const flushChanges = () => {
35 if (!current) {
36 removed = [];
37 added = [];
38 return;
39 }
40 const count = Math.max(removed.length, added.length);
41 for (let i = 0; i < count; i++) {
42 const left = removed[i]
43 ? { lineNo: removed[i].lineNo, text: removed[i].text, type: "removed" as const }
44 : emptyCell();
45 const right = added[i]
46 ? { lineNo: added[i].lineNo, text: added[i].text, type: "added" as const }
47 : emptyCell();
48 current.rows.push({ type: "line", left, right });
49 }
50 removed = [];
51 added = [];
52 };
53
54 for (const line of text.split(/\r?\n/)) {
55 if (line.startsWith("--- ")) {

Callers 1

parseUnifiedPatchFunction · 0.85

Calls 1

emptyCellFunction · 0.85

Tested by

no test coverage detected