Просмотр исходного кода

Fixes diff header parsing

main
Eric Amodio 1 год назад
Родитель
Сommit
e2ff94680c
1 измененных файлов: 5 добавлений и 5 удалений
  1. +5
    -5
      src/git/parsers/diffParser.ts

+ 5
- 5
src/git/parsers/diffParser.ts Просмотреть файл

@ -6,8 +6,8 @@ const shortStatDiffRegex = /(\d+)\s+files? changed(?:,\s+(\d+)\s+insertions?\(\+
function parseHunkHeaderPart(headerPart: string) { function parseHunkHeaderPart(headerPart: string) {
const [startS, countS] = headerPart.split(','); const [startS, countS] = headerPart.split(',');
const count = Number(countS) || 1;
const start = Number(startS); const start = Number(startS);
const count = Number(countS) || 1;
return { count: count, position: { start: start, end: start + count - 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]; line = lines[i];
if (!line.startsWith('@@')) continue; 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>(); const hunkLines = new Map<number, GitDiffHunkLine>();
let fileLineNumber = current.position.start; let fileLineNumber = current.position.start;

Загрузка…
Отмена
Сохранить