mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 01:25:42 -05:00
Adds diff info to active line hover always
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
export interface IGitDiffChunk {
|
||||
current: (string | undefined)[];
|
||||
currentStart: number;
|
||||
currentEnd: number;
|
||||
|
||||
previous: (string | undefined)[];
|
||||
previousStart: number;
|
||||
previousEnd: number;
|
||||
|
||||
chunk?: string;
|
||||
|
||||
original: (string | undefined)[];
|
||||
originalStart: number;
|
||||
originalEnd: number;
|
||||
|
||||
changes: (string | undefined)[];
|
||||
changesStart: number;
|
||||
changesEnd: number;
|
||||
}
|
||||
|
||||
export interface IGitDiff {
|
||||
diff?: string;
|
||||
chunks: IGitDiffChunk[];
|
||||
|
||||
diff?: string;
|
||||
}
|
||||
@@ -15,22 +15,41 @@ export class GitDiffParser {
|
||||
match = unifiedDiffRegex.exec(`${data}\n@@`);
|
||||
if (match == null) break;
|
||||
|
||||
const originalStart = +match[1];
|
||||
const changedStart = +match[3];
|
||||
const previousStart = +match[1];
|
||||
const currentStart = +match[3];
|
||||
|
||||
const chunk = match[5];
|
||||
const lines = chunk.split('\n').slice(1);
|
||||
const original = lines.filter(l => l[0] !== '+').map(l => (l[0] === '-') ? l.substring(1) : undefined);
|
||||
const changed = lines.filter(l => l[0] !== '-').map(l => (l[0] === '+') ? l.substring(1) : undefined);
|
||||
|
||||
const current = [];
|
||||
const previous = [];
|
||||
for (const l of lines) {
|
||||
switch (l[0]) {
|
||||
case '+':
|
||||
current.push(` ${l.substring(1)}`);
|
||||
previous.push(undefined);
|
||||
break;
|
||||
|
||||
case '-':
|
||||
current.push(undefined);
|
||||
previous.push(` ${l.substring(1)}`);
|
||||
break;
|
||||
|
||||
default:
|
||||
current.push(l);
|
||||
previous.push(l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
chunks.push({
|
||||
chunk: debug ? chunk : undefined,
|
||||
original: original,
|
||||
originalStart: originalStart,
|
||||
originalEnd: originalStart + +match[2],
|
||||
changes: changed,
|
||||
changesStart: changedStart,
|
||||
changesEnd: changedStart + +match[4]
|
||||
current: current,
|
||||
currentStart: currentStart,
|
||||
currentEnd: currentStart + +match[4],
|
||||
previous: previous,
|
||||
previousStart: previousStart,
|
||||
previousEnd: previousStart + +match[2]
|
||||
});
|
||||
} while (match != null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user