提交 7fddf0f1 编写于 作者: M Martin Aeschlimann

line decorations for first and last line

上级 539f0f1e
......@@ -74,9 +74,17 @@ export class LinesDecorationsOverlay extends DedupOverlay {
let r: DecorationToRender[] = [], rLen = 0;
for (let i = 0, len = decorations.length; i < len; i++) {
const d = decorations[i];
const linesDecorationsClassName = d.options.linesDecorationsClassName;
if (linesDecorationsClassName) {
r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, linesDecorationsClassName);
const linesDecorations = d.options.linesDecorationsClassName;
if (linesDecorations) {
r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, linesDecorations);
}
const firstLineDecorationsClassName = d.options.firstLineDecorationsClassName;
if (firstLineDecorationsClassName) {
r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.startLineNumber, firstLineDecorationsClassName);
}
const lastLineDecorationsClassName = d.options.lastLineDecorationsClassName;
if (lastLineDecorationsClassName) {
r[rLen++] = new DecorationToRender(d.range.endLineNumber, d.range.endLineNumber, lastLineDecorationsClassName);
}
}
return r;
......
......@@ -123,6 +123,14 @@ export interface IModelDecorationOptions {
* If set, the decoration will be rendered in the lines decorations with this CSS class name.
*/
linesDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered for first line of the range in the lines decorations with this CSS class name.
*/
firstLineDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered for last line of the range in the lines decorations for last line with this CSS class name.
*/
lastLineDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name.
*/
......
......@@ -3053,6 +3053,8 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
readonly minimap: ModelDecorationMinimapOptions | null;
readonly glyphMarginClassName: string | null;
readonly linesDecorationsClassName: string | null;
readonly firstLineDecorationsClassName: string | null;
readonly lastLineDecorationsClassName: string | null;
readonly marginClassName: string | null;
readonly inlineClassName: string | null;
readonly inlineClassNameAffectsLetterSpacing: boolean;
......@@ -3072,6 +3074,8 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
this.minimap = options.minimap ? new ModelDecorationMinimapOptions(options.minimap) : null;
this.glyphMarginClassName = options.glyphMarginClassName ? cleanClassName(options.glyphMarginClassName) : null;
this.linesDecorationsClassName = options.linesDecorationsClassName ? cleanClassName(options.linesDecorationsClassName) : null;
this.firstLineDecorationsClassName = options.firstLineDecorationsClassName ? cleanClassName(options.firstLineDecorationsClassName) : null;
this.lastLineDecorationsClassName = options.lastLineDecorationsClassName ? cleanClassName(options.lastLineDecorationsClassName) : null;
this.marginClassName = options.marginClassName ? cleanClassName(options.marginClassName) : null;
this.inlineClassName = options.inlineClassName ? cleanClassName(options.inlineClassName) : null;
this.inlineClassNameAffectsLetterSpacing = options.inlineClassNameAffectsLetterSpacing || false;
......
......@@ -13,7 +13,8 @@ export class FoldingDecorationProvider implements IDecorationProvider {
private static readonly COLLAPSED_VISUAL_DECORATION = ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
afterContentClassName: 'inline-folded',
linesDecorationsClassName: 'codicon codicon-chevron-right'
isWholeLine: true,
firstLineDecorationsClassName: 'codicon codicon-chevron-right'
});
private static readonly COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION = ModelDecorationOptions.register({
......@@ -21,16 +22,19 @@ export class FoldingDecorationProvider implements IDecorationProvider {
afterContentClassName: 'inline-folded',
className: 'folded-background',
isWholeLine: true,
linesDecorationsClassName: 'codicon codicon-chevron-right'
firstLineDecorationsClassName: 'codicon codicon-chevron-right'
});
private static readonly EXPANDED_AUTO_HIDE_VISUAL_DECORATION = ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
linesDecorationsClassName: 'codicon codicon-chevron-down'
isWholeLine: true,
firstLineDecorationsClassName: 'codicon codicon-chevron-down'
});
private static readonly EXPANDED_VISUAL_DECORATION = ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
isWholeLine: true,
firstLineDecorationsClassName: 'codicon codicon-chevron-down alwaysShowFoldIcons'
});
private static readonly HIDDEN_RANGE_DECORATION = ModelDecorationOptions.register({
......
......@@ -1369,6 +1369,14 @@ declare namespace monaco.editor {
* If set, the decoration will be rendered in the lines decorations with this CSS class name.
*/
linesDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered for first line of the range in the lines decorations with this CSS class name.
*/
firstLineDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered for last line of the range in the lines decorations for last line with this CSS class name.
*/
lastLineDecorationsClassName?: string | null;
/**
* If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册