提交 8f634171 编写于 作者: A Alex Dima

Only show a certain subset of decorations when they are collapsed

上级 bc0c7879
......@@ -146,24 +146,26 @@ export class DecorationsOverlay extends DynamicViewOverlay {
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
for (let i = 0, lenI = decorations.length; i < lenI; i++) {
let d = decorations[i];
const d = decorations[i];
if (d.source.options.isWholeLine) {
continue;
}
let className = d.source.options.className;
const className = d.source.options.className;
let linesVisibleRanges = ctx.linesVisibleRangesForRange(d.range, /*TODO@Alex*/className === 'findMatch');
if (!linesVisibleRanges) {
continue;
}
const showIfCollapsed = d.source.options.showIfCollapsed;
for (let j = 0, lenJ = linesVisibleRanges.length; j < lenJ; j++) {
let lineVisibleRanges = linesVisibleRanges[j];
let lineIndex = lineVisibleRanges.lineNumber - visibleStartLineNumber;
const lineIndex = lineVisibleRanges.lineNumber - visibleStartLineNumber;
if (lineVisibleRanges.ranges.length === 1) {
if (showIfCollapsed && lineVisibleRanges.ranges.length === 1) {
const singleVisibleRange = lineVisibleRanges.ranges[0];
if (singleVisibleRange.width === 0) {
// collapsed range case => make the decoration visible by faking its width
......@@ -172,8 +174,8 @@ export class DecorationsOverlay extends DynamicViewOverlay {
}
for (let k = 0, lenK = lineVisibleRanges.ranges.length; k < lenK; k++) {
let visibleRange = lineVisibleRanges.ranges[k];
let decorationOutput = (
const visibleRange = lineVisibleRanges.ranges[k];
const decorationOutput = (
'<div class="cdr '
+ className
+ '" style="left:'
......
......@@ -85,6 +85,11 @@ export interface IModelDecorationOptions {
* Should the decoration expand to encompass a whole line.
*/
isWholeLine?: boolean;
/**
* Always render the decoration (even when the range it encompasses is collapsed).
* @internal
*/
showIfCollapsed?: boolean;
/**
* @deprecated : Use `overviewRuler` instead
*/
......
......@@ -846,6 +846,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
hoverMessage: MarkedString | MarkedString[];
glyphMarginHoverMessage: MarkedString | MarkedString[];
isWholeLine: boolean;
showIfCollapsed: boolean;
showInOverviewRuler: string;
overviewRuler: editorCommon.IModelDecorationOverviewRulerOptions;
glyphMarginClassName: string;
......@@ -861,6 +862,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
this.hoverMessage = options.hoverMessage || [];
this.glyphMarginHoverMessage = options.glyphMarginHoverMessage || strings.empty;
this.isWholeLine = options.isWholeLine || false;
this.showIfCollapsed = options.showIfCollapsed || false;
this.overviewRuler = _normalizeOverviewRulerOptions(options.overviewRuler, options.showInOverviewRuler);
this.glyphMarginClassName = options.glyphMarginClassName ? cleanClassName(options.glyphMarginClassName) : strings.empty;
this.linesDecorationsClassName = options.linesDecorationsClassName ? cleanClassName(options.linesDecorationsClassName) : strings.empty;
......@@ -883,6 +885,7 @@ export class ModelDecorationOptions implements editorCommon.IModelDecorationOpti
this.stickiness === other.stickiness
&& this.className === other.className
&& this.isWholeLine === other.isWholeLine
&& this.showIfCollapsed === other.showIfCollapsed
&& this.showInOverviewRuler === other.showInOverviewRuler
&& this.glyphMarginClassName === other.glyphMarginClassName
&& this.linesDecorationsClassName === other.linesDecorationsClassName
......
......@@ -157,6 +157,7 @@ class ModelMarkerHandler {
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className,
hoverMessage,
showIfCollapsed: true,
overviewRuler: {
color,
darkColor,
......
......@@ -154,6 +154,7 @@ export class FindDecorations implements IDisposable {
return {
stickiness: editorCommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
className: isCurrent ? 'currentFindMatch' : 'findMatch',
showIfCollapsed: true,
overviewRuler: {
color: 'rgba(246, 185, 77, 0.7)',
darkColor: 'rgba(246, 185, 77, 0.7)',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册