Fixes conflict block rendering bug. (#162162)

This commit is contained in:
Henning Dieterichs 2022-09-28 14:10:45 +02:00 committed by GitHub
parent b0f88c162c
commit a1e8a52697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 4 deletions

View file

@ -82,10 +82,20 @@ export class BlockDecorations extends ViewPart {
block = this.blocks[count] = createFastDomNode(document.createElement('div'));
this.domNode.appendChild(block);
}
const top = ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, true);
const bottom = decoration.range.isEmpty()
? ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, false)
: ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
let top: number;
let bottom: number;
if (decoration.options.blockIsAfterEnd) {
// range must be empty
top = ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, false);
bottom = ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
} else {
top = ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, true);
bottom = decoration.range.isEmpty()
? ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, false)
: ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
}
block.setClassName('blockDecorations-block ' + decoration.options.blockClassName);
block.setLeft(ctx.scrollLeft);

View file

@ -92,6 +92,11 @@ export interface IModelDecorationOptions {
*/
className?: string | null;
blockClassName?: string | null;
/**
* Indicates if this block should be rendered after the last line.
* In this case, the range must be empty and set to the last line.
*/
blockIsAfterEnd?: boolean | null;
/**
* Message to be rendered when hovering over the glyph margin decoration.
*/

View file

@ -2231,6 +2231,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
readonly description: string;
readonly blockClassName: string | null;
readonly blockIsAfterEnd: boolean | null;
readonly stickiness: model.TrackedRangeStickiness;
readonly zIndex: number;
readonly className: string | null;
@ -2258,6 +2259,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
private constructor(options: model.IModelDecorationOptions) {
this.description = options.description;
this.blockClassName = options.blockClassName ? cleanClassName(options.blockClassName) : null;
this.blockIsAfterEnd = options.blockIsAfterEnd ?? null;
this.stickiness = options.stickiness || model.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;
this.zIndex = options.zIndex || 0;
this.className = options.className ? cleanClassName(options.className) : null;

5
src/vs/monaco.d.ts vendored
View file

@ -1488,6 +1488,11 @@ declare namespace monaco.editor {
*/
className?: string | null;
blockClassName?: string | null;
/**
* Indicates if this block should be rendered after the last line.
* In this case, the range must be empty and set to the last line.
*/
blockIsAfterEnd?: boolean | null;
/**
* Message to be rendered when hovering over the glyph margin decoration.
*/

View file

@ -158,6 +158,7 @@ export class InputCodeEditorView extends CodeEditorView {
options: {
showIfCollapsed: true,
blockClassName: blockClassNames.join(' '),
blockIsAfterEnd: range.startLineNumber > this.editor.getModel()!.getLineCount(),
description: 'Merge Editor',
minimap: {
position: MinimapPosition.Gutter,