Skip to content

Commit a1e8a52

Browse files
authored
Fixes conflict block rendering bug. (microsoft#162162)
1 parent b0f88c1 commit a1e8a52

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

src/vs/editor/browser/viewParts/blockDecorations/blockDecorations.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ export class BlockDecorations extends ViewPart {
8282
block = this.blocks[count] = createFastDomNode(document.createElement('div'));
8383
this.domNode.appendChild(block);
8484
}
85-
const top = ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, true);
86-
const bottom = decoration.range.isEmpty()
87-
? ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, false)
88-
: ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
85+
86+
let top: number;
87+
let bottom: number;
88+
89+
if (decoration.options.blockIsAfterEnd) {
90+
// range must be empty
91+
top = ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, false);
92+
bottom = ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
93+
} else {
94+
top = ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, true);
95+
bottom = decoration.range.isEmpty()
96+
? ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, false)
97+
: ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
98+
}
8999

90100
block.setClassName('blockDecorations-block ' + decoration.options.blockClassName);
91101
block.setLeft(ctx.scrollLeft);

src/vs/editor/common/model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export interface IModelDecorationOptions {
9292
*/
9393
className?: string | null;
9494
blockClassName?: string | null;
95+
/**
96+
* Indicates if this block should be rendered after the last line.
97+
* In this case, the range must be empty and set to the last line.
98+
*/
99+
blockIsAfterEnd?: boolean | null;
95100
/**
96101
* Message to be rendered when hovering over the glyph margin decoration.
97102
*/

src/vs/editor/common/model/textModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
22312231

22322232
readonly description: string;
22332233
readonly blockClassName: string | null;
2234+
readonly blockIsAfterEnd: boolean | null;
22342235
readonly stickiness: model.TrackedRangeStickiness;
22352236
readonly zIndex: number;
22362237
readonly className: string | null;
@@ -2258,6 +2259,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
22582259
private constructor(options: model.IModelDecorationOptions) {
22592260
this.description = options.description;
22602261
this.blockClassName = options.blockClassName ? cleanClassName(options.blockClassName) : null;
2262+
this.blockIsAfterEnd = options.blockIsAfterEnd ?? null;
22612263
this.stickiness = options.stickiness || model.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;
22622264
this.zIndex = options.zIndex || 0;
22632265
this.className = options.className ? cleanClassName(options.className) : null;

src/vs/monaco.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,11 @@ declare namespace monaco.editor {
14881488
*/
14891489
className?: string | null;
14901490
blockClassName?: string | null;
1491+
/**
1492+
* Indicates if this block should be rendered after the last line.
1493+
* In this case, the range must be empty and set to the last line.
1494+
*/
1495+
blockIsAfterEnd?: boolean | null;
14911496
/**
14921497
* Message to be rendered when hovering over the glyph margin decoration.
14931498
*/

src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export class InputCodeEditorView extends CodeEditorView {
158158
options: {
159159
showIfCollapsed: true,
160160
blockClassName: blockClassNames.join(' '),
161+
blockIsAfterEnd: range.startLineNumber > this.editor.getModel()!.getLineCount(),
161162
description: 'Merge Editor',
162163
minimap: {
163164
position: MinimapPosition.Gutter,

0 commit comments

Comments
 (0)