瀏覽代碼

Fixes diff header parsing

main
Eric Amodio 1 年之前
父節點
當前提交
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) {
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;

Loading…
取消
儲存