';
+ let common = '
';
let output: string[] = [];
for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.css b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.css
index c0a5f0d205a..452d83eeb8b 100644
--- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.css
+++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.css
@@ -14,4 +14,5 @@
*/
.monaco-editor .margin-view-overlays .cldr {
position: absolute;
+ height: 100%;
}
\ No newline at end of file
diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts
index 1308f188f6d..3517c9f31b4 100644
--- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts
+++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts
@@ -14,7 +14,6 @@ import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
export class LinesDecorationsOverlay extends DedupOverlay {
private _context: ViewContext;
- private _lineHeight: number;
private _decorationsLeft: number;
private _decorationsWidth: number;
@@ -23,7 +22,6 @@ export class LinesDecorationsOverlay extends DedupOverlay {
constructor(context: ViewContext) {
super();
this._context = context;
- this._lineHeight = this._context.configuration.editor.lineHeight;
this._decorationsLeft = 0;
this._decorationsWidth = 0;
this._renderResult = null;
@@ -63,9 +61,6 @@ export class LinesDecorationsOverlay extends DedupOverlay {
return false;
}
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
- if (e.lineHeight) {
- this._lineHeight = this._context.configuration.editor.lineHeight;
- }
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
@@ -95,18 +90,13 @@ export class LinesDecorationsOverlay extends DedupOverlay {
}
public prepareRender(ctx: IRenderingContext): void {
- if (!this.shouldRender()) {
- throw new Error('I did not ask to render!');
- }
-
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
let toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
- let lineHeight = this._lineHeight.toString();
let left = this._decorationsLeft.toString();
let width = this._decorationsWidth.toString();
- let common = '" style="left:' + left + 'px;width:' + width + 'px' + ';height:' + lineHeight + 'px;">
';
+ let common = '" style="left:' + left + 'px;width:' + width + 'px;">
';
let output: string[] = [];
for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
@@ -126,10 +116,6 @@ export class LinesDecorationsOverlay extends DedupOverlay {
if (!this._renderResult) {
return '';
}
- let lineIndex = lineNumber - startLineNumber;
- if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
- throw new Error('Unexpected render request');
- }
- return this._renderResult[lineIndex];
+ return this._renderResult[lineNumber - startLineNumber];
}
}
\ No newline at end of file
diff --git a/src/vs/editor/browser/viewParts/margin/margin.ts b/src/vs/editor/browser/viewParts/margin/margin.ts
new file mode 100644
index 00000000000..3ff433c51a0
--- /dev/null
+++ b/src/vs/editor/browser/viewParts/margin/margin.ts
@@ -0,0 +1,100 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+'use strict';
+
+import { StyleMutator, FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator';
+import * as editorCommon from 'vs/editor/common/editorCommon';
+import { ClassNames } from 'vs/editor/browser/editorBrowser';
+import { ViewPart } from 'vs/editor/browser/view/viewPart';
+import { ViewContext } from 'vs/editor/common/view/viewContext';
+import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
+import { ILayoutProvider } from 'vs/editor/browser/viewLayout/layoutProvider';
+
+export class Margin extends ViewPart {
+ public domNode: HTMLElement;
+ private _layoutProvider: ILayoutProvider;
+ private _canUseTranslate3d: boolean;
+ private _contentLeft: number;
+ private _glyphMarginLeft: number;
+ private _glyphMarginWidth: number;
+ private _glyphMarginBackgroundDomNode: FastDomNode;
+
+ constructor(context: ViewContext, layoutProvider: ILayoutProvider) {
+ super(context);
+ this._layoutProvider = layoutProvider;
+ this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
+ this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
+ this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
+ this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
+
+ this.domNode = this._createDomNode();
+ }
+
+ public dispose(): void {
+ super.dispose();
+ }
+
+ public _createDomNode(): HTMLElement {
+ let domNode = document.createElement('div');
+ domNode.className = ClassNames.MARGIN + ' monaco-editor-background';
+ domNode.style.position = 'absolute';
+ domNode.setAttribute('role', 'presentation');
+ domNode.setAttribute('aria-hidden', 'true');
+
+ this._glyphMarginBackgroundDomNode = createFastDomNode(document.createElement('div'));
+ this._glyphMarginBackgroundDomNode.setClassName(ClassNames.GLYPH_MARGIN);
+
+ domNode.appendChild(this._glyphMarginBackgroundDomNode.domNode);
+ return domNode;
+ }
+
+ // --- begin event handlers
+
+ public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
+ if (e.viewInfo.canUseTranslate3d) {
+ this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
+ }
+
+ return super.onConfigurationChanged(e);
+ }
+
+ public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
+ return super.onScrollChanged(e) || e.scrollTopChanged;
+ }
+
+ public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
+ this._contentLeft = layoutInfo.contentLeft;
+ this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
+ this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
+
+ return super.onLayoutChanged(layoutInfo) || true;
+ }
+
+ // --- end event handlers
+
+ public prepareRender(ctx: IRenderingContext): void {
+ // Nothing to read
+ }
+
+ public render(ctx: IRestrictedRenderingContext): void {
+ if (this._canUseTranslate3d) {
+ let transform = 'translate3d(0px, ' + ctx.linesViewportData.visibleRangesDeltaTop + 'px, 0px)';
+ StyleMutator.setTransform(this.domNode, transform);
+ StyleMutator.setTop(this.domNode, 0);
+ } else {
+ StyleMutator.setTransform(this.domNode, '');
+ StyleMutator.setTop(this.domNode, ctx.linesViewportData.visibleRangesDeltaTop);
+ }
+
+ let height = Math.min(this._layoutProvider.getTotalHeight(), 1000000);
+ StyleMutator.setHeight(this.domNode, height);
+ StyleMutator.setWidth(this.domNode, this._contentLeft);
+
+ this._glyphMarginBackgroundDomNode.setLeft(this._glyphMarginLeft);
+ this._glyphMarginBackgroundDomNode.setWidth(this._glyphMarginWidth);
+ this._glyphMarginBackgroundDomNode.setHeight(height);
+ }
+}
diff --git a/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.css b/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.css
new file mode 100644
index 00000000000..7bd8f89ab0e
--- /dev/null
+++ b/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.css
@@ -0,0 +1,15 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+/*
+ Keeping name short for faster parsing.
+ cmdr = core margin decorations rendering (div)
+*/
+.monaco-editor .margin-view-overlays .cmdr {
+ position: absolute;
+ left: 0;
+ width: 100%;
+ height: 100%;
+}
\ No newline at end of file
diff --git a/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.ts b/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.ts
new file mode 100644
index 00000000000..6ea01669a60
--- /dev/null
+++ b/src/vs/editor/browser/viewParts/marginDecorations/marginDecorations.ts
@@ -0,0 +1,109 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
+
+'use strict';
+
+import 'vs/css!./marginDecorations';
+import * as editorCommon from 'vs/editor/common/editorCommon';
+import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/glyphMargin/glyphMargin';
+import { ViewContext } from 'vs/editor/common/view/viewContext';
+import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
+
+export class MarginViewLineDecorationsOverlay extends DedupOverlay {
+ private _context: ViewContext;
+ private _renderResult: string[];
+
+ constructor(context: ViewContext) {
+ super();
+ this._context = context;
+ this._renderResult = null;
+ this._context.addEventHandler(this);
+ }
+
+ public dispose(): void {
+ this._context.removeEventHandler(this);
+ this._context = null;
+ this._renderResult = null;
+ }
+
+ // --- begin event handlers
+
+ public onModelFlushed(): boolean {
+ return true;
+ }
+ public onModelDecorationsChanged(e: editorCommon.IViewDecorationsChangedEvent): boolean {
+ return true;
+ }
+ public onModelLinesDeleted(e: editorCommon.IViewLinesDeletedEvent): boolean {
+ return true;
+ }
+ public onModelLineChanged(e: editorCommon.IViewLineChangedEvent): boolean {
+ return true;
+ }
+ public onModelLinesInserted(e: editorCommon.IViewLinesInsertedEvent): boolean {
+ return true;
+ }
+ public onCursorPositionChanged(e: editorCommon.IViewCursorPositionChangedEvent): boolean {
+ return false;
+ }
+ public onCursorSelectionChanged(e: editorCommon.IViewCursorSelectionChangedEvent): boolean {
+ return false;
+ }
+ public onCursorRevealRange(e: editorCommon.IViewRevealRangeEvent): boolean {
+ return false;
+ }
+ public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
+ return true;
+ }
+ public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
+ return true;
+ }
+ public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
+ return e.scrollTopChanged;
+ }
+ public onZonesChanged(): boolean {
+ return true;
+ }
+
+ // --- end event handlers
+
+ protected _getDecorations(ctx: IRenderingContext): DecorationToRender[] {
+ let decorations = ctx.getDecorationsInViewport();
+ let r: DecorationToRender[] = [];
+ for (let i = 0, len = decorations.length; i < len; i++) {
+ let d = decorations[i];
+ if (d.options.marginClassName) {
+ r.push(new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, d.options.marginClassName));
+ }
+ }
+ return r;
+ }
+
+ public prepareRender(ctx: IRenderingContext): void {
+ let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
+ let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
+ let toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
+
+ let output: string[] = [];
+ for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
+ let lineIndex = lineNumber - visibleStartLineNumber;
+ let classNames = toRender[lineIndex];
+ let lineOutput = '';
+ for (let i = 0, len = classNames.length; i < len; i++) {
+ lineOutput += '