Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes conflict block rendering bug. #162162

Merged
merged 1 commit into from Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/vs/editor/common/model.ts
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/common/model/textModel.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/vs/monaco.d.ts
Expand Up @@ -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.
*/
Expand Down
Expand Up @@ -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,
Expand Down