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

Function startBlock

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

Source from the content-addressed store, hash-verified

145 }
146
147 function startBlock(line: string): void {
148 saveBlock();
149
150 let values;
151
152 /**
153 * From Range:
154 * -<start line>[,<number of lines>]
155 *
156 * To Range:
157 * +<start line>[,<number of lines>]
158 *
159 * @@ from-file-range to-file-range @@
160 *
161 * @@@ from-file-range from-file-range to-file-range @@@
162 *
163 * number of lines is optional, if omited consider 0
164 */
165
166 if (currentFile !== null) {
167 if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) {
168 currentFile.isCombined = false;
169 oldLine = parseInt(values[1], 10);
170 newLine = parseInt(values[2], 10);
171 } else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) {
172 currentFile.isCombined = true;
173 oldLine = parseInt(values[1], 10);
174 oldLine2 = parseInt(values[2], 10);
175 newLine = parseInt(values[3], 10);
176 } else {
177 if (line.startsWith(hunkHeaderPrefix)) {
178 console.error('Failed to parse lines, starting in 0!');
179 }
180
181 oldLine = 0;
182 newLine = 0;
183 currentFile.isCombined = false;
184 }
185 }
186
187 /* Create block metadata */
188 currentBlock = {
189 lines: [],
190 // eslint-disable-next-line
191 // @ts-ignore
192 oldStartLine: oldLine,
193 // eslint-disable-next-line
194 // @ts-ignore
195 oldStartLine2: oldLine2,
196 // eslint-disable-next-line
197 // @ts-ignore
198 newStartLine: newLine,
199 header: line,
200 };
201 }
202
203 function createLine(line: string): void {
204 if (currentFile === null || currentBlock === null || oldLine === null || newLine === null) return;

Callers 1

parseFunction · 0.85

Calls 1

saveBlockFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…