Skip to content

Commit 42d10d8

Browse files
authored
Merge pull request microsoft#101999 from microsoft/joao/editor-overflow-widgets-container
Editor option: overflowWidgetsDomNode
2 parents 622aa93 + e3f908a commit 42d10d8

9 files changed

Lines changed: 51 additions & 28 deletions

File tree

src/vs/editor/browser/config/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import * as platform from 'vs/base/common/platform';
1111
import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader';
1212
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
1313
import { CommonEditorConfiguration, IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig';
14-
import { EditorOption, IEditorConstructionOptions, EditorFontLigatures } from 'vs/editor/common/config/editorOptions';
14+
import { EditorOption, EditorFontLigatures } from 'vs/editor/common/config/editorOptions';
1515
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
1616
import { IDimension } from 'vs/editor/common/editorCommon';
1717
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
18+
import { IEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
1819

1920
class CSSBasedConfigurationCache {
2021

src/vs/editor/browser/editorBrowser.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,18 @@ export interface IEditorAriaOptions {
336336
role?: string;
337337
}
338338

339+
export interface IEditorConstructionOptions extends IEditorOptions {
340+
/**
341+
* The initial editor dimension (to avoid measuring the container).
342+
*/
343+
dimension?: editorCommon.IDimension;
344+
/**
345+
* Place overflow widgets inside an external DOM node.
346+
* Defaults to an internal DOM node.
347+
*/
348+
overflowWidgetsDomNode?: HTMLElement;
349+
}
350+
339351
/**
340352
* A rich code editor.
341353
*/

src/vs/editor/browser/view/viewImpl.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export class View extends ViewEventHandler {
9393
configuration: IConfiguration,
9494
themeService: IThemeService,
9595
model: IViewModel,
96-
userInputEvents: ViewUserInputEvents
96+
userInputEvents: ViewUserInputEvents,
97+
overflowWidgetsDomNode: HTMLElement | undefined
9798
) {
9899
super();
99100
this._selections = [new Selection(1, 1, 1, 1)];
@@ -209,7 +210,12 @@ export class View extends ViewEventHandler {
209210
this._overflowGuardContainer.appendChild(this._overlayWidgets.getDomNode());
210211
this._overflowGuardContainer.appendChild(minimap.getDomNode());
211212
this.domNode.appendChild(this._overflowGuardContainer);
212-
this.domNode.appendChild(this._contentWidgets.overflowingContentWidgetsDomNode);
213+
214+
if (overflowWidgetsDomNode) {
215+
overflowWidgetsDomNode.appendChild(this._contentWidgets.overflowingContentWidgetsDomNode.domNode);
216+
} else {
217+
this.domNode.appendChild(this._contentWidgets.overflowingContentWidgetsDomNode);
218+
}
213219

214220
this._applyLayout();
215221

@@ -317,6 +323,8 @@ export class View extends ViewEventHandler {
317323
this._renderAnimationFrame = null;
318324
}
319325

326+
this._contentWidgets.overflowingContentWidgetsDomNode.domNode.remove();
327+
320328
this._context.removeEventHandler(this);
321329

322330
this._viewLines.dispose();

src/vs/editor/browser/widget/codeEditorWidget.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
2121
import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
2222
import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl';
2323
import { ViewUserInputEvents } from 'vs/editor/browser/view/viewUserInputEvents';
24-
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, IEditorConstructionOptions, filterValidationDecorations } from 'vs/editor/common/config/editorOptions';
24+
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, filterValidationDecorations } from 'vs/editor/common/config/editorOptions';
2525
import { Cursor } from 'vs/editor/common/controller/cursor';
2626
import { CursorColumns } from 'vs/editor/common/controller/cursorCommon';
2727
import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
@@ -208,6 +208,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
208208
private readonly _telemetryData?: object;
209209

210210
private readonly _domElement: HTMLElement;
211+
private readonly _overflowWidgetsDomNode: HTMLElement | undefined;
211212
private readonly _id: number;
212213
private readonly _configuration: editorCommon.IConfiguration;
213214

@@ -237,7 +238,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
237238

238239
constructor(
239240
domElement: HTMLElement,
240-
options: IEditorConstructionOptions,
241+
options: editorBrowser.IEditorConstructionOptions,
241242
codeEditorWidgetOptions: ICodeEditorWidgetOptions,
242243
@IInstantiationService instantiationService: IInstantiationService,
243244
@ICodeEditorService codeEditorService: ICodeEditorService,
@@ -248,14 +249,17 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
248249
@IAccessibilityService accessibilityService: IAccessibilityService
249250
) {
250251
super();
252+
253+
options = options || {};
254+
251255
this._domElement = domElement;
256+
this._overflowWidgetsDomNode = options.overflowWidgetsDomNode;
252257
this._id = (++EDITOR_ID);
253258
this._decorationTypeKeysToIds = {};
254259
this._decorationTypeSubtypes = {};
255260
this.isSimpleWidget = codeEditorWidgetOptions.isSimpleWidget || false;
256261
this._telemetryData = codeEditorWidgetOptions.telemetryData;
257262

258-
options = options || {};
259263
this._configuration = this._register(this._createConfiguration(options, accessibilityService));
260264
this._register(this._configuration.onDidChange((e) => {
261265
this._onDidChangeConfiguration.fire(e);
@@ -324,7 +328,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
324328
this._codeEditorService.addCodeEditor(this);
325329
}
326330

327-
protected _createConfiguration(options: IEditorConstructionOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
331+
protected _createConfiguration(options: editorBrowser.IEditorConstructionOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
328332
return new Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService);
329333
}
330334

@@ -1613,7 +1617,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
16131617
this._configuration,
16141618
this._themeService,
16151619
viewModel,
1616-
viewUserInputEvents
1620+
viewUserInputEvents,
1621+
this._overflowWidgetsDomNode
16171622
);
16181623

16191624
return [view, true];

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Constants } from 'vs/base/common/uint';
1111
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
1212
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
1313
import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
14-
import { IDimension } from 'vs/editor/common/editorCommon';
1514
import { IJSONSchema } from 'vs/base/common/jsonSchema';
1615

1716
//#region typed options
@@ -600,13 +599,6 @@ export interface IEditorOptions {
600599
showDeprecated?: boolean;
601600
}
602601

603-
export interface IEditorConstructionOptions extends IEditorOptions {
604-
/**
605-
* The initial editor dimension (to avoid measuring the container).
606-
*/
607-
dimension?: IDimension;
608-
}
609-
610602
/**
611603
* @internal
612604
* The width of the minimap gutter, in pixels.

src/vs/editor/standalone/browser/standaloneCodeEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import * as aria from 'vs/base/browser/ui/aria/aria';
77
import { Disposable, IDisposable, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
8-
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
8+
import { ICodeEditor, IDiffEditor, IEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
99
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1010
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
1111
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
12-
import { IDiffEditorOptions, IEditorOptions, IEditorConstructionOptions } from 'vs/editor/common/config/editorOptions';
12+
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
1313
import { InternalEditorAction } from 'vs/editor/common/editorAction';
1414
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
1515
import { ITextModel } from 'vs/editor/common/model';

src/vs/editor/test/browser/testCodeEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { ICodeEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
6+
import { ICodeEditor, IActiveCodeEditor, IEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
77
import { IEditorContributionCtor } from 'vs/editor/browser/editorExtensions';
88
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
99
import { View } from 'vs/editor/browser/view/viewImpl';
@@ -34,7 +34,7 @@ export interface ITestCodeEditor extends IActiveCodeEditor {
3434
class TestCodeEditor extends CodeEditorWidget implements ICodeEditor {
3535

3636
//#region testing overrides
37-
protected _createConfiguration(options: editorOptions.IEditorConstructionOptions): IConfiguration {
37+
protected _createConfiguration(options: IEditorConstructionOptions): IConfiguration {
3838
return new TestConfiguration(options);
3939
}
4040
protected _createView(viewModel: ViewModel): [View, boolean] {

src/vs/monaco.d.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,13 +3138,6 @@ declare namespace monaco.editor {
31383138
showDeprecated?: boolean;
31393139
}
31403140

3141-
export interface IEditorConstructionOptions extends IEditorOptions {
3142-
/**
3143-
* The initial editor dimension (to avoid measuring the container).
3144-
*/
3145-
dimension?: IDimension;
3146-
}
3147-
31483141
/**
31493142
* Configuration options for the diff editor.
31503143
*/
@@ -4405,6 +4398,18 @@ declare namespace monaco.editor {
44054398
readonly mode: string | null;
44064399
}
44074400

4401+
export interface IEditorConstructionOptions extends IEditorOptions {
4402+
/**
4403+
* The initial editor dimension (to avoid measuring the container).
4404+
*/
4405+
dimension?: IDimension;
4406+
/**
4407+
* Place overflow widgets inside an external DOM node.
4408+
* Defaults to an internal DOM node.
4409+
*/
4410+
overflowWidgetsDomNode?: HTMLElement;
4411+
}
4412+
44084413
/**
44094414
* A rich code editor.
44104415
*/

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { toResource, SideBySideEditor } from 'vs/workbench/common/editor';
5050
import { SIDE_BAR_BACKGROUND, SIDE_BAR_BORDER, PANEL_BACKGROUND, PANEL_INPUT_BORDER } from 'vs/workbench/common/theme';
5151
import { CodeEditorWidget, ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditorWidget';
5252
import { ITextModel } from 'vs/editor/common/model';
53-
import { IEditorConstructionOptions } from 'vs/editor/common/config/editorOptions';
53+
import { IEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
5454
import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
5555
import { IModelService } from 'vs/editor/common/services/modelService';
5656
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';

0 commit comments

Comments
 (0)