未验证 提交 0e4b1fec 编写于 作者: A Alex Dima

Render char diffs in the wrapped deleted or change lines in the inline diff

上级 a56c7406
......@@ -2302,6 +2302,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
}
}
}
const hasCharChanges = (decorations.length > 0);
const sb = createStringBuilder(10000);
let maxCharsPerLine = 0;
......@@ -2321,7 +2322,8 @@ class InlineViewZonesComputer extends ViewZonesComputer {
renderedLineCount++,
viewLineContent,
viewLineTokens,
actualDecorations,
LineDecoration.extractWrapped(actualDecorations, lastBreakOffset, breakOffset),
hasCharChanges,
mightContainNonBasicASCII,
mightContainRTL,
fontInfo,
......@@ -2354,6 +2356,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
lineContent,
lineTokens,
actualDecorations,
hasCharChanges,
mightContainNonBasicASCII,
mightContainRTL,
fontInfo,
......@@ -2386,6 +2389,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
lineContent: string,
lineTokens: IViewLineTokens,
decorations: LineDecoration[],
hasCharChanges: boolean,
mightContainNonBasicASCII: boolean,
mightContainRTL: boolean,
fontInfo: FontInfo,
......@@ -2402,7 +2406,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
): number {
sb.appendASCIIString('<div class="view-line');
if (decorations.length === 0) {
if (!hasCharChanges) {
// No char changes
sb.appendASCIIString(' char-delete');
}
......
......@@ -42,6 +42,24 @@ export class LineDecoration {
return true;
}
public static extractWrapped(arr: LineDecoration[], startOffset: number, endOffset: number): LineDecoration[] {
if (arr.length === 0) {
return arr;
}
const startColumn = startOffset + 1;
const endColumn = endOffset + 1;
const lineLength = endOffset - startOffset;
const r = [];
let rLength = 0;
for (const dec of arr) {
if (dec.endColumn <= startColumn || dec.startColumn >= endColumn) {
continue;
}
r[rLength++] = new LineDecoration(Math.max(1, dec.startColumn - startColumn + 1), Math.min(lineLength + 1, dec.endColumn - startColumn + 1), dec.className, dec.type);
}
return r;
}
public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): LineDecoration[] {
if (lineDecorations.length === 0) {
return [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册