Skip to content

Commit 9707a16

Browse files
authored
Add option for disabling overflowing widgets in the editor (microsoft#256123)
1 parent f1c597b commit 9707a16

File tree

5 files changed

+360
-335
lines changed

5 files changed

+360
-335
lines changed

src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,15 @@ class Widget {
215215
this._viewDomNode = viewDomNode;
216216
this._actual = actual;
217217

218+
const options = this._context.configuration.options;
219+
const layoutInfo = options.get(EditorOption.layoutInfo);
220+
const allowOverflow = options.get(EditorOption.allowOverflow);
221+
218222
this.domNode = createFastDomNode(this._actual.getDomNode());
219223
this.id = this._actual.getId();
220-
this.allowEditorOverflow = this._actual.allowEditorOverflow || false;
224+
this.allowEditorOverflow = (this._actual.allowEditorOverflow || false) && allowOverflow;
221225
this.suppressMouseDown = this._actual.suppressMouseDown || false;
222226

223-
const options = this._context.configuration.options;
224-
const layoutInfo = options.get(EditorOption.layoutInfo);
225-
226227
this._fixedOverflowWidgets = options.get(EditorOption.fixedOverflowWidgets);
227228
this._contentWidth = layoutInfo.contentWidth;
228229
this._contentLeft = layoutInfo.contentLeft;

src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ export class ViewOverlayWidgets extends ViewPart {
9292

9393
// ---- end view event handlers
9494

95+
private _widgetCanOverflow(widget: IOverlayWidget): boolean {
96+
const options = this._context.configuration.options;
97+
const allowOverflow = options.get(EditorOption.allowOverflow);
98+
return (widget.allowEditorOverflow || false) && allowOverflow;
99+
}
100+
95101
public addWidget(widget: IOverlayWidget): void {
96102
const domNode = createFastDomNode(widget.getDomNode());
97103

@@ -105,7 +111,7 @@ export class ViewOverlayWidgets extends ViewPart {
105111
domNode.setPosition('absolute');
106112
domNode.setAttribute('widgetId', widget.getId());
107113

108-
if (widget.allowEditorOverflow) {
114+
if (this._widgetCanOverflow(widget)) {
109115
this.overflowingOverlayWidgetsDomNode.appendChild(domNode);
110116
} else {
111117
this._domNode.appendChild(domNode);
@@ -193,7 +199,7 @@ export class ViewOverlayWidgets extends ViewPart {
193199
} else {
194200
const { top, left } = widgetData.preference;
195201
const fixedOverflowWidgets = this._context.configuration.options.get(EditorOption.fixedOverflowWidgets);
196-
if (fixedOverflowWidgets && widgetData.widget.allowEditorOverflow) {
202+
if (fixedOverflowWidgets && this._widgetCanOverflow(widgetData.widget)) {
197203
// top, left are computed relative to the editor and we need them relative to the page
198204
const editorBoundingBox = this._viewDomNodeRect;
199205
domNode.setTop(top + editorBoundingBox.top);

src/vs/editor/common/config/editorOptions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ export interface IEditorOptions {
219219
* Defaults to `false`.
220220
*/
221221
fixedOverflowWidgets?: boolean;
222+
/**
223+
* Allow content widgets and overflow widgets to overflow the editor viewport.
224+
* Defaults to `true`.
225+
*/
226+
allowOverflow?: boolean;
222227
/**
223228
* The number of vertical lanes the overview ruler should render.
224229
* Defaults to 3.
@@ -5577,6 +5582,7 @@ export const enum EditorOption {
55775582
acceptSuggestionOnEnter,
55785583
accessibilitySupport,
55795584
accessibilityPageSize,
5585+
allowOverflow,
55805586
allowVariableLineHeights,
55815587
allowVariableFonts,
55825588
allowVariableFontsInAccessibilityMode,
@@ -5767,7 +5773,11 @@ export const EditorOptions = {
57675773
{
57685774
description: nls.localize('accessibilityPageSize', "Controls the number of lines in the editor that can be read out by a screen reader at once. When we detect a screen reader we automatically set the default to be 500. Warning: this has a performance implication for numbers larger than the default."),
57695775
tags: ['accessibility']
5770-
})),
5776+
}
5777+
)),
5778+
allowOverflow: register(new EditorBooleanOption(
5779+
EditorOption.allowOverflow, 'allowOverflow', true,
5780+
)),
57715781
allowVariableLineHeights: register(new EditorBooleanOption(
57725782
EditorOption.allowVariableLineHeights, 'allowVariableLineHeights', true,
57735783
{

0 commit comments

Comments
 (0)