未验证 提交 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 { ...@@ -2302,6 +2302,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
} }
} }
} }
const hasCharChanges = (decorations.length > 0);
const sb = createStringBuilder(10000); const sb = createStringBuilder(10000);
let maxCharsPerLine = 0; let maxCharsPerLine = 0;
...@@ -2321,7 +2322,8 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -2321,7 +2322,8 @@ class InlineViewZonesComputer extends ViewZonesComputer {
renderedLineCount++, renderedLineCount++,
viewLineContent, viewLineContent,
viewLineTokens, viewLineTokens,
actualDecorations, LineDecoration.extractWrapped(actualDecorations, lastBreakOffset, breakOffset),
hasCharChanges,
mightContainNonBasicASCII, mightContainNonBasicASCII,
mightContainRTL, mightContainRTL,
fontInfo, fontInfo,
...@@ -2354,6 +2356,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -2354,6 +2356,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
lineContent, lineContent,
lineTokens, lineTokens,
actualDecorations, actualDecorations,
hasCharChanges,
mightContainNonBasicASCII, mightContainNonBasicASCII,
mightContainRTL, mightContainRTL,
fontInfo, fontInfo,
...@@ -2386,6 +2389,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -2386,6 +2389,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
lineContent: string, lineContent: string,
lineTokens: IViewLineTokens, lineTokens: IViewLineTokens,
decorations: LineDecoration[], decorations: LineDecoration[],
hasCharChanges: boolean,
mightContainNonBasicASCII: boolean, mightContainNonBasicASCII: boolean,
mightContainRTL: boolean, mightContainRTL: boolean,
fontInfo: FontInfo, fontInfo: FontInfo,
...@@ -2402,7 +2406,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -2402,7 +2406,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
): number { ): number {
sb.appendASCIIString('<div class="view-line'); sb.appendASCIIString('<div class="view-line');
if (decorations.length === 0) { if (!hasCharChanges) {
// No char changes // No char changes
sb.appendASCIIString(' char-delete'); sb.appendASCIIString(' char-delete');
} }
......
...@@ -42,6 +42,24 @@ export class LineDecoration { ...@@ -42,6 +42,24 @@ export class LineDecoration {
return true; 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[] { public static filter(lineDecorations: InlineDecoration[], lineNumber: number, minLineColumn: number, maxLineColumn: number): LineDecoration[] {
if (lineDecorations.length === 0) { if (lineDecorations.length === 0) {
return []; return [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册