have option to make block decorations not collapsed

This commit is contained in:
Johannes 2023-03-02 09:24:32 +01:00
parent f505dde405
commit b5827cf895
No known key found for this signature in database
GPG key ID: 6DEF802A22264FCA
4 changed files with 5 additions and 1 deletions

View file

@ -99,7 +99,7 @@ export class BlockDecorations extends ViewPart {
bottom = ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
} else {
top = ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, true);
bottom = decoration.range.isEmpty()
bottom = decoration.range.isEmpty() && !decoration.options.blockDoesNotCollapse
? ctx.getVerticalOffsetForLineNumber(decoration.range.startLineNumber, false)
: ctx.getVerticalOffsetAfterLineNumber(decoration.range.endLineNumber, true);
}

View file

@ -99,6 +99,7 @@ export interface IModelDecorationOptions {
* In this case, the range must be empty and set to the last line.
*/
blockIsAfterEnd?: boolean | null;
blockDoesNotCollapse?: boolean | null;
blockPadding?: [top: number, right: number, bottom: number, left: number] | null;
/**

View file

@ -2248,6 +2248,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
readonly description: string;
readonly blockClassName: string | null;
readonly blockIsAfterEnd: boolean | null;
readonly blockDoesNotCollapse?: boolean | null;
readonly blockPadding: [top: number, right: number, bottom: number, left: number] | null;
readonly stickiness: model.TrackedRangeStickiness;
readonly zIndex: number;
@ -2275,6 +2276,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.blockDoesNotCollapse = options.blockDoesNotCollapse ?? null;
this.blockIsAfterEnd = options.blockIsAfterEnd ?? null;
this.blockPadding = options.blockPadding ?? null;
this.stickiness = options.stickiness || model.TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges;

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

@ -1552,6 +1552,7 @@ declare namespace monaco.editor {
* In this case, the range must be empty and set to the last line.
*/
blockIsAfterEnd?: boolean | null;
blockDoesNotCollapse?: boolean | null;
blockPadding?: [top: number, right: number, bottom: number, left: number] | null;
/**
* Message to be rendered when hovering over the glyph margin decoration.