Skip to content

Commit 29f0d10

Browse files
committed
1 parent 50701ee commit 29f0d10

11 files changed

Lines changed: 40 additions & 21 deletions

File tree

build/monaco/monaco.d.ts.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare namespace monaco.editor {
4848
#include(vs/editor/standalone/common/standaloneThemeService): BuiltinTheme, IStandaloneThemeData, IColors
4949
#include(vs/editor/common/modes/supports/tokenization): ITokenThemeRule
5050
#include(vs/editor/common/services/webWorker): MonacoWebWorker, IWebWorkerOptions
51-
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
51+
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IStandaloneEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
5252
export interface ICommandHandler {
5353
(...args: any[]): void;
5454
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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 { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';
14+
import { EditorOption, IEditorConstructionOptions } 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 } from 'vs/platform/accessibility/common/accessibility';
@@ -310,13 +310,13 @@ export class Configuration extends CommonEditorConfiguration {
310310

311311
constructor(
312312
isSimpleWidget: boolean,
313-
options: IEditorOptions,
313+
options: IEditorConstructionOptions,
314314
referenceDomElement: HTMLElement | null = null,
315315
private readonly accessibilityService: IAccessibilityService
316316
) {
317317
super(isSimpleWidget, options);
318318

319-
this._elementSizeObserver = this._register(new ElementSizeObserver(referenceDomElement, () => this._onReferenceDomElementSizeChanged()));
319+
this._elementSizeObserver = this._register(new ElementSizeObserver(referenceDomElement, options.dimension, () => this._onReferenceDomElementSizeChanged()));
320320

321321
this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => this._onCSSBasedConfigurationChanged()));
322322

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ export class ElementSizeObserver extends Disposable {
1414
private width: number;
1515
private height: number;
1616

17-
constructor(referenceDomElement: HTMLElement | null, changeCallback: () => void) {
17+
constructor(referenceDomElement: HTMLElement | null, dimension: IDimension | undefined, changeCallback: () => void) {
1818
super();
1919
this.referenceDomElement = referenceDomElement;
2020
this.changeCallback = changeCallback;
2121
this.measureReferenceDomElementToken = -1;
2222
this.width = -1;
2323
this.height = -1;
24-
this.measureReferenceDomElement(false);
24+
this.measureReferenceDomElement(false, dimension);
2525
}
2626

2727
public dispose(): void {
@@ -75,4 +75,4 @@ export class ElementSizeObserver extends Disposable {
7575
}
7676
}
7777

78-
}
78+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
2323
import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
2424
import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl';
2525
import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents';
26-
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions';
26+
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById, IEditorConstructionOptions } from 'vs/editor/common/config/editorOptions';
2727
import { Cursor, CursorStateChangedEvent } from 'vs/editor/common/controller/cursor';
2828
import { CursorColumns, ICursors } from 'vs/editor/common/controller/cursorCommon';
2929
import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
@@ -236,7 +236,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
236236

237237
constructor(
238238
domElement: HTMLElement,
239-
options: IEditorOptions,
239+
options: IEditorConstructionOptions,
240240
codeEditorWidgetOptions: ICodeEditorWidgetOptions,
241241
@IInstantiationService instantiationService: IInstantiationService,
242242
@ICodeEditorService codeEditorService: ICodeEditorService,
@@ -329,7 +329,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
329329
this._codeEditorService.addCodeEditor(this);
330330
}
331331

332-
protected _createConfiguration(options: IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
332+
protected _createConfiguration(options: IEditorConstructionOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
333333
return new Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService);
334334
}
335335

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
1212
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
1313
import { isObject } from 'vs/base/common/types';
1414
import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
15+
import { IDimension } from 'vs/editor/common/editorCommon';
1516

1617
//#region typed options
1718

@@ -516,6 +517,13 @@ export interface IEditorOptions {
516517
showUnused?: boolean;
517518
}
518519

520+
export interface IEditorConstructionOptions extends IEditorOptions {
521+
/**
522+
* The initial editor dimension (to avoid measuring the container).
523+
*/
524+
dimension?: IDimension;
525+
}
526+
519527
/**
520528
* Configuration options for the diff editor.
521529
*/

src/vs/editor/common/editorCommon.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ export interface IEditor {
280280
/**
281281
* Instructs the editor to remeasure its container. This method should
282282
* be called when the container of the editor gets resized.
283+
*
284+
* If a dimension is passed in, the passed in value will be used.
283285
*/
284286
layout(dimension?: IDimension): void;
285287

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Selection } from 'vs/editor/common/core/selection';
2121
import { IEditorContribution } from 'vs/editor/common/editorCommon';
2222
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
2323
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode';
24-
import { IEditorConstructionOptions } from 'vs/editor/standalone/browser/standaloneCodeEditor';
24+
import { IStandaloneEditorConstructionOptions } from 'vs/editor/standalone/browser/standaloneCodeEditor';
2525
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
2626
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
2727
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -164,7 +164,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
164164
if (e.equals(KeyMod.CtrlCmd | KeyCode.KEY_H)) {
165165
alert(AccessibilityHelpNLS.openingDocs);
166166

167-
let url = (<IEditorConstructionOptions>this._editor.getRawOptions()).accessibilityHelpUrl;
167+
let url = (<IStandaloneEditorConstructionOptions>this._editor.getRawOptions()).accessibilityHelpUrl;
168168
if (typeof url === 'undefined') {
169169
url = 'https://go.microsoft.com/fwlink/?linkid=852450';
170170
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
1010
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1111
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
1212
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
13-
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
13+
import { IDiffEditorOptions, IEditorOptions, IEditorConstructionOptions } from 'vs/editor/common/config/editorOptions';
1414
import { InternalEditorAction } from 'vs/editor/common/editorAction';
1515
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
1616
import { ITextModel } from 'vs/editor/common/model';
@@ -79,7 +79,7 @@ export interface IActionDescriptor {
7979
/**
8080
* The options to create an editor.
8181
*/
82-
export interface IEditorConstructionOptions extends IEditorOptions {
82+
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions {
8383
/**
8484
* The initial model associated with this code editor.
8585
*/
@@ -158,7 +158,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
158158

159159
constructor(
160160
domElement: HTMLElement,
161-
options: IEditorConstructionOptions,
161+
options: IStandaloneEditorConstructionOptions,
162162
@IInstantiationService instantiationService: IInstantiationService,
163163
@ICodeEditorService codeEditorService: ICodeEditorService,
164164
@ICommandService commandService: ICommandService,
@@ -287,7 +287,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
287287

288288
constructor(
289289
domElement: HTMLElement,
290-
options: IEditorConstructionOptions | undefined,
290+
options: IStandaloneEditorConstructionOptions | undefined,
291291
toDispose: IDisposable,
292292
@IInstantiationService instantiationService: IInstantiationService,
293293
@ICodeEditorService codeEditorService: ICodeEditorService,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { IWebWorkerOptions, MonacoWebWorker, createWebWorker as actualCreateWebW
2424
import * as standaloneEnums from 'vs/editor/common/standalone/standaloneEnums';
2525
import { Colorizer, IColorizerElementOptions, IColorizerOptions } from 'vs/editor/standalone/browser/colorizer';
2626
import { SimpleEditorModelResolverService } from 'vs/editor/standalone/browser/simpleServices';
27-
import { IDiffEditorConstructionOptions, IEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor, StandaloneDiffEditor, StandaloneEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
27+
import { IDiffEditorConstructionOptions, IStandaloneEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor, StandaloneDiffEditor, StandaloneEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
2828
import { DynamicStandaloneServices, IEditorOverrideServices, StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
2929
import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
3030
import { ICommandService } from 'vs/platform/commands/common/commands';
@@ -68,7 +68,7 @@ function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: H
6868
* `domElement` should be empty (not contain other dom nodes).
6969
* The editor will read the size of `domElement`.
7070
*/
71-
export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor {
71+
export function create(domElement: HTMLElement, options?: IStandaloneEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor {
7272
return withAllStandaloneServices(domElement, override || {}, (services) => {
7373
return new StandaloneEditor(
7474
domElement,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService
2929
export class TestCodeEditor extends CodeEditorWidget implements editorBrowser.ICodeEditor {
3030

3131
//#region testing overrides
32-
protected _createConfiguration(options: editorOptions.IEditorOptions): editorCommon.IConfiguration {
32+
protected _createConfiguration(options: editorOptions.IEditorConstructionOptions): editorCommon.IConfiguration {
3333
return new TestConfiguration(options);
3434
}
3535
protected _createView(viewModel: ViewModel, cursor: Cursor): [View, boolean] {

0 commit comments

Comments
 (0)