From 39f6fded66f6401b5cbda928e14bdcdd25c5c7b9 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 25 Oct 2016 10:58:50 +0200 Subject: [PATCH] fixedOverflowWidgets setting related to #13241 --- .../viewParts/contentWidgets/contentWidgets.ts | 18 ++++++++++-------- .../editor/browser/widget/diffEditorWidget.ts | 1 + .../editor/common/config/commonEditorConfig.ts | 1 + src/vs/editor/common/config/defaultConfig.ts | 1 + src/vs/editor/common/editorCommon.ts | 11 +++++++++++ .../browser/referencesWidget.ts | 3 ++- src/vs/monaco.d.ts | 7 +++++++ .../browser/parts/editor/textEditor.ts | 3 ++- .../parts/debug/electron-browser/repl.ts | 3 ++- 9 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index 79c2c7fe106..55c0db61e71 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -154,7 +154,7 @@ export class ViewContentWidgets extends ViewPart { this._widgets[widget.getId()] = widgetData; let domNode = widget.getDomNode(); - domNode.style.position = 'fixed'; + domNode.style.position = this._context.configuration.editor.viewInfo.fixedOverflowWidgets ? 'fixed' : 'absolute'; StyleMutator.setMaxWidth(domNode, this._contentWidth); StyleMutator.setVisibility(domNode, 'hidden'); domNode.setAttribute('widgetId', widget.getId()); @@ -280,19 +280,21 @@ export class ViewContentWidgets extends ViewPart { if (absoluteLeft + width + 20 > INNER_WIDTH) { let delta = absoluteLeft - (INNER_WIDTH - width - 20); absoluteLeft -= delta; + left -= delta; } if (absoluteLeft < 0) { let delta = absoluteLeft; absoluteLeft -= delta; + left -= delta; } - return { - aboveTop: absoluteAboveTop, - fitsAbove: fitsAbove, - belowTop: absoluteBelowTop, - fitsBelow: fitsBelow, - left: absoluteLeft - }; + if (this._context.configuration.editor.viewInfo.fixedOverflowWidgets) { + aboveTop = absoluteAboveTop; + belowTop = absoluteBelowTop; + left = absoluteLeft; + } + + return { aboveTop, fitsAbove, belowTop, fitsBelow, left }; } private _prepareRenderWidgetAtExactPosition(position: Position, ctx: IRenderingContext): IMyWidgetRenderData { diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index 776f914c1fd..5229ebc3ca3 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -849,6 +849,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif clonedOptions.scrollbar.vertical = 'visible'; clonedOptions.folding = false; clonedOptions.codeLens = false; + clonedOptions.fixedOverflowWidgets = true; return clonedOptions; } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index d25e520f940..bd486c11379 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -296,6 +296,7 @@ class InternalEditorOptionsHelper { renderIndentGuides: toBoolean(opts.renderIndentGuides), renderLineHighlight: toBoolean(opts.renderLineHighlight), scrollbar: scrollbar, + fixedOverflowWidgets: toBoolean(opts.fixedOverflowWidgets) }); let contribInfo = new editorCommon.EditorContribOptions({ diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index 9225405950f..d608fddde27 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -56,6 +56,7 @@ class ConfigClass implements IConfiguration { verticalHasArrows: false, horizontalHasArrows: false }, + fixedOverflowWidgets: false, overviewRulerLanes: 2, cursorBlinking: 'blink', mouseWheelZoom: false, diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index f71e3355dbe..0074cbe6e8d 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -256,6 +256,11 @@ export interface IEditorOptions { * Control the behavior and rendering of the scrollbars. */ scrollbar?: IEditorScrollbarOptions; + /** + * Display overflow widgets as `fixed`. + * Defaults to `false`. + */ + fixedOverflowWidgets?: boolean; /** * The number of vertical lanes the overview ruler should render. * Defaults to 2. @@ -665,6 +670,7 @@ export class InternalEditorViewOptions { readonly renderIndentGuides: boolean; readonly renderLineHighlight: boolean; readonly scrollbar: InternalEditorScrollbarOptions; + readonly fixedOverflowWidgets: boolean; /** * @internal @@ -695,6 +701,7 @@ export class InternalEditorViewOptions { renderIndentGuides: boolean; renderLineHighlight: boolean; scrollbar: InternalEditorScrollbarOptions; + fixedOverflowWidgets: boolean; }) { this.theme = String(source.theme); this.canUseTranslate3d = Boolean(source.canUseTranslate3d); @@ -721,6 +728,7 @@ export class InternalEditorViewOptions { this.renderIndentGuides = Boolean(source.renderIndentGuides); this.renderLineHighlight = Boolean(source.renderLineHighlight); this.scrollbar = source.scrollbar.clone(); + this.fixedOverflowWidgets = Boolean(source.fixedOverflowWidgets); } private static _toSortedIntegerArray(source: any): number[] { @@ -781,6 +789,7 @@ export class InternalEditorViewOptions { && this.renderIndentGuides === other.renderIndentGuides && this.renderLineHighlight === other.renderLineHighlight && this.scrollbar.equals(other.scrollbar) + && this.fixedOverflowWidgets === other.fixedOverflowWidgets ); } @@ -814,6 +823,7 @@ export class InternalEditorViewOptions { renderIndentGuides: this.renderIndentGuides !== newOpts.renderIndentGuides, renderLineHighlight: this.renderLineHighlight !== newOpts.renderLineHighlight, scrollbar: (!this.scrollbar.equals(newOpts.scrollbar)), + fixedOverflowWidgets: this.fixedOverflowWidgets !== newOpts.fixedOverflowWidgets }; } @@ -851,6 +861,7 @@ export interface IViewConfigurationChangedEvent { readonly renderIndentGuides: boolean; readonly renderLineHighlight: boolean; readonly scrollbar: boolean; + readonly fixedOverflowWidgets: boolean; } export class EditorContribOptions { diff --git a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts index de1f33ba1c0..f409b0614a2 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts @@ -556,7 +556,8 @@ export class ReferenceWidget extends PeekViewWidget { var options: editorCommon.IEditorOptions = { scrollBeyondLastLine: false, scrollbar: DefaultConfig.editor.scrollbar, - overviewRulerLanes: 2 + overviewRulerLanes: 2, + fixedOverflowWidgets: true }; this._preview = this._instantiationService.createInstance(EmbeddedCodeEditorWidget, div.getHTMLElement(), options, this.editor); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 56fa422e026..0329b1eb5c0 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1118,6 +1118,11 @@ declare module monaco.editor { * Control the behavior and rendering of the scrollbars. */ scrollbar?: IEditorScrollbarOptions; + /** + * Display overflow widgets as `fixed`. + * Defaults to `false`. + */ + fixedOverflowWidgets?: boolean; /** * The number of vertical lanes the overview ruler should render. * Defaults to 2. @@ -1420,6 +1425,7 @@ declare module monaco.editor { readonly renderIndentGuides: boolean; readonly renderLineHighlight: boolean; readonly scrollbar: InternalEditorScrollbarOptions; + readonly fixedOverflowWidgets: boolean; } export interface IViewConfigurationChangedEvent { @@ -1448,6 +1454,7 @@ declare module monaco.editor { readonly renderIndentGuides: boolean; readonly renderLineHighlight: boolean; readonly scrollbar: boolean; + readonly fixedOverflowWidgets: boolean; } export class EditorContribOptions { diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index aeebc684d6f..1c3e842e785 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -119,7 +119,8 @@ export abstract class BaseTextEditor extends BaseEditor { return { overviewRulerLanes: 3, lineNumbersMinChars: 3, - theme: this.themeService.getColorTheme() + theme: this.themeService.getColorTheme(), + fixedOverflowWidgets: true }; } diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index fadd4be2035..1e477563652 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -269,7 +269,8 @@ export class Repl extends Panel implements IPrivateReplService { lineDecorationsWidth: 0, scrollBeyondLastLine: false, theme: this.themeService.getColorTheme(), - renderLineHighlight: false + renderLineHighlight: false, + fixedOverflowWidgets: true }; } -- GitLab