Skip to content

Commit 0512050

Browse files
committed
Migrate more editor options
1 parent 844c90a commit 0512050

49 files changed

Lines changed: 751 additions & 964 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 2 additions & 2 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 } from 'vs/editor/common/config/editorOptions';
14+
import { IEditorOptions, EditorOption } 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';
@@ -320,7 +320,7 @@ export class Configuration extends CommonEditorConfiguration {
320320

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

323-
if (this._validatedOptions.automaticLayout) {
323+
if (this._validatedOptions2.get(EditorOption.automaticLayout)) {
324324
this._elementSizeObserver.startObserving();
325325
}
326326

src/vs/editor/browser/controller/mouseHandler.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class MouseHandler extends ViewEventHandler {
113113
const onMouseWheel = (browserEvent: IMouseWheelEvent) => {
114114
this.viewController.emitMouseWheel(browserEvent);
115115

116-
if (!this._context.configuration.editor.viewInfo.mouseWheelZoom) {
116+
if (!this._context.configuration.options.get(EditorOption.mouseWheelZoom)) {
117117
return;
118118
}
119119
const e = new StandardWheelEvent(browserEvent);
@@ -354,10 +354,9 @@ class MouseDownOperation extends Disposable {
354354
e.detail = this._mouseState.count;
355355

356356
const options = this._context.configuration.options;
357-
const readOnly = options.get(EditorOption.readOnly);
358357

359-
if (!readOnly
360-
&& this._context.configuration.editor.dragAndDrop
358+
if (!options.get(EditorOption.readOnly)
359+
&& options.get(EditorOption.dragAndDrop)
361360
&& !this._mouseState.altKey // we don't support multiple mouse
362361
&& e.detail < 2 // only single click on a selection can work
363362
&& !this._isActive // the mouse is not down yet

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ export class TextAreaHandler extends ViewPart {
9191

9292
private readonly _viewController: ViewController;
9393
private readonly _viewHelper: ITextAreaHandlerHelper;
94+
private _scrollLeft: number;
95+
private _scrollTop: number;
96+
9497
private _accessibilitySupport: AccessibilitySupport;
9598
private _contentLeft: number;
9699
private _contentWidth: number;
97100
private _contentHeight: number;
98-
private _scrollLeft: number;
99-
private _scrollTop: number;
100101
private _fontInfo: BareFontInfo;
101102
private _lineHeight: number;
102103
private _emptySelectionClipboard: boolean;
@@ -117,6 +118,8 @@ export class TextAreaHandler extends ViewPart {
117118

118119
this._viewController = viewController;
119120
this._viewHelper = viewHelper;
121+
this._scrollLeft = 0;
122+
this._scrollTop = 0;
120123

121124
const conf = this._context.configuration.editor;
122125
const options = this._context.configuration.options;
@@ -126,12 +129,10 @@ export class TextAreaHandler extends ViewPart {
126129
this._contentLeft = layoutInfo.contentLeft;
127130
this._contentWidth = layoutInfo.contentWidth;
128131
this._contentHeight = layoutInfo.contentHeight;
129-
this._scrollLeft = 0;
130-
this._scrollTop = 0;
131132
this._fontInfo = conf.fontInfo;
132133
this._lineHeight = conf.lineHeight;
133-
this._emptySelectionClipboard = conf.emptySelectionClipboard;
134-
this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting;
134+
this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
135+
this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
135136

136137
this._visibleTextArea = null;
137138
this._selections = [new Selection(1, 1, 1, 1)];
@@ -342,7 +343,7 @@ export class TextAreaHandler extends ViewPart {
342343

343344
private _getWordBeforePosition(position: Position): string {
344345
const lineContent = this._context.model.getLineContent(position.lineNumber);
345-
const wordSeparators = getMapForWordSeparators(this._context.configuration.editor.wordSeparators);
346+
const wordSeparators = getMapForWordSeparators(this._context.configuration.options.get(EditorOption.wordSeparators));
346347

347348
let column = position.column;
348349
let distance = 0;
@@ -374,32 +375,21 @@ export class TextAreaHandler extends ViewPart {
374375
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
375376
const conf = this._context.configuration.editor;
376377
const options = this._context.configuration.options;
378+
const layoutInfo = options.get(EditorOption.layoutInfo);
379+
380+
this._accessibilitySupport = options.get(EditorOption.accessibilitySupport);
381+
this._contentLeft = layoutInfo.contentLeft;
382+
this._contentWidth = layoutInfo.contentWidth;
383+
this._contentHeight = layoutInfo.contentHeight;
384+
this._fontInfo = conf.fontInfo;
385+
this._lineHeight = conf.lineHeight;
386+
this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
387+
this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
388+
this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel));
377389

378-
if (e.fontInfo) {
379-
this._fontInfo = conf.fontInfo;
380-
}
381-
if (e.viewInfo) {
382-
this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel));
383-
}
384-
if (e.hasChanged(EditorOption.layoutInfo)) {
385-
const layoutInfo = options.get(EditorOption.layoutInfo);
386-
this._contentLeft = layoutInfo.contentLeft;
387-
this._contentWidth = layoutInfo.contentWidth;
388-
this._contentHeight = layoutInfo.contentHeight;
389-
}
390-
if (e.lineHeight) {
391-
this._lineHeight = conf.lineHeight;
392-
}
393390
if (e.hasChanged(EditorOption.accessibilitySupport)) {
394-
this._accessibilitySupport = options.get(EditorOption.accessibilitySupport);
395391
this._textAreaInput.writeScreenReaderContent('strategy changed');
396392
}
397-
if (e.emptySelectionClipboard) {
398-
this._emptySelectionClipboard = conf.emptySelectionClipboard;
399-
}
400-
if (e.copyWithSyntaxHighlighting) {
401-
this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting;
402-
}
403393

404394
return true;
405395
}
@@ -550,11 +540,10 @@ export class TextAreaHandler extends ViewPart {
550540

551541
const options = this._context.configuration.options;
552542

553-
if (this._context.configuration.editor.viewInfo.glyphMargin) {
543+
if (options.get(EditorOption.glyphMargin)) {
554544
tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME);
555545
} else {
556-
const renderLineNumbers = options.get(EditorOption.renderLineNumbers);
557-
if (renderLineNumbers.renderType !== RenderLineNumbersType.Off) {
546+
if (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off) {
558547
tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME);
559548
} else {
560549
tac.setClassName('monaco-editor-background textAreaCover');

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Selection } from 'vs/editor/common/core/selection';
1212
import { IConfiguration } from 'vs/editor/common/editorCommon';
1313
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
1414
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
15+
import { EditorOption } from 'vs/editor/common/config/editorOptions';
1516

1617
export interface IMouseDispatchData {
1718
position: Position;
@@ -107,7 +108,7 @@ export class ViewController {
107108
}
108109

109110
private _hasMulticursorModifier(data: IMouseDispatchData): boolean {
110-
switch (this.configuration.editor.multiCursorModifier) {
111+
switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
111112
case 'altKey':
112113
return data.altKey;
113114
case 'ctrlKey':
@@ -119,7 +120,7 @@ export class ViewController {
119120
}
120121

121122
private _hasNonMulticursorModifier(data: IMouseDispatchData): boolean {
122-
switch (this.configuration.editor.multiCursorModifier) {
123+
switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
123124
case 'altKey':
124125
return data.ctrlKey || data.metaKey;
125126
case 'ctrlKey':

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class View extends ViewEventHandler {
220220
this.domNode.appendChild(this.overflowGuardContainer);
221221
this.domNode.appendChild(this.contentWidgets.overflowingContentWidgetsDomNode);
222222

223-
this._setLayout();
223+
this._applyLayout();
224224

225225
// Pointer handler
226226
this.pointerHandler = this._register(new PointerHandler(this._context, viewController, this.createPointerHandlerHelper()));
@@ -282,9 +282,10 @@ export class View extends ViewEventHandler {
282282
};
283283
}
284284

285-
private _setLayout(): void {
285+
private _applyLayout(): void {
286286
const options = this._context.configuration.options;
287287
const layoutInfo = options.get(EditorOption.layoutInfo);
288+
288289
this.domNode.setWidth(layoutInfo.width);
289290
this.domNode.setHeight(layoutInfo.height);
290291

@@ -293,23 +294,18 @@ export class View extends ViewEventHandler {
293294

294295
this.linesContent.setWidth(1000000);
295296
this.linesContent.setHeight(1000000);
296-
297297
}
298298

299299
private getEditorClassName() {
300300
const focused = this._textAreaHandler.isFocused() ? ' focused' : '';
301-
return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type) + focused;
301+
return this._context.configuration.options.get(EditorOption.editorClassName) + ' ' + getThemeTypeSelector(this._context.theme.type) + focused;
302302
}
303303

304304
// --- begin event handlers
305305

306306
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
307-
if (e.editorClassName) {
308-
this.domNode.setClassName(this.getEditorClassName());
309-
}
310-
if (e.hasChanged(EditorOption.layoutInfo)) {
311-
this._setLayout();
312-
}
307+
this.domNode.setClassName(this.getEditorClassName());
308+
this._applyLayout();
313309
return false;
314310
}
315311
public onFocusChanged(e: viewEvents.ViewFocusChangedEvent): boolean {

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,10 @@ export class ContentViewOverlays extends ViewOverlays {
227227
// --- begin event handlers
228228

229229
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
230-
if (e.hasChanged(EditorOption.layoutInfo)) {
231-
const options = this._context.configuration.options;
232-
const layoutInfo = options.get(EditorOption.layoutInfo);
233-
this._contentWidth = layoutInfo.contentWidth;
234-
}
235-
return super.onConfigurationChanged(e);
230+
const options = this._context.configuration.options;
231+
const layoutInfo = options.get(EditorOption.layoutInfo);
232+
this._contentWidth = layoutInfo.contentWidth;
233+
return super.onConfigurationChanged(e) || true;
236234
}
237235
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
238236
return super.onScrollChanged(e) || e.scrollWidthChanged;
@@ -265,18 +263,11 @@ export class MarginViewOverlays extends ViewOverlays {
265263
}
266264

267265
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
268-
let shouldRender = false;
269-
if (e.fontInfo) {
270-
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
271-
shouldRender = true;
272-
}
273-
if (e.hasChanged(EditorOption.layoutInfo)) {
274-
const options = this._context.configuration.options;
275-
const layoutInfo = options.get(EditorOption.layoutInfo);
276-
this._contentLeft = layoutInfo.contentLeft;
277-
shouldRender = true;
278-
}
279-
return super.onConfigurationChanged(e) || shouldRender;
266+
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
267+
const options = this._context.configuration.options;
268+
const layoutInfo = options.get(EditorOption.layoutInfo);
269+
this._contentLeft = layoutInfo.contentLeft;
270+
return super.onConfigurationChanged(e) || true;
280271
}
281272

282273
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class Widget {
212212
const options = this._context.configuration.options;
213213
const layoutInfo = options.get(EditorOption.layoutInfo);
214214

215-
this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets;
215+
this._fixedOverflowWidgets = options.get(EditorOption.fixedOverflowWidgets);
216216
this._contentWidth = layoutInfo.contentWidth;
217217
this._contentLeft = layoutInfo.contentLeft;
218218
this._lineHeight = this._context.configuration.editor.lineHeight;

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
1717
private readonly _context: ViewContext;
1818
private _lineHeight: number;
1919
private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
20+
private _contentWidth: number;
2021
private _selectionIsEmpty: boolean;
2122
private _primaryCursorLineNumber: number;
2223
private _scrollWidth: number;
23-
private _contentWidth: number;
2424

2525
constructor(context: ViewContext) {
2626
super();
2727
this._context = context;
28+
2829
const options = this._context.configuration.options;
2930
const layoutInfo = options.get(EditorOption.layoutInfo);
3031

3132
this._lineHeight = this._context.configuration.editor.lineHeight;
32-
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
33+
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
34+
this._contentWidth = layoutInfo.contentWidth;
3335

3436
this._selectionIsEmpty = true;
3537
this._primaryCursorLineNumber = 1;
3638
this._scrollWidth = 0;
3739

38-
this._contentWidth = layoutInfo.contentWidth;
3940

4041
this._context.addEventHandler(this);
4142
}
@@ -48,17 +49,12 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
4849
// --- begin event handlers
4950

5051
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
51-
if (e.lineHeight) {
52-
this._lineHeight = this._context.configuration.editor.lineHeight;
53-
}
54-
if (e.viewInfo) {
55-
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
56-
}
57-
if (e.hasChanged(EditorOption.layoutInfo)) {
58-
const options = this._context.configuration.options;
59-
const layoutInfo = options.get(EditorOption.layoutInfo);
60-
this._contentWidth = layoutInfo.contentWidth;
61-
}
52+
const options = this._context.configuration.options;
53+
const layoutInfo = options.get(EditorOption.layoutInfo);
54+
55+
this._lineHeight = this._context.configuration.editor.lineHeight;
56+
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
57+
this._contentWidth = layoutInfo.contentWidth;
6258
return true;
6359
}
6460
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
1717
private readonly _context: ViewContext;
1818
private _lineHeight: number;
1919
private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
20+
private _contentLeft: number;
2021
private _selectionIsEmpty: boolean;
2122
private _primaryCursorLineNumber: number;
22-
private _contentLeft: number;
2323

2424
constructor(context: ViewContext) {
2525
super();
2626
this._context = context;
27+
2728
const options = this._context.configuration.options;
2829
const layoutInfo = options.get(EditorOption.layoutInfo);
30+
2931
this._lineHeight = this._context.configuration.editor.lineHeight;
30-
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
32+
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
33+
this._contentLeft = layoutInfo.contentLeft;
3134

3235
this._selectionIsEmpty = true;
3336
this._primaryCursorLineNumber = 1;
34-
this._contentLeft = layoutInfo.contentLeft;
3537

3638
this._context.addEventHandler(this);
3739
}
@@ -44,17 +46,12 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
4446
// --- begin event handlers
4547

4648
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
47-
if (e.lineHeight) {
48-
this._lineHeight = this._context.configuration.editor.lineHeight;
49-
}
50-
if (e.viewInfo) {
51-
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
52-
}
53-
if (e.hasChanged(EditorOption.layoutInfo)) {
54-
const options = this._context.configuration.options;
55-
const layoutInfo = options.get(EditorOption.layoutInfo);
56-
this._contentLeft = layoutInfo.contentLeft;
57-
}
49+
const options = this._context.configuration.options;
50+
const layoutInfo = options.get(EditorOption.layoutInfo);
51+
52+
this._lineHeight = this._context.configuration.editor.lineHeight;
53+
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
54+
this._contentLeft = layoutInfo.contentLeft;
5855
return true;
5956
}
6057
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {

0 commit comments

Comments
 (0)