Ver a proveniência

Fixes diff header parsing

main
Eric Amodio há 1 ano
ascendente
cometimento
e2ff94680c
1 ficheiros alterados com 5 adições e 5 eliminações
  1. +5
    -5
      src/git/parsers/diffParser.ts

+ 5
- 5
src/git/parsers/diffParser.ts Ver ficheiro

@ -6,8 +6,8 @@ const shortStatDiffRegex = /(\d+)\s+files? changed(?:,\s+(\d+)\s+insertions?\(\+
function parseHunkHeaderPart(headerPart: string) {
const [startS, countS] = headerPart.split(',');
const count = Number(countS) || 1;
const start = Number(startS);
const count = Number(countS) || 1;
return { count: count, position: { start: start, end: start + count - 1 } };
}
@ -33,11 +33,11 @@ export function parseGitFileDiff(data: string, includeContents = false): GitDiff
line = lines[i];
if (!line.startsWith('@@')) continue;
const content = line.slice(4, -3);
const [previousHeaderPart, currentHeaderPart] = content.split(' +');
const header = line.split('@@')[1].trim();
const [previousHeaderPart, currentHeaderPart] = header.split(' ');
const current = parseHunkHeaderPart(currentHeaderPart);
const previous = parseHunkHeaderPart(previousHeaderPart);
const current = parseHunkHeaderPart(currentHeaderPart.slice(1));
const previous = parseHunkHeaderPart(previousHeaderPart.slice(1));
const hunkLines = new Map<number, GitDiffHunkLine>();
let fileLineNumber = current.position.start;

Carregando…
Cancelar
Guardar