MCPcopy Index your code
hub / github.com/rtfpessoa/diff2html / createLine

Function createLine

src/diff-parser.ts:203–231  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

201 }
202
203 function createLine(line: string): void {
204 if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) return;
205
206 // eslint-disable-next-line
207 // @ts-ignore
208 const currentLine: DiffLine = {
209 content: line,
210 };
211
212 const addedPrefixes = currentFile.isCombined ? ['+ ', ' +', '++'] : ['+'];
213 const deletedPrefixes = currentFile.isCombined ? ['- ', ' -', '--'] : ['-'];
214
215 if (startsWithAny(line, addedPrefixes)) {
216 currentFile.addedLines++;
217 currentLine.type = LineType.INSERT;
218 currentLine.oldNumber = undefined;
219 currentLine.newNumber = newLine++;
220 } else if (startsWithAny(line, deletedPrefixes)) {
221 currentFile.deletedLines++;
222 currentLine.type = LineType.DELETE;
223 currentLine.oldNumber = oldLine++;
224 currentLine.newNumber = undefined;
225 } else {
226 currentLine.type = LineType.CONTEXT;
227 currentLine.oldNumber = oldLine++;
228 currentLine.newNumber = newLine++;
229 }
230 currentBlock.lines.push(currentLine);
231 }
232
233 /*
234 * Checks if there is a hunk header coming before a new file starts

Callers 1

parseFunction · 0.85

Calls 1

startsWithAnyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…