From 7fcc63b43c585f3c08a659f9b6809a63b5e46b84 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Fri, 30 Aug 2019 08:07:53 -0700 Subject: [PATCH 001/204] chore: Bump electron@4.2.10 --- .yarnrc | 2 +- cgmanifest.json | 4 ++-- src/typings/electron.d.ts | 4 ++-- test/smoke/package.json | 2 +- test/smoke/yarn.lock | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.yarnrc b/.yarnrc index 98712ee2b433d..ff946c7a25031 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1,3 +1,3 @@ disturl "https://atom.io/download/electron" -target "4.2.9" +target "4.2.10" runtime "electron" diff --git a/cgmanifest.json b/cgmanifest.json index 5ba2e16626757..d26f37b620406 100644 --- a/cgmanifest.json +++ b/cgmanifest.json @@ -60,12 +60,12 @@ "git": { "name": "electron", "repositoryUrl": "https://github.com/electron/electron", - "commitHash": "3d4d6454007f14fa9a5f0e1fa49206fb91b676cc" + "commitHash": "4e4c7527c63fcf27dffaeb58bde996b8d859c0ed" } }, "isOnlyProductionDependency": true, "license": "MIT", - "version": "4.2.9" + "version": "4.2.10" }, { "component": { diff --git a/src/typings/electron.d.ts b/src/typings/electron.d.ts index cc80376a76512..6f44785756c40 100644 --- a/src/typings/electron.d.ts +++ b/src/typings/electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron 4.2.9 +// Type definitions for Electron 4.2.10 // Project: http://electronjs.org/ // Definitions by: The Electron Team // Definitions: https://github.com/electron/electron-typescript-definitions @@ -9861,4 +9861,4 @@ declare namespace NodeJS { electron: string; chrome: string; } -} \ No newline at end of file +} diff --git a/test/smoke/package.json b/test/smoke/package.json index 185fc07d64f49..99e9ddf08524a 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -23,7 +23,7 @@ "@types/webdriverio": "4.6.1", "concurrently": "^3.5.1", "cpx": "^1.5.0", - "electron": "4.2.9", + "electron": "4.2.10", "htmlparser2": "^3.9.2", "mkdirp": "^0.5.1", "mocha": "^5.2.0", diff --git a/test/smoke/yarn.lock b/test/smoke/yarn.lock index 5219fecf778fe..81f81a3f414e9 100644 --- a/test/smoke/yarn.lock +++ b/test/smoke/yarn.lock @@ -683,10 +683,10 @@ electron-download@^4.1.0: semver "^5.4.1" sumchecker "^2.0.2" -electron@4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/electron/-/electron-4.2.9.tgz#81226aa1ba58e1b05388474faf5a815010a11ea2" - integrity sha512-zC7K3GOiZKmxqllVG/qq/Gx+qQvyolKj5xKKwXMqIGekfokEW2hvoIO5Yh7KCoAh5dqBtpzOJjS4fj1se+YBcg== +electron@4.2.10: + version "4.2.10" + resolved "https://registry.yarnpkg.com/electron/-/electron-4.2.10.tgz#7096450bb14875ec2e6797316c0c1034e7fe2b76" + integrity sha512-dFhsJOW7OZX8JxjoBdugUZh6VWbs5PjlQIH6/w1KsZO7otgBy44j9vPI31KnIid3bdMtNbmTEF+6PA32z88kRw== dependencies: "@types/node" "^10.12.18" electron-download "^4.1.0" From 2a720880c3bf5dd365c153a00a8042c89eea3775 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 30 Aug 2019 17:20:36 +0200 Subject: [PATCH 002/204] Introduce a new way to manage editor options --- .../viewParts/lineNumbers/lineNumbers.ts | 4 +- .../common/config/commonEditorConfig.ts | 82 ++++++++++- src/vs/editor/common/config/editorOptions.ts | 138 +++++++++++++++++- src/vs/editor/common/editorCommon.ts | 1 + .../common/standalone/standaloneEnums.ts | 4 + .../standalone/browser/standaloneEditor.ts | 4 +- src/vs/monaco.d.ts | 29 +++- 7 files changed, 246 insertions(+), 16 deletions(-) diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index 3e9b2d6c68b0f..c80286daf0dc6 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -6,7 +6,7 @@ import 'vs/css!./lineNumbers'; import * as platform from 'vs/base/common/platform'; import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; -import { RenderLineNumbersType } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { editorActiveLineNumber, editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -45,7 +45,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay { this._lineHeight = config.lineHeight; this._renderLineNumbers = config.viewInfo.renderLineNumbers; this._renderCustomLineNumbers = config.viewInfo.renderCustomLineNumbers; - this._renderFinalNewline = config.viewInfo.renderFinalNewline; + this._renderFinalNewline = this._context.configuration.options.get(EditorOptionId.RenderFinalNewline, EditorOption.RenderFinalNewline); this._lineNumbersLeft = config.layoutInfo.lineNumbersLeft; this._lineNumbersWidth = config.layoutInfo.lineNumbersWidth; } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 1fd0db269f430..6ae96a3430c3c 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -63,6 +63,58 @@ export interface IEnvConfiguration { const hasOwnProperty = Object.hasOwnProperty; +export class EditorConfiguration2 { + public static readOptions(options: editorOptions.IEditorOptions): editorOptions.RawEditorOptions { + // console.log(`parseOptions`, options); + const result = new editorOptions.RawEditorOptions(); + for (const editorOption of editorOptions.editorOptionsRegistry) { + result._write(editorOption.id, editorOption.read(options)); + } + return result; + } + + public static mixOptions(a: editorOptions.RawEditorOptions, b: editorOptions.IEditorOptions): editorOptions.RawEditorOptions { + // console.log(`mixOptions`, a, b); + const result = new editorOptions.RawEditorOptions(); + for (const editorOption of editorOptions.editorOptionsRegistry) { + result._write(editorOption.id, editorOption.mix(a._read(editorOption.id), editorOption.read(b))); + } + return result; + } + + public static validateOptions(options: editorOptions.RawEditorOptions): editorOptions.ValidatedEditorOptions { + // console.log(`validateOptions`, options); + const result = new editorOptions.ValidatedEditorOptions(); + for (const editorOption of editorOptions.editorOptionsRegistry) { + result._write(editorOption.id, editorOption.validate(options._read(editorOption.id))); + } + return result; + } + + public static computeOptions(options: editorOptions.ValidatedEditorOptions, env: editorOptions.IEnvironmentalOptions): editorOptions.ComputedEditorOptions { + // console.log(`computeOptions`, options, env); + const result = new editorOptions.ComputedEditorOptions(); + for (const editorOption of editorOptions.editorOptionsRegistry) { + result._write(editorOption.id, editorOption.compute(options._read(editorOption.id))); + } + return result; + } + + public static checkEquals(a: editorOptions.ComputedEditorOptions, b: editorOptions.ComputedEditorOptions): editorOptions.ChangedEditorOptions | null { + // console.log(`equals`, a, b); + const result = new editorOptions.ChangedEditorOptions(); + let somethingChanged = false; + for (const editorOption of editorOptions.editorOptionsRegistry) { + const equals = editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); + result._write(editorOption.id, equals); + if (!equals) { + somethingChanged = true; + } + } + return (somethingChanged ? result : null); + } +} + export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { public readonly isSimpleWidget: boolean; @@ -75,6 +127,10 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed private _onDidChange = this._register(new Emitter()); public readonly onDidChange: Event = this._onDidChange.event; + private _rawOptions2: editorOptions.RawEditorOptions; + private _validatedOptions2: editorOptions.ValidatedEditorOptions; + public options!: editorOptions.ComputedEditorOptions; + constructor(isSimpleWidget: boolean, options: editorOptions.IEditorOptions) { super(); @@ -89,6 +145,10 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {}); this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); + + this._rawOptions2 = EditorConfiguration2.readOptions(options); + this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); + this._isDominatedByLongLines = false; this._lineNumbersDigitCount = 1; @@ -105,16 +165,20 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed protected _recomputeOptions(): void { const oldOptions = this.editor; - const newOptions = this._computeInternalOptions(); + const oldOptions2 = this.options; + const [newOptions, newOptions2] = this._computeInternalOptions(); + + const changeEvent = (oldOptions2 ? EditorConfiguration2.checkEquals(oldOptions2, newOptions2) : null); - if (oldOptions && oldOptions.equals(newOptions)) { + if (oldOptions && oldOptions.equals(newOptions) && oldOptions2 && changeEvent === null) { return; } this.editor = newOptions; + this.options = newOptions2; if (oldOptions) { - this._onDidChange.fire(oldOptions.createChangeEvent(newOptions)); + this._onDidChange.fire(oldOptions.createChangeEvent(newOptions, changeEvent)); } } @@ -122,7 +186,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed return this._rawOptions; } - private _computeInternalOptions(): editorOptions.InternalEditorOptions { + private _computeInternalOptions(): [editorOptions.InternalEditorOptions, editorOptions.ComputedEditorOptions] { const opts = this._validatedOptions; const partialEnv = this._getEnvConfiguration(); const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget); @@ -138,7 +202,9 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed tabFocusMode: TabFocus.getTabFocusMode(), accessibilitySupport: partialEnv.accessibilitySupport }; - return editorOptions.InternalEditorOptionsFactory.createInternalEditorOptions(env, opts); + const r = editorOptions.InternalEditorOptionsFactory.createInternalEditorOptions(env, opts); + const r2 = EditorConfiguration2.computeOptions(this._validatedOptions2, env); + return [r, r2]; } private static _primitiveArrayEquals(a: any[], b: any[]): boolean { @@ -189,7 +255,11 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed return; } this._rawOptions = objects.mixin(this._rawOptions, newOptions || {}); + this._rawOptions2 = EditorConfiguration2.mixOptions(this._rawOptions2, newOptions); + this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); + this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); + this._recomputeOptions(); } @@ -275,7 +345,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.renderFinalNewline': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.renderFinalNewline, + 'default': editorOptions.EditorOption.RenderFinalNewline.defaultValue, 'description': nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }, 'editor.rulers': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 43c568a191f49..6c0c01f4524c1 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -997,7 +997,6 @@ export interface InternalEditorViewOptions { readonly renderLineNumbers: RenderLineNumbersType; readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; - readonly renderFinalNewline: boolean; readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -1230,8 +1229,14 @@ export class InternalEditorOptions { /** * @internal */ - public createChangeEvent(newOpts: InternalEditorOptions): IConfigurationChangedEvent { + public createChangeEvent(newOpts: InternalEditorOptions, changeEvent: ChangedEditorOptions | null): IConfigurationChangedEvent { return { + hasChanged: (id: EditorOptionId) => { + if (!changeEvent) { + return false; + } + return changeEvent.get(id); + }, canUseLayerHinting: (this.canUseLayerHinting !== newOpts.canUseLayerHinting), pixelRatio: (this.pixelRatio !== newOpts.pixelRatio), editorClassName: (this.editorClassName !== newOpts.editorClassName), @@ -1312,7 +1317,6 @@ export class InternalEditorOptions { && a.renderLineNumbers === b.renderLineNumbers && a.renderCustomLineNumbers === b.renderCustomLineNumbers && a.cursorSurroundingLines === b.cursorSurroundingLines - && a.renderFinalNewline === b.renderFinalNewline && a.selectOnLineNumbers === b.selectOnLineNumbers && a.glyphMargin === b.glyphMargin && a.revealHorizontalRightPadding === b.revealHorizontalRightPadding @@ -1638,6 +1642,7 @@ export interface EditorLayoutInfo { * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { + hasChanged(id: EditorOptionId): boolean; readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; readonly editorClassName: boolean; @@ -2076,7 +2081,6 @@ export class EditorOptionsValidator { cursorSurroundingLines: _clampedInt(opts.cursorSurroundingLines, defaults.cursorWidth, 0, Number.MAX_VALUE), renderLineNumbers: renderLineNumbers, renderCustomLineNumbers: renderCustomLineNumbers, - renderFinalNewline: _boolean(opts.renderFinalNewline, defaults.renderFinalNewline), selectOnLineNumbers: _boolean(opts.selectOnLineNumbers, defaults.selectOnLineNumbers), glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin), revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000), @@ -2198,7 +2202,6 @@ export class InternalEditorOptionsFactory { renderLineNumbers: opts.viewInfo.renderLineNumbers, renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers, cursorSurroundingLines: opts.viewInfo.cursorSurroundingLines, - renderFinalNewline: opts.viewInfo.renderFinalNewline, selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers, glyphMargin: opts.viewInfo.glyphMargin, revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding, @@ -2665,7 +2668,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { renderLineNumbers: RenderLineNumbersType.On, renderCustomLineNumbers: null, cursorSurroundingLines: 0, - renderFinalNewline: true, selectOnLineNumbers: true, glyphMargin: true, revealHorizontalRightPadding: 30, @@ -2770,3 +2772,127 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { codeActionsOnSaveTimeout: 750 }, }; + +export interface IRawEditorOptionsBag { + [key: string]: any; +} + +/** + * @internal + */ +export class RawEditorOptions { + private readonly _values: any[] = []; + public _read(id: EditorOptionId): T | undefined { + return this._values[id]; + } + public _write(id: EditorOptionId, value: T | undefined): void { + this._values[id] = value; + } +} + +/** + * @internal + */ +export class ValidatedEditorOptions { + private readonly _values: any[] = []; + public _read(option: EditorOptionId): T { + return this._values[option]; + } + public _write(option: EditorOptionId, value: T): void { + this._values[option] = value; + } +} + +export interface IComputedEditorOptions { + get(id: EditorOptionId, option: IEditorOption): T3; +} + +/** + * @internal + */ +export class ComputedEditorOptions { + private readonly _values: any[] = []; + public _read(id: EditorOptionId): T { + return this._values[id]; + } + public get(id: EditorOptionId, option: IEditorOption): T3 { + return this._values[id]; + } + public _write(id: EditorOptionId, value: T): void { + this._values[id] = value; + } +} + +/** + * @internal + */ +export class ChangedEditorOptions { + private readonly _values: boolean[] = []; + public get(id: EditorOptionId): boolean { + return this._values[id]; + } + public _write(id: EditorOptionId, value: boolean): void { + this._values[id] = value; + } +} + +interface IEditorOption { + readonly id: EditorOptionId; + readonly name: string; + readonly defaultValue: T1; + read(options: IRawEditorOptionsBag): T1 | undefined; + mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; + validate(input: T1 | undefined): T2; + compute(value: T2): T3; + equals(a: T3, b: T3): boolean; +} + +class BooleanEditorOption implements IEditorOption { + public readonly id: EditorOptionId; + public readonly name: string; + public readonly defaultValue: boolean; + + constructor(id: EditorOptionId, name: string, defaultValue: boolean) { + this.id = id; + this.name = name; + this.defaultValue = defaultValue; + } + + public read(options: IRawEditorOptionsBag): boolean | undefined { + return options[this.name]; + } + + public mix(a: boolean | undefined, b: boolean | undefined): boolean | undefined { + return (typeof b !== 'undefined' ? b : a); + } + + public validate(input: boolean | undefined): boolean { + return _boolean(input, this.defaultValue); + } + + public compute(value: boolean): boolean { + return value; + } + + public equals(a: boolean, b: boolean): boolean { + return (a === b); + } +} + +/** + * @internal + */ +export const editorOptionsRegistry: IEditorOption[] = []; + +function registerEditorOption(option: IEditorOption): IEditorOption { + editorOptionsRegistry[option.id] = option; + return option; +} + +export const enum EditorOptionId { + RenderFinalNewline, +} + +export const EditorOption = { + RenderFinalNewline: registerEditorOption(new BooleanEditorOption(EditorOptionId.RenderFinalNewline, 'renderFinalNewline', true)) +}; diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index bde26ab980217..6c9541592342f 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -152,6 +152,7 @@ export interface IConfiguration extends IDisposable { onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable; readonly editor: editorOptions.InternalEditorOptions; + readonly options: editorOptions.IComputedEditorOptions; setMaxLineNumber(maxLineNumber: number): void; updateOptions(newOptions: editorOptions.IEditorOptions): void; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index a705c132478b7..ef807a300680b 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -430,6 +430,10 @@ export enum RenderLineNumbersType { Custom = 4 } +export enum EditorOptionId { + RenderFinalNewline = 0 +} + /** * A positioning preference for rendering content widgets. */ diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 280e00cbdf712..c3936c2a1b7dd 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -369,6 +369,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { RenderMinimap: standaloneEnums.RenderMinimap, ScrollType: standaloneEnums.ScrollType, RenderLineNumbersType: standaloneEnums.RenderLineNumbersType, + EditorOptionId: standaloneEnums.EditorOptionId, // classes InternalEditorOptions: editorOptions.InternalEditorOptions, @@ -378,7 +379,8 @@ export function createMonacoEditorAPI(): typeof monaco.editor { FindMatch: FindMatch, // vars - EditorType: editorCommon.EditorType + EditorType: editorCommon.EditorType, + EditorOption: editorOptions.EditorOption, }; } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 6e0b1286ef04b..970d6f079d601 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3312,7 +3312,6 @@ declare namespace monaco.editor { readonly renderLineNumbers: RenderLineNumbersType; readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; - readonly renderFinalNewline: boolean; readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -3525,6 +3524,7 @@ declare namespace monaco.editor { * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { + hasChanged(id: EditorOptionId): boolean; readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; readonly editorClassName: boolean; @@ -3551,6 +3551,33 @@ declare namespace monaco.editor { readonly contribInfo: boolean; } + export interface IRawEditorOptionsBag { + [key: string]: any; + } + + export interface IComputedEditorOptions { + get(id: EditorOptionId, option: IEditorOption): T3; + } + + interface IEditorOption { + readonly id: EditorOptionId; + readonly name: string; + readonly defaultValue: T1; + read(options: IRawEditorOptionsBag): T1 | undefined; + mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; + validate(input: T1 | undefined): T2; + compute(value: T2): T3; + equals(a: T3, b: T3): boolean; + } + + export enum EditorOptionId { + RenderFinalNewline = 0 + } + + export const EditorOption: { + RenderFinalNewline: IEditorOption; + }; + /** * A view zone is a full horizontal rectangle that 'pushes' text down. * The editor reserves space for view zones when rendering. From 44e5859b23395a60ca9e691cc9bd53a8d14ff60e Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 30 Aug 2019 15:18:46 -0700 Subject: [PATCH 003/204] Fix #80134 - editor service requires strongly typed options --- .../services/preferences/browser/preferencesService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/services/preferences/browser/preferencesService.ts b/src/vs/workbench/services/preferences/browser/preferencesService.ts index c95a613854514..68ac6c5b36eb3 100644 --- a/src/vs/workbench/services/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/services/preferences/browser/preferencesService.ts @@ -214,7 +214,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic private openSettings2(options?: ISettingsEditorOptions): Promise { const input = this.settingsEditor2Input; - return this.editorService.openEditor(input, options) + return this.editorService.openEditor(input, options ? SettingsEditorOptions.create(options) : undefined) .then(() => this.editorGroupService.activeGroup.activeControl!); } From 75ffa8befa51ec59a233c7c030226737bd4af53d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 2 Sep 2019 12:06:47 +0200 Subject: [PATCH 004/204] - Add a typed way to read options - Move more options to the new format --- .../editor/browser/controller/mouseHandler.ts | 3 +- src/vs/editor/browser/editorBrowser.ts | 2 ++ .../viewParts/lineNumbers/lineNumbers.ts | 2 +- .../editor/browser/widget/codeEditorWidget.ts | 4 +++ .../common/config/commonEditorConfig.ts | 8 +++-- src/vs/editor/common/config/editorOptions.ts | 31 ++++++------------- src/vs/editor/common/editorCommon.ts | 3 +- .../common/standalone/standaloneEnums.ts | 4 ++- src/vs/monaco.d.ts | 19 ++++++------ .../codeEditor/browser/selectionClipboard.ts | 8 ++--- 10 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index 418e8ebee98ea..ccd54250d8944 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -21,6 +21,7 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; /** * Merges mouse events when mouse move events are throttled @@ -216,7 +217,7 @@ export class MouseHandler extends ViewEventHandler { const targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY); const targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS); const targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS); - const selectOnLineNumbers = this._context.configuration.editor.viewInfo.selectOnLineNumbers; + const selectOnLineNumbers = this._context.configuration.getOption(EditorOptionId.selectOnLineNumbers); const targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE); const targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET); diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index a5e31344d3c2d..d1efe4ddd5278 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -536,6 +536,8 @@ export interface ICodeEditor extends editorCommon.IEditor { */ getConfiguration(): editorOptions.InternalEditorOptions; + getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue; + /** * Returns the 'raw' editor's configuration (without any validation or defaults). * @internal diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index c80286daf0dc6..2067c4d38787c 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -45,7 +45,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay { this._lineHeight = config.lineHeight; this._renderLineNumbers = config.viewInfo.renderLineNumbers; this._renderCustomLineNumbers = config.viewInfo.renderCustomLineNumbers; - this._renderFinalNewline = this._context.configuration.options.get(EditorOptionId.RenderFinalNewline, EditorOption.RenderFinalNewline); + this._renderFinalNewline = this._context.configuration.getOption(EditorOptionId.renderFinalNewline); this._lineNumbersLeft = config.layoutInfo.lineNumbersLeft; this._lineNumbersWidth = config.layoutInfo.lineNumbersWidth; } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 0ac879ee78a59..3860def914f4b 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -370,6 +370,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE return this._configuration.editor; } + public getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue { + return this._configuration.getOption(id); + } + public getRawConfiguration(): editorOptions.IEditorOptions { return this._configuration.getRawOptions(); } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 6ae96a3430c3c..10fff30099556 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -156,6 +156,10 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions())); } + public getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue { + return this.options._read(id); + } + public observeReferenceElement(dimension?: editorCommon.IDimension): void { } @@ -345,7 +349,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.renderFinalNewline': { 'type': 'boolean', - 'default': editorOptions.EditorOption.RenderFinalNewline.defaultValue, + 'default': editorOptions.EditorOption.renderFinalNewline.defaultValue, 'description': nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }, 'editor.rulers': { @@ -1137,7 +1141,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.selectionClipboard': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.selectionClipboard, + 'default': editorOptions.EditorOption.selectionClipboard.defaultValue, 'description': nls.localize('selectionClipboard', "Controls whether the Linux primary clipboard should be supported."), 'included': platform.isLinux }, diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 6c0c01f4524c1..45bef3115da8e 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -997,7 +997,6 @@ export interface InternalEditorViewOptions { readonly renderLineNumbers: RenderLineNumbersType; readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; - readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; readonly roundedSelection: boolean; @@ -1025,7 +1024,6 @@ export interface InternalEditorViewOptions { } export interface EditorContribOptions { - readonly selectionClipboard: boolean; readonly hover: InternalEditorHoverOptions; readonly links: boolean; readonly contextmenu: boolean; @@ -1317,7 +1315,6 @@ export class InternalEditorOptions { && a.renderLineNumbers === b.renderLineNumbers && a.renderCustomLineNumbers === b.renderCustomLineNumbers && a.cursorSurroundingLines === b.cursorSurroundingLines - && a.selectOnLineNumbers === b.selectOnLineNumbers && a.glyphMargin === b.glyphMargin && a.revealHorizontalRightPadding === b.revealHorizontalRightPadding && a.roundedSelection === b.roundedSelection @@ -1464,8 +1461,7 @@ export class InternalEditorOptions { */ private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean { return ( - a.selectionClipboard === b.selectionClipboard - && this._equalsHoverOptions(a.hover, b.hover) + this._equalsHoverOptions(a.hover, b.hover) && a.links === b.links && a.contextmenu === b.contextmenu && InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions) @@ -2081,7 +2077,6 @@ export class EditorOptionsValidator { cursorSurroundingLines: _clampedInt(opts.cursorSurroundingLines, defaults.cursorWidth, 0, Number.MAX_VALUE), renderLineNumbers: renderLineNumbers, renderCustomLineNumbers: renderCustomLineNumbers, - selectOnLineNumbers: _boolean(opts.selectOnLineNumbers, defaults.selectOnLineNumbers), glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin), revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000), roundedSelection: _boolean(opts.roundedSelection, defaults.roundedSelection), @@ -2122,7 +2117,6 @@ export class EditorOptionsValidator { } const find = this._sanitizeFindOpts(opts.find, defaults.find); return { - selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard), hover: this._sanitizeHoverOpts(opts.hover, defaults.hover), links: _boolean(opts.links, defaults.links), contextmenu: _boolean(opts.contextmenu, defaults.contextmenu), @@ -2202,7 +2196,6 @@ export class InternalEditorOptionsFactory { renderLineNumbers: opts.viewInfo.renderLineNumbers, renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers, cursorSurroundingLines: opts.viewInfo.cursorSurroundingLines, - selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers, glyphMargin: opts.viewInfo.glyphMargin, revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding, roundedSelection: opts.viewInfo.roundedSelection, @@ -2236,7 +2229,6 @@ export class InternalEditorOptionsFactory { }, contribInfo: { - selectionClipboard: opts.contribInfo.selectionClipboard, hover: opts.contribInfo.hover, links: opts.contribInfo.links, contextmenu: opts.contribInfo.contextmenu, @@ -2668,7 +2660,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { renderLineNumbers: RenderLineNumbersType.On, renderCustomLineNumbers: null, cursorSurroundingLines: 0, - selectOnLineNumbers: true, glyphMargin: true, revealHorizontalRightPadding: 30, roundedSelection: true, @@ -2716,7 +2707,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { }, contribInfo: { - selectionClipboard: true, hover: { enabled: true, delay: 300, @@ -2803,10 +2793,6 @@ export class ValidatedEditorOptions { } } -export interface IComputedEditorOptions { - get(id: EditorOptionId, option: IEditorOption): T3; -} - /** * @internal */ @@ -2815,9 +2801,6 @@ export class ComputedEditorOptions { public _read(id: EditorOptionId): T { return this._values[id]; } - public get(id: EditorOptionId, option: IEditorOption): T3 { - return this._values[id]; - } public _write(id: EditorOptionId, value: T): void { this._values[id] = value; } @@ -2836,7 +2819,7 @@ export class ChangedEditorOptions { } } -interface IEditorOption { +export interface IEditorOption { readonly id: EditorOptionId; readonly name: string; readonly defaultValue: T1; @@ -2890,9 +2873,15 @@ function registerEditorOption(option: IEditorOption): IE } export const enum EditorOptionId { - RenderFinalNewline, + renderFinalNewline, + selectionClipboard, + selectOnLineNumbers, } export const EditorOption = { - RenderFinalNewline: registerEditorOption(new BooleanEditorOption(EditorOptionId.RenderFinalNewline, 'renderFinalNewline', true)) + renderFinalNewline: registerEditorOption(new BooleanEditorOption(EditorOptionId.renderFinalNewline, 'renderFinalNewline', true)), + selectionClipboard: registerEditorOption(new BooleanEditorOption(EditorOptionId.selectionClipboard, 'selectionClipboard', true)), + selectOnLineNumbers: registerEditorOption(new BooleanEditorOption(EditorOptionId.selectOnLineNumbers, 'selectOnLineNumbers', true)), }; + +export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 6c9541592342f..f070525b99bc7 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -152,7 +152,8 @@ export interface IConfiguration extends IDisposable { onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable; readonly editor: editorOptions.InternalEditorOptions; - readonly options: editorOptions.IComputedEditorOptions; + + getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue; setMaxLineNumber(maxLineNumber: number): void; updateOptions(newOptions: editorOptions.IEditorOptions): void; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index ef807a300680b..1af333dd0a41f 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -431,7 +431,9 @@ export enum RenderLineNumbersType { } export enum EditorOptionId { - RenderFinalNewline = 0 + renderFinalNewline = 0, + selectionClipboard = 1, + selectOnLineNumbers = 2 } /** diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 970d6f079d601..87d8500889508 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3312,7 +3312,6 @@ declare namespace monaco.editor { readonly renderLineNumbers: RenderLineNumbersType; readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; - readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; readonly roundedSelection: boolean; @@ -3340,7 +3339,6 @@ declare namespace monaco.editor { } export interface EditorContribOptions { - readonly selectionClipboard: boolean; readonly hover: InternalEditorHoverOptions; readonly links: boolean; readonly contextmenu: boolean; @@ -3555,11 +3553,7 @@ declare namespace monaco.editor { [key: string]: any; } - export interface IComputedEditorOptions { - get(id: EditorOptionId, option: IEditorOption): T3; - } - - interface IEditorOption { + export interface IEditorOption { readonly id: EditorOptionId; readonly name: string; readonly defaultValue: T1; @@ -3571,13 +3565,19 @@ declare namespace monaco.editor { } export enum EditorOptionId { - RenderFinalNewline = 0 + renderFinalNewline = 0, + selectionClipboard = 1, + selectOnLineNumbers = 2 } export const EditorOption: { - RenderFinalNewline: IEditorOption; + renderFinalNewline: IEditorOption; + selectionClipboard: IEditorOption; + selectOnLineNumbers: IEditorOption; }; + export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; + /** * A view zone is a full horizontal rectangle that 'pushes' text down. * The editor reserves space for view zones when rendering. @@ -4027,6 +4027,7 @@ declare namespace monaco.editor { * Returns the current editor's configuration */ getConfiguration(): InternalEditorOptions; + getOption>(id: EditorOptionId): ComputedEditorOptionValue; /** * Get value of the current model attached to this editor. * @see `ITextModel.getValue` diff --git a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts index 4c3a8ba75ff57..18aa8e4965e01 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts @@ -9,7 +9,7 @@ import * as process from 'vs/base/common/process'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -24,11 +24,11 @@ export class SelectionClipboard extends Disposable implements IEditorContributio super(); if (platform.isLinux) { - let isEnabled = editor.getConfiguration().contribInfo.selectionClipboard; + let isEnabled = editor.getOption(EditorOptionId.selectionClipboard); this._register(editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.contribInfo) { - isEnabled = editor.getConfiguration().contribInfo.selectionClipboard; + if (e.hasChanged(EditorOptionId.selectionClipboard)) { + isEnabled = editor.getOption(EditorOptionId.selectionClipboard); } })); From 363b9769412fea0d9aef07fa1801371c14d72741 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 2 Sep 2019 23:05:00 +0200 Subject: [PATCH 005/204] Convert more editor options --- .../lib/tslint/noUnexternalizedStringsRule.js | 3 + .../lib/tslint/noUnexternalizedStringsRule.ts | 3 + build/monaco/api.js | 5 +- build/monaco/api.ts | 5 +- build/monaco/monaco.d.ts.recipe | 1 + .../editor/browser/controller/mouseHandler.ts | 2 +- .../editor/browser/controller/mouseTarget.ts | 8 +- .../browser/controller/textAreaHandler.ts | 31 +- src/vs/editor/browser/editorBrowser.ts | 2 + src/vs/editor/browser/view/viewImpl.ts | 6 +- src/vs/editor/browser/view/viewLayer.ts | 6 +- src/vs/editor/browser/view/viewOverlays.ts | 22 +- .../contentWidgets/contentWidgets.ts | 16 +- .../currentLineHighlight.ts | 13 +- .../currentLineMarginHighlight.ts | 11 +- .../editorScrollbar/editorScrollbar.ts | 57 +- .../viewParts/glyphMargin/glyphMargin.ts | 16 +- .../viewParts/indentGuides/indentGuides.ts | 11 +- .../viewParts/lineNumbers/lineNumbers.ts | 13 +- .../browser/viewParts/lines/viewLines.ts | 15 +- .../linesDecorations/linesDecorations.ts | 17 +- .../editor/browser/viewParts/margin/margin.ts | 21 +- .../browser/viewParts/minimap/minimap.ts | 8 +- .../overlayWidgets/overlayWidgets.ts | 29 +- .../overviewRuler/decorationsOverviewRuler.ts | 10 +- .../editor/browser/viewParts/rulers/rulers.ts | 6 +- .../scrollDecoration/scrollDecoration.ts | 18 +- .../browser/viewParts/viewZones/viewZones.ts | 16 +- .../editor/browser/widget/codeEditorWidget.ts | 19 +- .../editor/browser/widget/diffEditorWidget.ts | 6 +- src/vs/editor/browser/widget/diffReview.ts | 15 +- .../common/config/commonEditorConfig.ts | 55 +- src/vs/editor/common/config/editorOptions.ts | 1815 ++++++++--------- .../editor/common/controller/cursorCommon.ts | 10 +- src/vs/editor/common/editorCommon.ts | 3 +- .../common/standalone/standaloneEnums.ts | 36 +- src/vs/editor/common/view/viewEvents.ts | 14 +- src/vs/editor/common/viewLayout/viewLayout.ts | 27 +- .../editor/common/viewModel/viewModelImpl.ts | 23 +- src/vs/editor/contrib/find/findWidget.ts | 16 +- src/vs/editor/contrib/folding/folding.ts | 10 +- .../accessibilityHelp/accessibilityHelp.ts | 4 +- .../standalone/browser/standaloneEditor.ts | 2 + .../common/config/commonEditorConfig.test.ts | 8 +- .../viewLayout/editorLayoutProvider.test.ts | 4 +- .../viewModel/splitLinesCollection.test.ts | 49 +- src/vs/monaco.d.ts | 278 ++- .../workbench/api/browser/mainThreadEditor.ts | 6 +- .../browser/parts/editor/editorStatus.ts | 4 +- .../codeEditor/browser/toggleWordWrap.ts | 45 +- .../browser/commentsEditorContribution.ts | 6 +- .../preferences/browser/preferencesWidgets.ts | 4 +- .../quickopen/browser/gotoLineHandler.ts | 7 +- 53 files changed, 1555 insertions(+), 1282 deletions(-) diff --git a/build/lib/tslint/noUnexternalizedStringsRule.js b/build/lib/tslint/noUnexternalizedStringsRule.js index 18a90c0f9c1eb..a1183ce68e767 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.js +++ b/build/lib/tslint/noUnexternalizedStringsRule.js @@ -11,6 +11,9 @@ const Lint = require("tslint"); */ class Rule extends Lint.Rules.AbstractRule { apply(sourceFile) { + if (/\.d.ts$/.test(sourceFile.fileName)) { + return []; + } return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions())); } } diff --git a/build/lib/tslint/noUnexternalizedStringsRule.ts b/build/lib/tslint/noUnexternalizedStringsRule.ts index e8c0e98ec15e0..d896e4fabe2ee 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.ts +++ b/build/lib/tslint/noUnexternalizedStringsRule.ts @@ -11,6 +11,9 @@ import * as Lint from 'tslint'; */ export class Rule extends Lint.Rules.AbstractRule { public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + if (/\.d.ts$/.test(sourceFile.fileName)) { + return []; + } return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions())); } } diff --git a/build/monaco/api.js b/build/monaco/api.js index 5cd0be82039fd..93fea1558b9ec 100644 --- a/build/monaco/api.js +++ b/build/monaco/api.js @@ -148,8 +148,9 @@ function getMassagedTopLevelDeclarationText(sourceFile, declaration, importName, } }); } - result = result.replace(/export default/g, 'export'); - result = result.replace(/export declare/g, 'export'); + result = result.replace(/export default /g, 'export '); + result = result.replace(/export declare /g, 'export '); + result = result.replace(/declare /g, ''); if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { result = result.replace(/const enum/, 'enum'); enums.push(result); diff --git a/build/monaco/api.ts b/build/monaco/api.ts index ef9c9a584dc6a..1cd4e49b73377 100644 --- a/build/monaco/api.ts +++ b/build/monaco/api.ts @@ -178,8 +178,9 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati } }); } - result = result.replace(/export default/g, 'export'); - result = result.replace(/export declare/g, 'export'); + result = result.replace(/export default /g, 'export '); + result = result.replace(/export declare /g, 'export '); + result = result.replace(/declare /g, ''); if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { result = result.replace(/const enum/, 'enum'); diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index afba093b25c8e..4a80dae41aacb 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -62,6 +62,7 @@ export interface ICommandHandler { #includeAll(vs/editor/common/editorCommon;editorOptions.=>): IScrollEvent #includeAll(vs/editor/common/model/textModelEvents): #includeAll(vs/editor/common/controller/cursorEvents): +#include(vs/platform/accessibility/common/accessibility): AccessibilitySupport #includeAll(vs/editor/common/config/editorOptions): #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>): #include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index ccd54250d8944..ce65849c4184e 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -217,7 +217,7 @@ export class MouseHandler extends ViewEventHandler { const targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY); const targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS); const targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS); - const selectOnLineNumbers = this._context.configuration.getOption(EditorOptionId.selectOnLineNumbers); + const selectOnLineNumbers = this._context.configuration.options.get(EditorOptionId.selectOnLineNumbers); const targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE); const targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET); diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index f510e0f6f82ad..58948e740aa73 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -10,7 +10,7 @@ import { ClientCoordinates, EditorMouseEvent, EditorPagePosition, PageCoordinate import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart'; import { ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine'; import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; -import { EditorLayoutInfo } from 'vs/editor/common/config/editorOptions'; +import { EditorLayoutInfo, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range as EditorRange } from 'vs/editor/common/core/range'; import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; @@ -239,7 +239,8 @@ export class HitTestContext { constructor(context: ViewContext, viewHelper: IPointerHandlerHelper, lastViewCursorsRenderData: IViewCursorRenderData[]) { this.model = context.model; - this.layoutInfo = context.configuration.editor.layoutInfo; + const options = context.configuration.options; + this.layoutInfo = options.get(EditorOptionId.layoutInfo); this.viewDomNode = viewHelper.viewDomNode; this.lineHeight = context.configuration.editor.lineHeight; this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; @@ -713,7 +714,8 @@ export class MouseTargetFactory { } public getMouseColumn(editorPos: EditorPagePosition, pos: PageCoordinates): number { - const layoutInfo = this._context.configuration.editor.layoutInfo; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); const mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft; return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index c1a41a4981f49..bfefbfff922e9 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -16,7 +16,7 @@ import { ViewController } from 'vs/editor/browser/view/viewController'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; import { LineNumbersOverlay } from 'vs/editor/browser/viewParts/lineNumbers/lineNumbers'; import { Margin } from 'vs/editor/browser/viewParts/margin/margin'; -import { RenderLineNumbersType } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; import { BareFontInfo } from 'vs/editor/common/config/fontInfo'; import { WordCharacterClass, getMapForWordSeparators } from 'vs/editor/common/controller/wordCharacterClassifier'; import { Position } from 'vs/editor/common/core/position'; @@ -119,11 +119,13 @@ export class TextAreaHandler extends ViewPart { this._viewHelper = viewHelper; const conf = this._context.configuration.editor; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._accessibilitySupport = conf.accessibilitySupport; - this._contentLeft = conf.layoutInfo.contentLeft; - this._contentWidth = conf.layoutInfo.contentWidth; - this._contentHeight = conf.layoutInfo.contentHeight; + this._contentLeft = layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; + this._contentHeight = layoutInfo.contentHeight; this._scrollLeft = 0; this._scrollTop = 0; this._fontInfo = conf.fontInfo; @@ -143,7 +145,7 @@ export class TextAreaHandler extends ViewPart { this.textArea.setAttribute('autocapitalize', 'off'); this.textArea.setAttribute('autocomplete', 'off'); this.textArea.setAttribute('spellcheck', 'false'); - this.textArea.setAttribute('aria-label', conf.viewInfo.ariaLabel); + this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); this.textArea.setAttribute('role', 'textbox'); this.textArea.setAttribute('aria-multiline', 'true'); this.textArea.setAttribute('aria-haspopup', 'false'); @@ -371,22 +373,24 @@ export class TextAreaHandler extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const conf = this._context.configuration.editor; + const options = this._context.configuration.options; if (e.fontInfo) { this._fontInfo = conf.fontInfo; } if (e.viewInfo) { - this.textArea.setAttribute('aria-label', conf.viewInfo.ariaLabel); + this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); } - if (e.layoutInfo) { - this._contentLeft = conf.layoutInfo.contentLeft; - this._contentWidth = conf.layoutInfo.contentWidth; - this._contentHeight = conf.layoutInfo.contentHeight; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; + this._contentHeight = layoutInfo.contentHeight; } if (e.lineHeight) { this._lineHeight = conf.lineHeight; } - if (e.accessibilitySupport) { + if (e.hasChanged(EditorOptionId.accessibilitySupport)) { this._accessibilitySupport = conf.accessibilitySupport; this._textAreaInput.writeScreenReaderContent('strategy changed'); } @@ -544,10 +548,13 @@ export class TextAreaHandler extends ViewPart { tac.setWidth(1); tac.setHeight(1); + const options = this._context.configuration.options; + if (this._context.configuration.editor.viewInfo.glyphMargin) { tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME); } else { - if (this._context.configuration.editor.viewInfo.renderLineNumbers !== RenderLineNumbersType.Off) { + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + if (renderLineNumbers.renderType !== RenderLineNumbersType.Off) { tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME); } else { tac.setClassName('monaco-editor-background textAreaCover'); diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index d1efe4ddd5278..de7dcc54683f3 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -536,6 +536,8 @@ export interface ICodeEditor extends editorCommon.IEditor { */ getConfiguration(): editorOptions.InternalEditorOptions; + getOptions(): editorOptions.IComputedEditorOptions; + getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue; /** diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 45c711ceceff8..67fca03779377 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -48,6 +48,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData' import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IContentWidgetData { widget: editorBrowser.IContentWidget; @@ -281,7 +282,8 @@ export class View extends ViewEventHandler { } private _setLayout(): void { - const layoutInfo = this._context.configuration.editor.layoutInfo; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.domNode.setWidth(layoutInfo.width); this.domNode.setHeight(layoutInfo.height); @@ -304,7 +306,7 @@ export class View extends ViewEventHandler { if (e.editorClassName) { this.domNode.setClassName(this.getEditorClassName()); } - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { this._setLayout(); } return false; diff --git a/src/vs/editor/browser/view/viewLayer.ts b/src/vs/editor/browser/view/viewLayer.ts index ecdd665be7312..c5624ce9c83e7 100644 --- a/src/vs/editor/browser/view/viewLayer.ts +++ b/src/vs/editor/browser/view/viewLayer.ts @@ -7,6 +7,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; /** * Represents a visible line @@ -269,7 +270,10 @@ export class VisibleLinesCollection { // ---- begin view event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - return e.layoutInfo; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + return true; + } + return false; } public onFlushed(e: viewEvents.ViewFlushedEvent): boolean { diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index bc75a6b4cef92..5182408db5aea 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -14,6 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class ViewOverlays extends ViewPart implements IVisibleLinesHost { @@ -215,8 +216,9 @@ export class ContentViewOverlays extends ViewOverlays { constructor(context: ViewContext) { super(context); - - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentWidth = layoutInfo.contentWidth; this.domNode.setHeight(0); } @@ -224,8 +226,10 @@ export class ContentViewOverlays extends ViewOverlays { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.layoutInfo) { - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentWidth = layoutInfo.contentWidth; } return super.onConfigurationChanged(e); } @@ -249,7 +253,9 @@ export class MarginViewOverlays extends ViewOverlays { constructor(context: ViewContext) { super(context); - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; this.domNode.setClassName('margin-view-overlays'); this.domNode.setWidth(1); @@ -263,8 +269,10 @@ export class MarginViewOverlays extends ViewOverlays { Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); shouldRender = true; } - if (e.layoutInfo) { - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; shouldRender = true; } return super.onConfigurationChanged(e) || shouldRender; diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index cae3be1ed169c..9c7998b742722 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -14,6 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; class Coordinate { _coordinateBrand: void; @@ -207,9 +208,12 @@ class Widget { this.allowEditorOverflow = this._actual.allowEditorOverflow || false; this.suppressMouseDown = this._actual.suppressMouseDown || false; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets; - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; + this._contentLeft = layoutInfo.contentLeft; this._lineHeight = this._context.configuration.editor.lineHeight; this._position = null; @@ -233,9 +237,11 @@ class Widget { if (e.lineHeight) { this._lineHeight = this._context.configuration.editor.lineHeight; } - if (e.layoutInfo) { - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; this._maxWidth = this._getMaxWidth(); } } diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index d707bbad7c55e..65343ec07eb8c 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -10,6 +10,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class CurrentLineHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; @@ -23,13 +24,17 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; this._selectionIsEmpty = true; this._primaryCursorLineNumber = 1; this._scrollWidth = 0; - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; + + this._contentWidth = layoutInfo.contentWidth; this._context.addEventHandler(this); } @@ -48,8 +53,10 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { if (e.viewInfo) { this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; } - if (e.layoutInfo) { - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentWidth = layoutInfo.contentWidth; } return true; } diff --git a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts index 551450736551a..1389ed0e1b0dd 100644 --- a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts @@ -10,6 +10,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; @@ -22,12 +23,14 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; this._selectionIsEmpty = true; this._primaryCursorLineNumber = 1; - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + this._contentLeft = layoutInfo.contentLeft; this._context.addEventHandler(this); } @@ -46,8 +49,10 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { if (e.viewInfo) { this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; } - if (e.layoutInfo) { - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; } return true; } diff --git a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts index d9b8c4dfd8fc3..24185fbc1c54c 100644 --- a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts +++ b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts @@ -14,6 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class EditorScrollbar extends ViewPart { @@ -28,8 +29,11 @@ export class EditorScrollbar extends ViewPart { ) { super(context); - const editor = this._context.configuration.editor; - const configScrollbarOpts = editor.viewInfo.scrollbar; + + const options = this._context.configuration.options; + const scrollbar = options.get(EditorOptionId.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); const scrollbarOptions: ScrollableElementCreationOptions = { listenOnDomNode: viewDomNode.domNode, @@ -37,18 +41,18 @@ export class EditorScrollbar extends ViewPart { useShadows: false, lazyRender: true, - vertical: configScrollbarOpts.vertical, - horizontal: configScrollbarOpts.horizontal, - verticalHasArrows: configScrollbarOpts.verticalHasArrows, - horizontalHasArrows: configScrollbarOpts.horizontalHasArrows, - verticalScrollbarSize: configScrollbarOpts.verticalScrollbarSize, - verticalSliderSize: configScrollbarOpts.verticalSliderSize, - horizontalScrollbarSize: configScrollbarOpts.horizontalScrollbarSize, - horizontalSliderSize: configScrollbarOpts.horizontalSliderSize, - handleMouseWheel: configScrollbarOpts.handleMouseWheel, - arrowSize: configScrollbarOpts.arrowSize, - mouseWheelScrollSensitivity: configScrollbarOpts.mouseWheelScrollSensitivity, - fastScrollSensitivity: configScrollbarOpts.fastScrollSensitivity, + vertical: scrollbar.vertical, + horizontal: scrollbar.horizontal, + verticalHasArrows: scrollbar.verticalHasArrows, + horizontalHasArrows: scrollbar.horizontalHasArrows, + verticalScrollbarSize: scrollbar.verticalScrollbarSize, + verticalSliderSize: scrollbar.verticalSliderSize, + horizontalScrollbarSize: scrollbar.horizontalScrollbarSize, + horizontalSliderSize: scrollbar.horizontalSliderSize, + handleMouseWheel: scrollbar.handleMouseWheel, + arrowSize: scrollbar.arrowSize, + mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, + fastScrollSensitivity: fastScrollSensitivity, }; this.scrollbar = this._register(new SmoothScrollableElement(linesContent.domNode, scrollbarOptions, this._context.viewLayout.scrollable)); @@ -96,11 +100,13 @@ export class EditorScrollbar extends ViewPart { } private _setLayout(): void { - const layoutInfo = this._context.configuration.editor.layoutInfo; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.scrollbarDomNode.setLeft(layoutInfo.contentLeft); - const side = this._context.configuration.editor.viewInfo.minimap.side; + const minimap = options.get(EditorOptionId.minimap); + const side = minimap.side; if (side === 'right') { this.scrollbarDomNode.setWidth(layoutInfo.contentWidth + layoutInfo.minimapWidth); } else { @@ -124,16 +130,23 @@ export class EditorScrollbar extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.viewInfo) { - const editor = this._context.configuration.editor; + if ( + e.hasChanged(EditorOptionId.scrollbar) + || e.hasChanged(EditorOptionId.mouseWheelScrollSensitivity) + || e.hasChanged(EditorOptionId.fastScrollSensitivity) + ) { + const options = this._context.configuration.options; + const scrollbar = options.get(EditorOptionId.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); const newOpts: ScrollableElementChangeOptions = { - handleMouseWheel: editor.viewInfo.scrollbar.handleMouseWheel, - mouseWheelScrollSensitivity: editor.viewInfo.scrollbar.mouseWheelScrollSensitivity, - fastScrollSensitivity: editor.viewInfo.scrollbar.fastScrollSensitivity + handleMouseWheel: scrollbar.handleMouseWheel, + mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, + fastScrollSensitivity: fastScrollSensitivity }; this.scrollbar.updateOptions(newOpts); } - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { this._setLayout(); } return true; diff --git a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts index 60c18790d0c0a..c063c6680715c 100644 --- a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts +++ b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts @@ -8,6 +8,7 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class DecorationToRender { _decorationToRenderBrand: void; @@ -84,10 +85,12 @@ export class GlyphMarginOverlay extends DedupOverlay { constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; - this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth; + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; this._renderResult = null; this._context.addEventHandler(this); } @@ -101,15 +104,18 @@ export class GlyphMarginOverlay extends DedupOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { + const options = this._context.configuration.options; + if (e.lineHeight) { this._lineHeight = this._context.configuration.editor.lineHeight; } if (e.viewInfo) { this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; } - if (e.layoutInfo) { - this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; } return true; } diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index ea713746e0da7..a8ba2a3936aa5 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -11,6 +11,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class IndentGuidesOverlay extends DynamicViewOverlay { @@ -27,11 +28,13 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { super(); this._context = context; this._primaryLineNumber = 0; + const options = this._context.configuration.options; this._lineHeight = this._context.configuration.editor.lineHeight; this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; - const wrappingColumn = this._context.configuration.editor.wrappingInfo.wrappingColumn; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); this._renderResult = null; @@ -48,6 +51,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { + const options = this._context.configuration.options; if (e.lineHeight) { this._lineHeight = this._context.configuration.editor.lineHeight; } @@ -58,8 +62,9 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; } - if (e.wrappingInfo || e.fontInfo) { - const wrappingColumn = this._context.configuration.editor.wrappingInfo.wrappingColumn; + if (e.hasChanged(EditorOptionId.wrappingInfo) || e.fontInfo) { + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } return true; diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index 2067c4d38787c..d07bbdc92aef9 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -41,13 +41,16 @@ export class LineNumbersOverlay extends DynamicViewOverlay { } private _readConfig(): void { + const options = this._context.configuration.options; const config = this._context.configuration.editor; this._lineHeight = config.lineHeight; - this._renderLineNumbers = config.viewInfo.renderLineNumbers; - this._renderCustomLineNumbers = config.viewInfo.renderCustomLineNumbers; - this._renderFinalNewline = this._context.configuration.getOption(EditorOptionId.renderFinalNewline); - this._lineNumbersLeft = config.layoutInfo.lineNumbersLeft; - this._lineNumbersWidth = config.layoutInfo.lineNumbersWidth; + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + this._renderLineNumbers = renderLineNumbers.renderType; + this._renderCustomLineNumbers = renderLineNumbers.renderFn; + this._renderFinalNewline = options.get(EditorOptionId.renderFinalNewline); + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._lineNumbersLeft = layoutInfo.lineNumbersLeft; + this._lineNumbersWidth = layoutInfo.lineNumbersWidth; } public dispose(): void { diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 580311d769117..2e64c0c8056c8 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -18,6 +18,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { Viewport } from 'vs/editor/common/viewModel/viewModel'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; class LastRenderedData { @@ -90,10 +91,12 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this.domNode = this._visibleLines.domNode; const conf = this._context.configuration; + const options = this._context.configuration.options; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); this._lineHeight = conf.editor.lineHeight; this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; - this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping; + this._isViewportWrapping = wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding; this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines; this._canUseLayerHinting = conf.editor.canUseLayerHinting; @@ -135,11 +138,12 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { this._visibleLines.onConfigurationChanged(e); - if (e.wrappingInfo) { + if (e.hasChanged(EditorOptionId.wrappingInfo)) { this._maxLineWidth = 0; } const conf = this._context.configuration; + const options = this._context.configuration.options; if (e.lineHeight) { this._lineHeight = conf.editor.lineHeight; @@ -147,8 +151,9 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, if (e.fontInfo) { this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; } - if (e.wrappingInfo) { - this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping; + if (e.hasChanged(EditorOptionId.wrappingInfo)) { + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + this._isViewportWrapping = wrappingInfo.isViewportWrapping; } if (e.viewInfo) { this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding; @@ -163,7 +168,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._onOptionsMaybeChanged(); - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { this._maxLineWidth = 0; } diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts index fe764290badfe..1d709f5b917b4 100644 --- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts +++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts @@ -8,6 +8,7 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class LinesDecorationsOverlay extends DedupOverlay { @@ -20,8 +21,10 @@ export class LinesDecorationsOverlay extends DedupOverlay { constructor(context: ViewContext) { super(); this._context = context; - this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft; - this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._decorationsLeft = layoutInfo.decorationsLeft; + this._decorationsWidth = layoutInfo.decorationsWidth; this._renderResult = null; this._context.addEventHandler(this); } @@ -35,9 +38,11 @@ export class LinesDecorationsOverlay extends DedupOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.layoutInfo) { - this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft; - this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth; + const options = this._context.configuration.options; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._decorationsLeft = layoutInfo.decorationsLeft; + this._decorationsWidth = layoutInfo.decorationsWidth; } return true; } @@ -107,4 +112,4 @@ export class LinesDecorationsOverlay extends DedupOverlay { } return this._renderResult[lineNumber - startLineNumber]; } -} \ No newline at end of file +} diff --git a/src/vs/editor/browser/viewParts/margin/margin.ts b/src/vs/editor/browser/viewParts/margin/margin.ts index ab4f24c7bf3ed..f49a24845e7a9 100644 --- a/src/vs/editor/browser/viewParts/margin/margin.ts +++ b/src/vs/editor/browser/viewParts/margin/margin.ts @@ -8,6 +8,7 @@ import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class Margin extends ViewPart { @@ -23,10 +24,13 @@ export class Margin extends ViewPart { constructor(context: ViewContext) { super(context); + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; - this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth; + this._contentLeft = layoutInfo.contentLeft; + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; this._domNode = createFastDomNode(document.createElement('div')); this._domNode.setClassName(Margin.OUTER_CLASS_NAME); @@ -51,14 +55,17 @@ export class Margin extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { + const options = this._context.configuration.options; + if (e.canUseLayerHinting) { this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; } - if (e.layoutInfo) { - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; - this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; } return true; diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 1182f2ee8ab98..747ef26183079 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -13,7 +13,7 @@ import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ILine, RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; -import { RenderMinimap } from 'vs/editor/common/config/editorOptions'; +import { RenderMinimap, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { RGBA8 } from 'vs/editor/common/core/rgba'; import { IConfiguration, ScrollType } from 'vs/editor/common/editorCommon'; @@ -107,14 +107,16 @@ class MinimapOptions { public readonly canvasOuterHeight: number; constructor(configuration: IConfiguration) { + const options = configuration.options; const pixelRatio = configuration.editor.pixelRatio; - const layoutInfo = configuration.editor.layoutInfo; + const layoutInfo = options.get(EditorOptionId.layoutInfo); const viewInfo = configuration.editor.viewInfo; const fontInfo = configuration.editor.fontInfo; this.renderMinimap = layoutInfo.renderMinimap | 0; this.scrollBeyondLastLine = viewInfo.scrollBeyondLastLine; - this.showSlider = viewInfo.minimap.showSlider; + const minimapOpts = options.get(EditorOptionId.minimap); + this.showSlider = minimapOpts.showSlider; this.pixelRatio = pixelRatio; this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; this.lineHeight = configuration.editor.lineHeight; diff --git a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts index 87a35ca24f24f..0fa9087323df6 100644 --- a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts +++ b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts @@ -10,6 +10,7 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; interface IWidgetData { widget: IOverlayWidget; @@ -35,12 +36,15 @@ export class ViewOverlayWidgets extends ViewPart { constructor(context: ViewContext) { super(context); + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._widgets = {}; - this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth; - this._minimapWidth = this._context.configuration.editor.layoutInfo.minimapWidth; - this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight; - this._editorHeight = this._context.configuration.editor.layoutInfo.height; - this._editorWidth = this._context.configuration.editor.layoutInfo.width; + this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; + this._minimapWidth = layoutInfo.minimapWidth; + this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; + this._editorHeight = layoutInfo.height; + this._editorWidth = layoutInfo.width; this._domNode = createFastDomNode(document.createElement('div')); PartFingerprints.write(this._domNode, PartFingerprint.OverlayWidgets); @@ -59,12 +63,15 @@ export class ViewOverlayWidgets extends ViewPart { // ---- begin view event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.layoutInfo) { - this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth; - this._minimapWidth = this._context.configuration.editor.layoutInfo.minimapWidth; - this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight; - this._editorHeight = this._context.configuration.editor.layoutInfo.height; - this._editorWidth = this._context.configuration.editor.layoutInfo.width; + const options = this._context.configuration.options; + + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; + this._minimapWidth = layoutInfo.minimapWidth; + this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; + this._editorHeight = layoutInfo.height; + this._editorWidth = layoutInfo.width; return true; } return false; diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index c186568ad8f90..b620c0ed4ea85 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -15,6 +15,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ITheme } from 'vs/platform/theme/common/themeService'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; class Settings { @@ -42,6 +43,7 @@ class Settings { public readonly w: number[]; constructor(config: IConfiguration, theme: ITheme) { + const options = config.options; this.lineHeight = config.editor.lineHeight; this.pixelRatio = config.editor.pixelRatio; this.overviewRulerLanes = config.editor.viewInfo.overviewRulerLanes; @@ -56,8 +58,9 @@ class Settings { this.themeType = theme.type; - const minimapEnabled = config.editor.viewInfo.minimap.enabled; - const minimapSide = config.editor.viewInfo.minimap.side; + const minimapOpts = options.get(EditorOptionId.minimap); + const minimapEnabled = minimapOpts.enabled; + const minimapSide = minimapOpts.side; const backgroundColor = (minimapEnabled ? TokenizationRegistry.getDefaultBackground() : null); if (backgroundColor === null || minimapSide === 'left') { this.backgroundColor = null; @@ -65,7 +68,8 @@ class Settings { this.backgroundColor = Color.Format.CSS.formatHex(backgroundColor); } - const position = config.editor.layoutInfo.overviewRuler; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + const position = layoutInfo.overviewRuler; this.top = position.top; this.right = position.right; this.domWidth = position.width; diff --git a/src/vs/editor/browser/viewParts/rulers/rulers.ts b/src/vs/editor/browser/viewParts/rulers/rulers.ts index 7d4d402d24efb..ceb396185fd56 100644 --- a/src/vs/editor/browser/viewParts/rulers/rulers.ts +++ b/src/vs/editor/browser/viewParts/rulers/rulers.ts @@ -11,6 +11,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class Rulers extends ViewPart { @@ -37,7 +38,10 @@ export class Rulers extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.viewInfo || e.layoutInfo || e.fontInfo) { + if (e.viewInfo + || e.hasChanged(EditorOptionId.layoutInfo) + || e.fontInfo + ) { this._rulers = this._context.configuration.editor.viewInfo.rulers; this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; return true; diff --git a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts index 2ae336437e426..d3b4ae392cdd7 100644 --- a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts +++ b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts @@ -11,6 +11,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export class ScrollDecorationViewPart extends ViewPart { @@ -27,7 +28,9 @@ export class ScrollDecorationViewPart extends ViewPart { this._width = 0; this._updateWidth(); this._shouldShow = false; - this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows; + const options = this._context.configuration.options; + const scrollbar = options.get(EditorOptionId.scrollbar); + this._useShadows = scrollbar.useShadows; this._domNode = createFastDomNode(document.createElement('div')); this._domNode.setAttribute('role', 'presentation'); this._domNode.setAttribute('aria-hidden', 'true'); @@ -51,7 +54,8 @@ export class ScrollDecorationViewPart extends ViewPart { } private _updateWidth(): boolean { - const layoutInfo = this._context.configuration.editor.layoutInfo; + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); let newWidth = 0; if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) { newWidth = layoutInfo.width; @@ -69,10 +73,12 @@ export class ScrollDecorationViewPart extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { let shouldRender = false; - if (e.viewInfo) { - this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows; + if (e.hasChanged(EditorOptionId.scrollbar)) { + const options = this._context.configuration.options; + const scrollbar = options.get(EditorOptionId.scrollbar); + this._useShadows = scrollbar.useShadows; } - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { shouldRender = this._updateWidth(); } return this._updateShouldShow() || shouldRender; @@ -99,4 +105,4 @@ registerThemingParticipant((theme, collector) => { if (shadow) { collector.addRule(`.monaco-editor .scroll-decoration { box-shadow: ${shadow} 0 6px 6px -6px inset; }`); } -}); \ No newline at end of file +}); diff --git a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts index 6c01df4e0b6fc..3e0f58f547542 100644 --- a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts +++ b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts @@ -12,6 +12,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { IViewWhitespaceViewportData } from 'vs/editor/common/viewModel/viewModel'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IMyViewZone { whitespaceId: string; @@ -40,9 +41,12 @@ export class ViewZones extends ViewPart { constructor(context: ViewContext) { super(context); + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._lineHeight = this._context.configuration.editor.lineHeight; - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; + this._contentLeft = layoutInfo.contentLeft; this.domNode = createFastDomNode(document.createElement('div')); this.domNode.setClassName('view-zones'); @@ -84,15 +88,17 @@ export class ViewZones extends ViewPart { } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { + const options = this._context.configuration.options; if (e.lineHeight) { this._lineHeight = this._context.configuration.editor.lineHeight; return this._recomputeWhitespacesProps(); } - if (e.layoutInfo) { - this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth; - this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft; + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._contentWidth = layoutInfo.contentWidth; + this._contentLeft = layoutInfo.contentLeft; } return true; diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 3860def914f4b..ca2133d8ab22d 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -259,8 +259,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._register(this._configuration.onDidChange((e) => { this._onDidChangeConfiguration.fire(e); - if (e.layoutInfo) { - this._onDidLayoutChange.fire(this._configuration.editor.layoutInfo); + if (e.hasChanged(editorOptions.EditorOptionId.layoutInfo)) { + const options = this._configuration.options; + const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); + this._onDidLayoutChange.fire(layoutInfo); } if (this._configuration.editor.showUnused) { this._domElement.classList.add(SHOW_UNUSED_ENABLED_CLASS); @@ -370,8 +372,12 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE return this._configuration.editor; } + public getOptions(): editorOptions.IComputedEditorOptions { + return this._configuration.options; + } + public getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue { - return this._configuration.getOption(id); + return this._configuration.options.get(id); } public getRawConfiguration(): editorOptions.IEditorOptions { @@ -1124,7 +1130,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } public getLayoutInfo(): editorOptions.EditorLayoutInfo { - return this._configuration.editor.layoutInfo; + const options = this._configuration.options; + const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); + return layoutInfo; } public createOverviewRuler(cssClassName: string): editorBrowser.IOverviewRuler | null { @@ -1272,7 +1280,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } const position = this._modelData.model.validatePosition(rawPosition); - const layoutInfo = this._configuration.editor.layoutInfo; + const options = this._configuration.options; + const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); const top = CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, position.lineNumber, position.column) - this.getScrollTop(); const left = this._modelData.view.getOffsetForColumn(position.lineNumber, position.column) + layoutInfo.glyphMarginWidth + layoutInfo.lineNumbersWidth + layoutInfo.decorationsWidth - this.getScrollLeft(); diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index fa0e688d6962b..da9e1ddf553bb 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -1947,6 +1947,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { private readonly originalModel: ITextModel; private readonly modifiedEditorConfiguration: editorOptions.InternalEditorOptions; + private readonly modifiedEditorOptions: editorOptions.IComputedEditorOptions; private readonly modifiedEditorTabSize: number; private readonly renderIndicators: boolean; @@ -1954,6 +1955,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { super(lineChanges, originalForeignVZ, modifiedForeignVZ); this.originalModel = originalEditor.getModel()!; this.modifiedEditorConfiguration = modifiedEditor.getConfiguration(); + this.modifiedEditorOptions = modifiedEditor.getOptions(); this.modifiedEditorTabSize = modifiedEditor.getModel()!.getOptions().tabSize; this.renderIndicators = renderIndicators; } @@ -1993,7 +1995,9 @@ class InlineViewZonesComputer extends ViewZonesComputer { let sb = createStringBuilder(10000); let marginHTML: string[] = []; - let lineDecorationsWidth = this.modifiedEditorConfiguration.layoutInfo.decorationsWidth; + const layoutInfo = this.modifiedEditorOptions.get(editorOptions.EditorOptionId.layoutInfo); + const lineDecorationsWidth = layoutInfo.decorationsWidth; + let lineHeight = this.modifiedEditorConfiguration.lineHeight; const typicalHalfwidthCharacterWidth = this.modifiedEditorConfiguration.fontInfo.typicalHalfwidthCharacterWidth; let maxCharsPerLine = 0; diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index 037883dd53085..f6ab9ce2f141f 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -525,7 +525,9 @@ export class DiffReview extends Disposable { private _render(): void { const originalOpts = this._diffEditor.getOriginalEditor().getConfiguration(); + const originalOptions = this._diffEditor.getOriginalEditor().getOptions(); const modifiedOpts = this._diffEditor.getModifiedEditor().getConfiguration(); + const modifiedOptions = this._diffEditor.getModifiedEditor().getOptions(); const originalModel = this._diffEditor.getOriginalEditor().getModel(); const modifiedModel = this._diffEditor.getModifiedEditor().getModel(); @@ -620,7 +622,7 @@ export class DiffReview extends Disposable { let modLine = minModifiedLine; for (let i = 0, len = diffs.length; i < len; i++) { const diffEntry = diffs[i]; - DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOpts, originalModel, originalModelOpts, modifiedOpts, modifiedModel, modifiedModelOpts); + DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOpts, originalOptions, originalModel, originalModelOpts, modifiedOpts, modifiedOptions, modifiedModel, modifiedModelOpts); if (diffEntry.modifiedLineStart !== 0) { modLine = diffEntry.modifiedLineEnd; } @@ -633,8 +635,8 @@ export class DiffReview extends Disposable { private static _renderSection( dest: HTMLElement, diffEntry: DiffEntry, modLine: number, width: number, - originalOpts: editorOptions.InternalEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, - modifiedOpts: editorOptions.InternalEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions + originalOpts: editorOptions.InternalEditorOptions, originalOptions: editorOptions.IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, + modifiedOpts: editorOptions.InternalEditorOptions, modifiedOptions: editorOptions.IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions ): void { const type = diffEntry.getType(); @@ -665,8 +667,11 @@ export class DiffReview extends Disposable { originalLineEnd - originalLineStart ); - const originalLineNumbersWidth = originalOpts.layoutInfo.glyphMarginWidth + originalOpts.layoutInfo.lineNumbersWidth; - const modifiedLineNumbersWidth = 10 + modifiedOpts.layoutInfo.glyphMarginWidth + modifiedOpts.layoutInfo.lineNumbersWidth; + const originalLayoutInfo = originalOptions.get(editorOptions.EditorOptionId.layoutInfo); + const originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth; + + const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOptionId.layoutInfo); + const modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth; for (let i = 0; i <= cnt; i++) { const originalLine = (originalLineStart === 0 ? 0 : originalLineStart + i); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 10fff30099556..a5dc25319e20b 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -95,7 +95,7 @@ export class EditorConfiguration2 { // console.log(`computeOptions`, options, env); const result = new editorOptions.ComputedEditorOptions(); for (const editorOption of editorOptions.editorOptionsRegistry) { - result._write(editorOption.id, editorOption.compute(options._read(editorOption.id))); + result._write(editorOption.id, editorOption.compute(env, result, options._read(editorOption.id))); } return result; } @@ -105,9 +105,9 @@ export class EditorConfiguration2 { const result = new editorOptions.ChangedEditorOptions(); let somethingChanged = false; for (const editorOption of editorOptions.editorOptionsRegistry) { - const equals = editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); - result._write(editorOption.id, equals); - if (!equals) { + const changed = !editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); + result._write(editorOption.id, changed); + if (changed) { somethingChanged = true; } } @@ -115,6 +115,25 @@ export class EditorConfiguration2 { } } +/** + * Compatibility with old options + */ +function migrateOptions(options: editorOptions.IEditorOptions): void { + let wordWrap = options.wordWrap; + if (wordWrap === true) { + options.wordWrap = 'on'; + } else if (wordWrap === false) { + options.wordWrap = 'off'; + } + + let lineNumbers = options.lineNumbers; + if (lineNumbers === true) { + options.lineNumbers = 'on'; + } else if (lineNumbers === false) { + options.lineNumbers = 'off'; + } +} + export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { public readonly isSimpleWidget: boolean; @@ -133,6 +152,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed constructor(isSimpleWidget: boolean, options: editorOptions.IEditorOptions) { super(); + migrateOptions(options); this.isSimpleWidget = isSimpleWidget; @@ -156,10 +176,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions())); } - public getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue { - return this.options._read(id); - } - public observeReferenceElement(dimension?: editorCommon.IDimension): void { } @@ -255,6 +271,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed if (typeof newOptions === 'undefined') { return; } + migrateOptions(newOptions); if (CommonEditorConfiguration._subsetEquals(this._rawOptions, newOptions)) { return; } @@ -417,29 +434,29 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.minimap.enabled': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.minimap.enabled, + 'default': editorOptions.EditorOption.minimap.defaultValue.enabled, 'description': nls.localize('minimap.enabled', "Controls whether the minimap is shown.") }, 'editor.minimap.side': { 'type': 'string', 'enum': ['left', 'right'], - 'default': EDITOR_DEFAULTS.viewInfo.minimap.side, + 'default': editorOptions.EditorOption.minimap.defaultValue.side, 'description': nls.localize('minimap.side', "Controls the side where to render the minimap.") }, 'editor.minimap.showSlider': { 'type': 'string', 'enum': ['always', 'mouseover'], - 'default': EDITOR_DEFAULTS.viewInfo.minimap.showSlider, + 'default': editorOptions.EditorOption.minimap.defaultValue.showSlider, 'description': nls.localize('minimap.showSlider', "Controls whether the minimap slider is automatically hidden.") }, 'editor.minimap.renderCharacters': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.minimap.renderCharacters, + 'default': editorOptions.EditorOption.minimap.defaultValue.renderCharacters, 'description': nls.localize('minimap.renderCharacters', "Render the actual characters on a line as opposed to color blocks.") }, 'editor.minimap.maxColumn': { 'type': 'number', - 'default': EDITOR_DEFAULTS.viewInfo.minimap.maxColumn, + 'default': editorOptions.EditorOption.minimap.defaultValue.maxColumn, 'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.") }, 'editor.hover.enabled': { @@ -498,7 +515,7 @@ const editorConfiguration: IConfigurationNode = { ] }, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."), ], - 'default': EDITOR_DEFAULTS.wordWrap, + 'default': editorOptions.EditorOption.wordWrap.defaultValue, 'description': nls.localize({ key: 'wordWrap', comment: [ @@ -509,7 +526,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.wordWrapColumn': { 'type': 'integer', - 'default': EDITOR_DEFAULTS.wordWrapColumn, + 'default': editorOptions.EditorOption.wordWrapColumn.defaultValue, 'minimum': 1, 'markdownDescription': nls.localize({ key: 'wordWrapColumn', @@ -533,12 +550,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.mouseWheelScrollSensitivity': { 'type': 'number', - 'default': EDITOR_DEFAULTS.viewInfo.scrollbar.mouseWheelScrollSensitivity, + 'default': editorOptions.EditorOption.mouseWheelScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }, 'editor.fastScrollSensitivity': { 'type': 'number', - 'default': EDITOR_DEFAULTS.viewInfo.scrollbar.fastScrollSensitivity, + 'default': editorOptions.EditorOption.fastScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`.") }, 'editor.multiCursorModifier': { @@ -1035,7 +1052,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.folding': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.folding, + 'default': editorOptions.EditorOption.folding.defaultValue, 'description': nls.localize('folding', "Controls whether the editor has code folding enabled.") }, 'editor.foldingStrategy': { @@ -1088,7 +1105,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader."), nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."), ], - 'default': EDITOR_DEFAULTS.accessibilitySupport, + 'default': editorOptions.EditorOption.accessibilitySupport.defaultValue, 'description': nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers.") }, 'editor.showUnused': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 45bef3115da8e..dc915f4f80be0 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; +import * as assert from 'vs/base/common/assert'; import * as arrays from 'vs/base/common/arrays'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; @@ -272,7 +273,7 @@ export interface IEditorOptions { * Otherwise, line numbers will not be rendered. * Defaults to true. */ - lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + lineNumbers?: LineNumbersType; /** * Controls the minimal number of visible leading and trailing lines surrounding the cursor. * Defaults to 0. @@ -451,7 +452,7 @@ export interface IEditorOptions { * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'. * Defaults to 'same' in vscode and to 'none' in monaco-editor. */ - wrappingIndent?: string; + wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent'; /** * Configure word wrapping characters. A break will be introduced before these characters. * Defaults to '{([+'. @@ -727,6 +728,9 @@ export interface IEditorOptions { * Controls fading out of unused variables. */ showUnused?: boolean; + + layoutInfo?: undefined; + wrappingInfo?: undefined; } /** @@ -909,30 +913,6 @@ function _cursorStyleFromString(cursorStyle: string | undefined, defaultValue: T return TextEditorCursorStyle.Line; } -export interface InternalEditorScrollbarOptions { - readonly arrowSize: number; - readonly vertical: ScrollbarVisibility; - readonly horizontal: ScrollbarVisibility; - readonly useShadows: boolean; - readonly verticalHasArrows: boolean; - readonly horizontalHasArrows: boolean; - readonly handleMouseWheel: boolean; - readonly horizontalScrollbarSize: number; - readonly horizontalSliderSize: number; - readonly verticalScrollbarSize: number; - readonly verticalSliderSize: number; - readonly mouseWheelScrollSensitivity: number; - readonly fastScrollSensitivity: number; -} - -export interface InternalEditorMinimapOptions { - readonly enabled: boolean; - readonly side: 'right' | 'left'; - readonly showSlider: 'always' | 'mouseover'; - readonly renderCharacters: boolean; - readonly maxColumn: number; -} - export interface InternalEditorFindOptions { readonly seedSearchStringFromSelection: boolean; readonly autoFindInSelection: boolean; @@ -969,33 +949,10 @@ export interface InternalParameterHintOptions { readonly cycle: boolean; } -export interface EditorWrappingInfo { - readonly inDiffEditor: boolean; - readonly isDominatedByLongLines: boolean; - readonly isWordWrapMinified: boolean; - readonly isViewportWrapping: boolean; - readonly wrappingColumn: number; - readonly wrappingIndent: WrappingIndent; - readonly wordWrapBreakBeforeCharacters: string; - readonly wordWrapBreakAfterCharacters: string; - readonly wordWrapBreakObtrusiveCharacters: string; -} - -export const enum RenderLineNumbersType { - Off = 0, - On = 1, - Relative = 2, - Interval = 3, - Custom = 4 -} - export interface InternalEditorViewOptions { readonly extraEditorClassName: string; readonly disableMonospaceOptimizations: boolean; readonly rulers: number[]; - readonly ariaLabel: string; - readonly renderLineNumbers: RenderLineNumbersType; - readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -1018,8 +975,6 @@ export interface InternalEditorViewOptions { readonly renderIndentGuides: boolean; readonly highlightActiveIndentGuide: boolean; readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly scrollbar: InternalEditorScrollbarOptions; - readonly minimap: InternalEditorMinimapOptions; readonly fixedOverflowWidgets: boolean; } @@ -1045,7 +1000,6 @@ export interface EditorContribOptions { readonly selectionHighlight: boolean; readonly occurrencesHighlight: boolean; readonly codeLens: boolean; - readonly folding: boolean; readonly foldingStrategy: 'auto' | 'indentation'; readonly showFoldingControls: 'always' | 'mouseover'; readonly matchBrackets: boolean; @@ -1062,21 +1016,12 @@ export interface EditorContribOptions { * @internal */ export interface IValidatedEditorOptions { - readonly inDiffEditor: boolean; readonly wordSeparators: string; - readonly lineNumbersMinChars: number; readonly lineDecorationsWidth: number | string; readonly readOnly: boolean; readonly mouseStyle: 'text' | 'default' | 'copy'; readonly disableLayerHinting: boolean; readonly automaticLayout: boolean; - readonly wordWrap: 'off' | 'on' | 'wordWrapColumn' | 'bounded'; - readonly wordWrapColumn: number; - readonly wordWrapMinified: boolean; - readonly wrappingIndent: WrappingIndent; - readonly wordWrapBreakBeforeCharacters: string; - readonly wordWrapBreakAfterCharacters: string; - readonly wordWrapBreakObtrusiveCharacters: string; readonly autoClosingBrackets: EditorAutoClosingStrategy; readonly autoClosingQuotes: EditorAutoClosingStrategy; readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy; @@ -1088,7 +1033,6 @@ export interface IValidatedEditorOptions { readonly useTabStops: boolean; readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; readonly multiCursorMergeOverlapping: boolean; - readonly accessibilitySupport: 'auto' | 'off' | 'on'; readonly showUnused: boolean; readonly viewInfo: InternalEditorViewOptions; @@ -1128,10 +1072,8 @@ export class InternalEditorOptions { readonly copyWithSyntaxHighlighting: boolean; // ---- grouped options - readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; - readonly wrappingInfo: EditorWrappingInfo; readonly contribInfo: EditorContribOptions; /** @@ -1143,7 +1085,6 @@ export class InternalEditorOptions { editorClassName: string; lineHeight: number; readOnly: boolean; - accessibilitySupport: AccessibilitySupport; multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; multiCursorMergeOverlapping: boolean; wordSeparators: string; @@ -1157,10 +1098,8 @@ export class InternalEditorOptions { dragAndDrop: boolean; emptySelectionClipboard: boolean; copyWithSyntaxHighlighting: boolean; - layoutInfo: EditorLayoutInfo; fontInfo: FontInfo; viewInfo: InternalEditorViewOptions; - wrappingInfo: EditorWrappingInfo; contribInfo: EditorContribOptions; showUnused: boolean; }) { @@ -1169,7 +1108,6 @@ export class InternalEditorOptions { this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight | 0; this.readOnly = source.readOnly; - this.accessibilitySupport = source.accessibilitySupport; this.multiCursorModifier = source.multiCursorModifier; this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping; this.wordSeparators = source.wordSeparators; @@ -1183,10 +1121,8 @@ export class InternalEditorOptions { this.dragAndDrop = source.dragAndDrop; this.emptySelectionClipboard = source.emptySelectionClipboard; this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; - this.layoutInfo = source.layoutInfo; this.fontInfo = source.fontInfo; this.viewInfo = source.viewInfo; - this.wrappingInfo = source.wrappingInfo; this.contribInfo = source.contribInfo; this.showUnused = source.showUnused; } @@ -1201,7 +1137,6 @@ export class InternalEditorOptions { && this.editorClassName === other.editorClassName && this.lineHeight === other.lineHeight && this.readOnly === other.readOnly - && this.accessibilitySupport === other.accessibilitySupport && this.multiCursorModifier === other.multiCursorModifier && this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping && this.wordSeparators === other.wordSeparators @@ -1216,10 +1151,8 @@ export class InternalEditorOptions { && this.showUnused === other.showUnused && this.emptySelectionClipboard === other.emptySelectionClipboard && this.copyWithSyntaxHighlighting === other.copyWithSyntaxHighlighting - && InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, other.layoutInfo) && this.fontInfo.equals(other.fontInfo) && InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo) - && InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, other.wrappingInfo) && InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo) ); } @@ -1240,7 +1173,6 @@ export class InternalEditorOptions { editorClassName: (this.editorClassName !== newOpts.editorClassName), lineHeight: (this.lineHeight !== newOpts.lineHeight), readOnly: (this.readOnly !== newOpts.readOnly), - accessibilitySupport: (this.accessibilitySupport !== newOpts.accessibilitySupport), multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier), multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping), wordSeparators: (this.wordSeparators !== newOpts.wordSeparators), @@ -1254,55 +1186,12 @@ export class InternalEditorOptions { dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop), emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard), copyWithSyntaxHighlighting: (this.copyWithSyntaxHighlighting !== newOpts.copyWithSyntaxHighlighting), - layoutInfo: (!InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, newOpts.layoutInfo)), fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)), - wrappingInfo: (!InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, newOpts.wrappingInfo)), contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo)) }; } - /** - * @internal - */ - private static _equalsLayoutInfo(a: EditorLayoutInfo, b: EditorLayoutInfo): boolean { - return ( - a.width === b.width - && a.height === b.height - && a.glyphMarginLeft === b.glyphMarginLeft - && a.glyphMarginWidth === b.glyphMarginWidth - && a.glyphMarginHeight === b.glyphMarginHeight - && a.lineNumbersLeft === b.lineNumbersLeft - && a.lineNumbersWidth === b.lineNumbersWidth - && a.lineNumbersHeight === b.lineNumbersHeight - && a.decorationsLeft === b.decorationsLeft - && a.decorationsWidth === b.decorationsWidth - && a.decorationsHeight === b.decorationsHeight - && a.contentLeft === b.contentLeft - && a.contentWidth === b.contentWidth - && a.contentHeight === b.contentHeight - && a.renderMinimap === b.renderMinimap - && a.minimapLeft === b.minimapLeft - && a.minimapWidth === b.minimapWidth - && a.viewportColumn === b.viewportColumn - && a.verticalScrollbarWidth === b.verticalScrollbarWidth - && a.horizontalScrollbarHeight === b.horizontalScrollbarHeight - && this._equalsOverviewRuler(a.overviewRuler, b.overviewRuler) - ); - } - - /** - * @internal - */ - private static _equalsOverviewRuler(a: OverviewRulerPosition, b: OverviewRulerPosition): boolean { - return ( - a.width === b.width - && a.height === b.height - && a.top === b.top - && a.right === b.right - ); - } - /** * @internal */ @@ -1311,9 +1200,6 @@ export class InternalEditorOptions { a.extraEditorClassName === b.extraEditorClassName && a.disableMonospaceOptimizations === b.disableMonospaceOptimizations && arrays.equals(a.rulers, b.rulers) - && a.ariaLabel === b.ariaLabel - && a.renderLineNumbers === b.renderLineNumbers - && a.renderCustomLineNumbers === b.renderCustomLineNumbers && a.cursorSurroundingLines === b.cursorSurroundingLines && a.glyphMargin === b.glyphMargin && a.revealHorizontalRightPadding === b.revealHorizontalRightPadding @@ -1336,46 +1222,10 @@ export class InternalEditorOptions { && a.renderIndentGuides === b.renderIndentGuides && a.highlightActiveIndentGuide === b.highlightActiveIndentGuide && a.renderLineHighlight === b.renderLineHighlight - && this._equalsScrollbarOptions(a.scrollbar, b.scrollbar) - && this._equalsMinimapOptions(a.minimap, b.minimap) && a.fixedOverflowWidgets === b.fixedOverflowWidgets ); } - /** - * @internal - */ - private static _equalsScrollbarOptions(a: InternalEditorScrollbarOptions, b: InternalEditorScrollbarOptions): boolean { - return ( - a.arrowSize === b.arrowSize - && a.vertical === b.vertical - && a.horizontal === b.horizontal - && a.useShadows === b.useShadows - && a.verticalHasArrows === b.verticalHasArrows - && a.horizontalHasArrows === b.horizontalHasArrows - && a.handleMouseWheel === b.handleMouseWheel - && a.horizontalScrollbarSize === b.horizontalScrollbarSize - && a.horizontalSliderSize === b.horizontalSliderSize - && a.verticalScrollbarSize === b.verticalScrollbarSize - && a.verticalSliderSize === b.verticalSliderSize - && a.mouseWheelScrollSensitivity === b.mouseWheelScrollSensitivity - && a.fastScrollSensitivity === b.fastScrollSensitivity - ); - } - - /** - * @internal - */ - private static _equalsMinimapOptions(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean { - return ( - a.enabled === b.enabled - && a.side === b.side - && a.showSlider === b.showSlider - && a.renderCharacters === b.renderCharacters - && a.maxColumn === b.maxColumn - ); - } - /** * @internal */ @@ -1439,23 +1289,6 @@ export class InternalEditorOptions { } } - /** - * @internal - */ - private static _equalsWrappingInfo(a: EditorWrappingInfo, b: EditorWrappingInfo): boolean { - return ( - a.inDiffEditor === b.inDiffEditor - && a.isDominatedByLongLines === b.isDominatedByLongLines - && a.isWordWrapMinified === b.isWordWrapMinified - && a.isViewportWrapping === b.isViewportWrapping - && a.wrappingColumn === b.wrappingColumn - && a.wrappingIndent === b.wrappingIndent - && a.wordWrapBreakBeforeCharacters === b.wordWrapBreakBeforeCharacters - && a.wordWrapBreakAfterCharacters === b.wordWrapBreakAfterCharacters - && a.wordWrapBreakObtrusiveCharacters === b.wordWrapBreakObtrusiveCharacters - ); - } - /** * @internal */ @@ -1482,7 +1315,6 @@ export class InternalEditorOptions { && a.selectionHighlight === b.selectionHighlight && a.occurrencesHighlight === b.occurrencesHighlight && a.codeLens === b.codeLens - && a.folding === b.folding && a.foldingStrategy === b.foldingStrategy && a.showFoldingControls === b.showFoldingControls && a.matchBrackets === b.matchBrackets @@ -1512,128 +1344,6 @@ export class InternalEditorOptions { } } -/** - * A description for the overview ruler position. - */ -export interface OverviewRulerPosition { - /** - * Width of the overview ruler - */ - readonly width: number; - /** - * Height of the overview ruler - */ - readonly height: number; - /** - * Top position for the overview ruler - */ - readonly top: number; - /** - * Right position for the overview ruler - */ - readonly right: number; -} - -/** - * The internal layout details of the editor. - */ -export interface EditorLayoutInfo { - - /** - * Full editor width. - */ - readonly width: number; - /** - * Full editor height. - */ - readonly height: number; - - /** - * Left position for the glyph margin. - */ - readonly glyphMarginLeft: number; - /** - * The width of the glyph margin. - */ - readonly glyphMarginWidth: number; - /** - * The height of the glyph margin. - */ - readonly glyphMarginHeight: number; - - /** - * Left position for the line numbers. - */ - readonly lineNumbersLeft: number; - /** - * The width of the line numbers. - */ - readonly lineNumbersWidth: number; - /** - * The height of the line numbers. - */ - readonly lineNumbersHeight: number; - - /** - * Left position for the line decorations. - */ - readonly decorationsLeft: number; - /** - * The width of the line decorations. - */ - readonly decorationsWidth: number; - /** - * The height of the line decorations. - */ - readonly decorationsHeight: number; - - /** - * Left position for the content (actual text) - */ - readonly contentLeft: number; - /** - * The width of the content (actual text) - */ - readonly contentWidth: number; - /** - * The height of the content (actual height) - */ - readonly contentHeight: number; - - /** - * The position for the minimap - */ - readonly minimapLeft: number; - /** - * The width of the minimap - */ - readonly minimapWidth: number; - - /** - * Minimap render type - */ - readonly renderMinimap: RenderMinimap; - - /** - * The number of columns (of typical characters) fitting on a viewport line. - */ - readonly viewportColumn: number; - - /** - * The width of the vertical scrollbar. - */ - readonly verticalScrollbarWidth: number; - /** - * The height of the horizontal scrollbar. - */ - readonly horizontalScrollbarHeight: number; - - /** - * The position of the overview ruler. - */ - readonly overviewRuler: OverviewRulerPosition; -} - /** * An event describing that the configuration of the editor has changed. */ @@ -1644,7 +1354,6 @@ export interface IConfigurationChangedEvent { readonly editorClassName: boolean; readonly lineHeight: boolean; readonly readOnly: boolean; - readonly accessibilitySupport: boolean; readonly multiCursorModifier: boolean; readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; @@ -1658,16 +1367,11 @@ export interface IConfigurationChangedEvent { readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; - readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: boolean; - readonly wrappingInfo: boolean; readonly contribInfo: boolean; } -/** - * @internal - */ export interface IEnvironmentalOptions { readonly outerWidth: number; readonly outerHeight: number; @@ -1747,18 +1451,12 @@ function _float(value: any, defaultValue: number): number { return r; } -function _wrappingIndentFromString(wrappingIndent: string | undefined, defaultValue: WrappingIndent): WrappingIndent { - if (typeof wrappingIndent !== 'string') { - return defaultValue; - } - if (wrappingIndent === 'same') { - return WrappingIndent.Same; - } else if (wrappingIndent === 'indent') { - return WrappingIndent.Indent; - } else if (wrappingIndent === 'deepIndent') { - return WrappingIndent.DeepIndent; - } else { - return WrappingIndent.None; +function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent { + switch (wrappingIndent) { + case 'none': return WrappingIndent.None; + case 'same': return WrappingIndent.Same; + case 'indent': return WrappingIndent.Indent; + case 'deepIndent': return WrappingIndent.DeepIndent; } } @@ -1806,18 +1504,6 @@ export class EditorOptionsValidator { * i.e. since they can be defined by the user, they might be invalid. */ public static validate(opts: IEditorOptions, defaults: IValidatedEditorOptions): IValidatedEditorOptions { - let wordWrap = opts.wordWrap; - { - // Compatibility with old true or false values - if (wordWrap === true) { - wordWrap = 'on'; - } else if (wordWrap === false) { - wordWrap = 'off'; - } - - wordWrap = _stringSet<'off' | 'on' | 'wordWrapColumn' | 'bounded'>(wordWrap, defaults.wordWrap, ['off', 'on', 'wordWrapColumn', 'bounded']); - } - const viewInfo = this._sanitizeViewInfo(opts, defaults.viewInfo); const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo); @@ -1846,21 +1532,12 @@ export class EditorOptionsValidator { } return { - inDiffEditor: _boolean(opts.inDiffEditor, defaults.inDiffEditor), wordSeparators: _string(opts.wordSeparators, defaults.wordSeparators), - lineNumbersMinChars: _clampedInt(opts.lineNumbersMinChars, defaults.lineNumbersMinChars, 1, 10), lineDecorationsWidth: (typeof opts.lineDecorationsWidth === 'undefined' ? defaults.lineDecorationsWidth : opts.lineDecorationsWidth), readOnly: _boolean(opts.readOnly, defaults.readOnly), mouseStyle: _stringSet<'text' | 'default' | 'copy'>(opts.mouseStyle, defaults.mouseStyle, ['text', 'default', 'copy']), disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting), automaticLayout: _boolean(opts.automaticLayout, defaults.automaticLayout), - wordWrap: wordWrap, - wordWrapColumn: _clampedInt(opts.wordWrapColumn, defaults.wordWrapColumn, 1, Constants.MAX_SAFE_SMALL_INTEGER), - wordWrapMinified: _boolean(opts.wordWrapMinified, defaults.wordWrapMinified), - wrappingIndent: _wrappingIndentFromString(opts.wrappingIndent, defaults.wrappingIndent), - wordWrapBreakBeforeCharacters: _string(opts.wordWrapBreakBeforeCharacters, defaults.wordWrapBreakBeforeCharacters), - wordWrapBreakAfterCharacters: _string(opts.wordWrapBreakAfterCharacters, defaults.wordWrapBreakAfterCharacters), - wordWrapBreakObtrusiveCharacters: _string(opts.wordWrapBreakObtrusiveCharacters, defaults.wordWrapBreakObtrusiveCharacters), autoClosingBrackets, autoClosingQuotes, autoClosingOvertype: _stringSet(opts.autoClosingOvertype, defaults.autoClosingOvertype, ['always', 'auto', 'never']), @@ -1872,55 +1549,13 @@ export class EditorOptionsValidator { useTabStops: _boolean(opts.useTabStops, defaults.useTabStops), multiCursorModifier: multiCursorModifier, multiCursorMergeOverlapping: _boolean(opts.multiCursorMergeOverlapping, defaults.multiCursorMergeOverlapping), - accessibilitySupport: _stringSet<'auto' | 'on' | 'off'>(opts.accessibilitySupport, defaults.accessibilitySupport, ['auto', 'on', 'off']), showUnused: _boolean(opts.showUnused, defaults.showUnused), viewInfo: viewInfo, contribInfo: contribInfo, }; } - private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions | undefined, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number, fastScrollSensitivity: number): InternalEditorScrollbarOptions { - if (typeof opts !== 'object') { - return defaults; - } - const horizontalScrollbarSize = _clampedInt(opts.horizontalScrollbarSize, defaults.horizontalScrollbarSize, 0, 1000); - const verticalScrollbarSize = _clampedInt(opts.verticalScrollbarSize, defaults.verticalScrollbarSize, 0, 1000); - return { - vertical: _scrollbarVisibilityFromString(opts.vertical, defaults.vertical), - horizontal: _scrollbarVisibilityFromString(opts.horizontal, defaults.horizontal), - - arrowSize: _clampedInt(opts.arrowSize, defaults.arrowSize, 0, 1000), - useShadows: _boolean(opts.useShadows, defaults.useShadows), - - verticalHasArrows: _boolean(opts.verticalHasArrows, defaults.verticalHasArrows), - horizontalHasArrows: _boolean(opts.horizontalHasArrows, defaults.horizontalHasArrows), - - horizontalScrollbarSize: horizontalScrollbarSize, - horizontalSliderSize: _clampedInt(opts.horizontalSliderSize, horizontalScrollbarSize, 0, 1000), - - verticalScrollbarSize: verticalScrollbarSize, - verticalSliderSize: _clampedInt(opts.verticalSliderSize, verticalScrollbarSize, 0, 1000), - - handleMouseWheel: _boolean(opts.handleMouseWheel, defaults.handleMouseWheel), - mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, - fastScrollSensitivity: fastScrollSensitivity, - }; - } - - private static _sanitizeMinimapOpts(opts: IEditorMinimapOptions | undefined, defaults: InternalEditorMinimapOptions): InternalEditorMinimapOptions { - if (typeof opts !== 'object') { - return defaults; - } - return { - enabled: _boolean(opts.enabled, defaults.enabled), - side: _stringSet<'right' | 'left'>(opts.side, defaults.side, ['right', 'left']), - showSlider: _stringSet<'always' | 'mouseover'>(opts.showSlider, defaults.showSlider, ['always', 'mouseover']), - renderCharacters: _boolean(opts.renderCharacters, defaults.renderCharacters), - maxColumn: _clampedInt(opts.maxColumn, defaults.maxColumn, 1, 10000), - }; - } - - private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions { + private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions { if (typeof opts !== 'object') { return defaults; } @@ -2004,33 +1639,6 @@ export class EditorOptionsValidator { rulers.sort(); } - let renderLineNumbers: RenderLineNumbersType = defaults.renderLineNumbers; - let renderCustomLineNumbers: ((lineNumber: number) => string) | null = defaults.renderCustomLineNumbers; - - if (typeof opts.lineNumbers !== 'undefined') { - let lineNumbers = opts.lineNumbers; - - // Compatibility with old true or false values - if (lineNumbers === true) { - lineNumbers = 'on'; - } else if (lineNumbers === false) { - lineNumbers = 'off'; - } - - if (typeof lineNumbers === 'function') { - renderLineNumbers = RenderLineNumbersType.Custom; - renderCustomLineNumbers = lineNumbers; - } else if (lineNumbers === 'interval') { - renderLineNumbers = RenderLineNumbersType.Interval; - } else if (lineNumbers === 'relative') { - renderLineNumbers = RenderLineNumbersType.Relative; - } else if (lineNumbers === 'on') { - renderLineNumbers = RenderLineNumbersType.On; - } else { - renderLineNumbers = RenderLineNumbersType.Off; - } - } - const fontLigatures = _boolean(opts.fontLigatures, defaults.fontLigatures); const disableMonospaceOptimizations = _boolean(opts.disableMonospaceOptimizations, defaults.disableMonospaceOptimizations) || fontLigatures; @@ -2056,27 +1664,11 @@ export class EditorOptionsValidator { renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']); } - let mouseWheelScrollSensitivity = _float(opts.mouseWheelScrollSensitivity, defaults.scrollbar.mouseWheelScrollSensitivity); - if (mouseWheelScrollSensitivity === 0) { - // Disallow 0, as it would prevent/block scrolling - mouseWheelScrollSensitivity = 1; - } - - let fastScrollSensitivity = _float(opts.fastScrollSensitivity, defaults.scrollbar.fastScrollSensitivity); - if (fastScrollSensitivity <= 0) { - fastScrollSensitivity = defaults.scrollbar.fastScrollSensitivity; - } - const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity, fastScrollSensitivity); - const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap); - return { extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName), disableMonospaceOptimizations: disableMonospaceOptimizations, rulers: rulers, - ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel), cursorSurroundingLines: _clampedInt(opts.cursorSurroundingLines, defaults.cursorWidth, 0, Number.MAX_VALUE), - renderLineNumbers: renderLineNumbers, - renderCustomLineNumbers: renderCustomLineNumbers, glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin), revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000), roundedSelection: _boolean(opts.roundedSelection, defaults.roundedSelection), @@ -2098,8 +1690,6 @@ export class EditorOptionsValidator { renderIndentGuides: _boolean(opts.renderIndentGuides, defaults.renderIndentGuides), highlightActiveIndentGuide: _boolean(opts.highlightActiveIndentGuide, defaults.highlightActiveIndentGuide), renderLineHighlight: renderLineHighlight, - scrollbar: scrollbar, - minimap: minimap, fixedOverflowWidgets: _boolean(opts.fixedOverflowWidgets, defaults.fixedOverflowWidgets), }; } @@ -2138,7 +1728,6 @@ export class EditorOptionsValidator { selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight), occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight), codeLens: _boolean(opts.codeLens, defaults.codeLens), - folding: _boolean(opts.folding, defaults.folding), foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']), showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']), matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets), @@ -2156,223 +1745,7 @@ export class EditorOptionsValidator { */ export class InternalEditorOptionsFactory { - private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: AccessibilitySupport): IValidatedEditorOptions { - const accessibilityIsOff = (accessibilitySupport === AccessibilitySupport.Disabled); - return { - inDiffEditor: opts.inDiffEditor, - wordSeparators: opts.wordSeparators, - lineNumbersMinChars: opts.lineNumbersMinChars, - lineDecorationsWidth: opts.lineDecorationsWidth, - readOnly: opts.readOnly, - mouseStyle: opts.mouseStyle, - disableLayerHinting: opts.disableLayerHinting, - automaticLayout: opts.automaticLayout, - wordWrap: opts.wordWrap, - wordWrapColumn: opts.wordWrapColumn, - wordWrapMinified: opts.wordWrapMinified, - wrappingIndent: opts.wrappingIndent, - wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters, - wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters, - wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters, - autoClosingBrackets: opts.autoClosingBrackets, - autoClosingQuotes: opts.autoClosingQuotes, - autoClosingOvertype: opts.autoClosingOvertype, - autoSurround: opts.autoSurround, - autoIndent: opts.autoIndent, - dragAndDrop: opts.dragAndDrop, - emptySelectionClipboard: opts.emptySelectionClipboard, - copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting, - useTabStops: opts.useTabStops, - multiCursorModifier: opts.multiCursorModifier, - multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping, - accessibilitySupport: opts.accessibilitySupport, - showUnused: opts.showUnused, - - viewInfo: { - extraEditorClassName: opts.viewInfo.extraEditorClassName, - disableMonospaceOptimizations: opts.viewInfo.disableMonospaceOptimizations, - rulers: opts.viewInfo.rulers, - ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel), - renderLineNumbers: opts.viewInfo.renderLineNumbers, - renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers, - cursorSurroundingLines: opts.viewInfo.cursorSurroundingLines, - glyphMargin: opts.viewInfo.glyphMargin, - revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding, - roundedSelection: opts.viewInfo.roundedSelection, - overviewRulerLanes: opts.viewInfo.overviewRulerLanes, - overviewRulerBorder: opts.viewInfo.overviewRulerBorder, - cursorBlinking: opts.viewInfo.cursorBlinking, - mouseWheelZoom: opts.viewInfo.mouseWheelZoom, - cursorSmoothCaretAnimation: opts.viewInfo.cursorSmoothCaretAnimation, - cursorStyle: opts.viewInfo.cursorStyle, - cursorWidth: opts.viewInfo.cursorWidth, - hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler, - scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine, - scrollBeyondLastColumn: opts.viewInfo.scrollBeyondLastColumn, - smoothScrolling: opts.viewInfo.smoothScrolling, - stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter, - renderWhitespace: opts.viewInfo.renderWhitespace, - renderControlCharacters: opts.viewInfo.renderControlCharacters, - fontLigatures: opts.viewInfo.fontLigatures, - renderIndentGuides: opts.viewInfo.renderIndentGuides, - highlightActiveIndentGuide: opts.viewInfo.highlightActiveIndentGuide, - renderLineHighlight: opts.viewInfo.renderLineHighlight, - scrollbar: opts.viewInfo.scrollbar, - minimap: { - enabled: opts.viewInfo.minimap.enabled, - side: opts.viewInfo.minimap.side, - renderCharacters: opts.viewInfo.minimap.renderCharacters, - showSlider: opts.viewInfo.minimap.showSlider, - maxColumn: opts.viewInfo.minimap.maxColumn - }, - fixedOverflowWidgets: opts.viewInfo.fixedOverflowWidgets - }, - - contribInfo: { - hover: opts.contribInfo.hover, - links: opts.contribInfo.links, - contextmenu: opts.contribInfo.contextmenu, - quickSuggestions: opts.contribInfo.quickSuggestions, - quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay, - parameterHints: opts.contribInfo.parameterHints, - formatOnType: opts.contribInfo.formatOnType, - formatOnPaste: opts.contribInfo.formatOnPaste, - suggestOnTriggerCharacters: opts.contribInfo.suggestOnTriggerCharacters, - acceptSuggestionOnEnter: opts.contribInfo.acceptSuggestionOnEnter, - acceptSuggestionOnCommitCharacter: opts.contribInfo.acceptSuggestionOnCommitCharacter, - wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions, - suggestSelection: opts.contribInfo.suggestSelection, - suggestFontSize: opts.contribInfo.suggestFontSize, - suggestLineHeight: opts.contribInfo.suggestLineHeight, - tabCompletion: opts.contribInfo.tabCompletion, - suggest: opts.contribInfo.suggest, - gotoLocation: opts.contribInfo.gotoLocation, - selectionHighlight: opts.contribInfo.selectionHighlight, - occurrencesHighlight: opts.contribInfo.occurrencesHighlight, - codeLens: opts.contribInfo.codeLens, - folding: opts.contribInfo.folding, - foldingStrategy: opts.contribInfo.foldingStrategy, - showFoldingControls: opts.contribInfo.showFoldingControls, - matchBrackets: opts.contribInfo.matchBrackets, - find: opts.contribInfo.find, - colorDecorators: opts.contribInfo.colorDecorators, - lightbulbEnabled: opts.contribInfo.lightbulbEnabled, - codeActionsOnSave: opts.contribInfo.codeActionsOnSave, - codeActionsOnSaveTimeout: opts.contribInfo.codeActionsOnSaveTimeout - } - }; - } - - public static createInternalEditorOptions(env: IEnvironmentalOptions, _opts: IValidatedEditorOptions) { - - let accessibilitySupport: AccessibilitySupport; - if (_opts.accessibilitySupport === 'auto') { - // The editor reads the `accessibilitySupport` from the environment - accessibilitySupport = env.accessibilitySupport; - } else if (_opts.accessibilitySupport === 'on') { - accessibilitySupport = AccessibilitySupport.Enabled; - } else { - accessibilitySupport = AccessibilitySupport.Disabled; - } - - // Disable some non critical features to get as best performance as possible - // See https://github.com/Microsoft/vscode/issues/26730 - const opts = this._tweakValidatedOptions(_opts, accessibilitySupport); - - let lineDecorationsWidth: number; - if (typeof opts.lineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(opts.lineDecorationsWidth)) { - const multiple = parseFloat(opts.lineDecorationsWidth.substr(0, opts.lineDecorationsWidth.length - 2)); - lineDecorationsWidth = multiple * env.fontInfo.typicalHalfwidthCharacterWidth; - } else { - lineDecorationsWidth = _clampedInt(opts.lineDecorationsWidth, 0, 0, 1000); - } - if (opts.contribInfo.folding) { - lineDecorationsWidth += 16; - } - - const layoutInfo = EditorLayoutProvider.compute({ - outerWidth: env.outerWidth, - outerHeight: env.outerHeight, - showGlyphMargin: opts.viewInfo.glyphMargin, - lineHeight: env.fontInfo.lineHeight, - showLineNumbers: (opts.viewInfo.renderLineNumbers !== RenderLineNumbersType.Off), - lineNumbersMinChars: opts.lineNumbersMinChars, - lineNumbersDigitCount: env.lineNumbersDigitCount, - lineDecorationsWidth: lineDecorationsWidth, - typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth, - maxDigitWidth: env.fontInfo.maxDigitWidth, - verticalScrollbarWidth: opts.viewInfo.scrollbar.verticalScrollbarSize, - horizontalScrollbarHeight: opts.viewInfo.scrollbar.horizontalScrollbarSize, - scrollbarArrowSize: opts.viewInfo.scrollbar.arrowSize, - verticalScrollbarHasArrows: opts.viewInfo.scrollbar.verticalHasArrows, - minimap: opts.viewInfo.minimap.enabled, - minimapSide: opts.viewInfo.minimap.side, - minimapRenderCharacters: opts.viewInfo.minimap.renderCharacters, - minimapMaxColumn: opts.viewInfo.minimap.maxColumn, - pixelRatio: env.pixelRatio - }); - - let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null; - { - const wordWrap = opts.wordWrap; - const wordWrapColumn = opts.wordWrapColumn; - const wordWrapMinified = opts.wordWrapMinified; - - if (accessibilitySupport === AccessibilitySupport.Enabled) { - // See https://github.com/Microsoft/vscode/issues/27766 - // Never enable wrapping when a screen reader is attached - // because arrow down etc. will not move the cursor in the way - // a screen reader expects. - bareWrappingInfo = { - isWordWrapMinified: false, - isViewportWrapping: false, - wrappingColumn: -1 - }; - } else if (wordWrapMinified && env.isDominatedByLongLines) { - // Force viewport width wrapping if model is dominated by long lines - bareWrappingInfo = { - isWordWrapMinified: true, - isViewportWrapping: true, - wrappingColumn: Math.max(1, layoutInfo.viewportColumn) - }; - } else if (wordWrap === 'on') { - bareWrappingInfo = { - isWordWrapMinified: false, - isViewportWrapping: true, - wrappingColumn: Math.max(1, layoutInfo.viewportColumn) - }; - } else if (wordWrap === 'bounded') { - bareWrappingInfo = { - isWordWrapMinified: false, - isViewportWrapping: true, - wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn) - }; - } else if (wordWrap === 'wordWrapColumn') { - bareWrappingInfo = { - isWordWrapMinified: false, - isViewportWrapping: false, - wrappingColumn: wordWrapColumn - }; - } else { - bareWrappingInfo = { - isWordWrapMinified: false, - isViewportWrapping: false, - wrappingColumn: -1 - }; - } - } - - const wrappingInfo: EditorWrappingInfo = { - inDiffEditor: opts.inDiffEditor, - isDominatedByLongLines: env.isDominatedByLongLines, - isWordWrapMinified: bareWrappingInfo.isWordWrapMinified, - isViewportWrapping: bareWrappingInfo.isViewportWrapping, - wrappingColumn: bareWrappingInfo.wrappingColumn, - wrappingIndent: opts.wrappingIndent, - wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters, - wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters, - wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters, - }; + public static createInternalEditorOptions(env: IEnvironmentalOptions, opts: IValidatedEditorOptions) { let className = 'monaco-editor'; if (opts.viewInfo.extraEditorClassName) { @@ -2396,7 +1769,6 @@ export class InternalEditorOptionsFactory { editorClassName: className, lineHeight: env.fontInfo.lineHeight, readOnly: opts.readOnly, - accessibilitySupport: accessibilitySupport, multiCursorModifier: opts.multiCursorModifier, multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping, wordSeparators: opts.wordSeparators, @@ -2410,10 +1782,8 @@ export class InternalEditorOptionsFactory { dragAndDrop: opts.dragAndDrop, emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard, copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting, - layoutInfo: layoutInfo, fontInfo: env.fontInfo, viewInfo: opts.viewInfo, - wrappingInfo: wrappingInfo, contribInfo: opts.contribInfo, showUnused: opts.showUnused, }); @@ -2451,260 +1821,88 @@ export interface IEditorLayoutProviderOpts { readonly pixelRatio: number; } +const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace'; +const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace'; +const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\''; + /** * @internal */ -export class EditorLayoutProvider { - public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo { - const outerWidth = _opts.outerWidth | 0; - const outerHeight = _opts.outerHeight | 0; - const showGlyphMargin = _opts.showGlyphMargin; - const lineHeight = _opts.lineHeight | 0; - const showLineNumbers = _opts.showLineNumbers; - const lineNumbersMinChars = _opts.lineNumbersMinChars | 0; - const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0; - const lineDecorationsWidth = _opts.lineDecorationsWidth | 0; - const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth; - const maxDigitWidth = _opts.maxDigitWidth; - const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0; - const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows; - const scrollbarArrowSize = _opts.scrollbarArrowSize | 0; - const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0; - const minimap = _opts.minimap; - const minimapSide = _opts.minimapSide; - const minimapRenderCharacters = _opts.minimapRenderCharacters; - const minimapMaxColumn = _opts.minimapMaxColumn | 0; - const pixelRatio = _opts.pixelRatio; - - let lineNumbersWidth = 0; - if (showLineNumbers) { - const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars); - lineNumbersWidth = Math.round(digitCount * maxDigitWidth); - } +export const EDITOR_FONT_DEFAULTS = { + fontFamily: ( + platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY) + ), + fontWeight: 'normal', + fontSize: ( + platform.isMacintosh ? 12 : 14 + ), + lineHeight: 0, + letterSpacing: 0, +}; - let glyphMarginWidth = 0; - if (showGlyphMargin) { - glyphMarginWidth = lineHeight; - } +/** + * @internal + */ +export const EDITOR_MODEL_DEFAULTS = { + tabSize: 4, + indentSize: 4, + insertSpaces: true, + detectIndentation: true, + trimAutoWhitespace: true, + largeFileOptimizations: true +}; - let glyphMarginLeft = 0; - let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth; - let decorationsLeft = lineNumbersLeft + lineNumbersWidth; - let contentLeft = decorationsLeft + lineDecorationsWidth; +/** + * @internal + */ +export const EDITOR_DEFAULTS: IValidatedEditorOptions = { + wordSeparators: USUAL_WORD_SEPARATORS, + lineDecorationsWidth: 10, + readOnly: false, + mouseStyle: 'text', + disableLayerHinting: false, + automaticLayout: false, + autoClosingBrackets: 'languageDefined', + autoClosingQuotes: 'languageDefined', + autoClosingOvertype: 'auto', + autoSurround: 'languageDefined', + autoIndent: true, + dragAndDrop: true, + emptySelectionClipboard: true, + copyWithSyntaxHighlighting: true, + useTabStops: true, + multiCursorModifier: 'altKey', + multiCursorMergeOverlapping: true, + showUnused: true, - const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth; - - let renderMinimap: RenderMinimap; - let minimapLeft: number; - let minimapWidth: number; - let contentWidth: number; - if (!minimap) { - minimapLeft = 0; - minimapWidth = 0; - renderMinimap = RenderMinimap.None; - contentWidth = remainingWidth; - } else { - let minimapCharWidth: number; - if (pixelRatio >= 2) { - renderMinimap = minimapRenderCharacters ? RenderMinimap.Large : RenderMinimap.LargeBlocks; - minimapCharWidth = 2 / pixelRatio; - } else { - renderMinimap = minimapRenderCharacters ? RenderMinimap.Small : RenderMinimap.SmallBlocks; - minimapCharWidth = 1 / pixelRatio; - } - - // Given: - // (leaving 2px for the cursor to have space after the last character) - // viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth - // minimapWidth = viewportColumn * minimapCharWidth - // contentWidth = remainingWidth - minimapWidth - // What are good values for contentWidth and minimapWidth ? - - // minimapWidth = ((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth) * minimapCharWidth - // typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth - 2) * minimapCharWidth - // typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth - 2) * minimapCharWidth - // (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth - // minimapWidth = ((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth) - - minimapWidth = Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth))); - let minimapColumns = minimapWidth / minimapCharWidth; - if (minimapColumns > minimapMaxColumn) { - minimapWidth = Math.floor(minimapMaxColumn * minimapCharWidth); - } - contentWidth = remainingWidth - minimapWidth; - - if (minimapSide === 'left') { - minimapLeft = 0; - glyphMarginLeft += minimapWidth; - lineNumbersLeft += minimapWidth; - decorationsLeft += minimapWidth; - contentLeft += minimapWidth; - } else { - minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth; - } - } - - // (leaving 2px for the cursor to have space after the last character) - const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth)); - - const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0); - - return { - width: outerWidth, - height: outerHeight, - - glyphMarginLeft: glyphMarginLeft, - glyphMarginWidth: glyphMarginWidth, - glyphMarginHeight: outerHeight, - - lineNumbersLeft: lineNumbersLeft, - lineNumbersWidth: lineNumbersWidth, - lineNumbersHeight: outerHeight, - - decorationsLeft: decorationsLeft, - decorationsWidth: lineDecorationsWidth, - decorationsHeight: outerHeight, - - contentLeft: contentLeft, - contentWidth: contentWidth, - contentHeight: outerHeight, - - renderMinimap: renderMinimap, - minimapLeft: minimapLeft, - minimapWidth: minimapWidth, - - viewportColumn: viewportColumn, - - verticalScrollbarWidth: verticalScrollbarWidth, - horizontalScrollbarHeight: horizontalScrollbarHeight, - - overviewRuler: { - top: verticalArrowSize, - width: verticalScrollbarWidth, - height: (outerHeight - 2 * verticalArrowSize), - right: 0 - } - }; - } -} - -const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace'; -const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace'; -const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\''; - -/** - * @internal - */ -export const EDITOR_FONT_DEFAULTS = { - fontFamily: ( - platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY) - ), - fontWeight: 'normal', - fontSize: ( - platform.isMacintosh ? 12 : 14 - ), - lineHeight: 0, - letterSpacing: 0, -}; - -/** - * @internal - */ -export const EDITOR_MODEL_DEFAULTS = { - tabSize: 4, - indentSize: 4, - insertSpaces: true, - detectIndentation: true, - trimAutoWhitespace: true, - largeFileOptimizations: true -}; - -/** - * @internal - */ -export const EDITOR_DEFAULTS: IValidatedEditorOptions = { - inDiffEditor: false, - wordSeparators: USUAL_WORD_SEPARATORS, - lineNumbersMinChars: 5, - lineDecorationsWidth: 10, - readOnly: false, - mouseStyle: 'text', - disableLayerHinting: false, - automaticLayout: false, - wordWrap: 'off', - wordWrapColumn: 80, - wordWrapMinified: true, - wrappingIndent: WrappingIndent.Same, - wordWrapBreakBeforeCharacters: '([{‘“〈《「『【〔([{「£¥$£¥++', - wordWrapBreakAfterCharacters: ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」', - wordWrapBreakObtrusiveCharacters: '.', - autoClosingBrackets: 'languageDefined', - autoClosingQuotes: 'languageDefined', - autoClosingOvertype: 'auto', - autoSurround: 'languageDefined', - autoIndent: true, - dragAndDrop: true, - emptySelectionClipboard: true, - copyWithSyntaxHighlighting: true, - useTabStops: true, - multiCursorModifier: 'altKey', - multiCursorMergeOverlapping: true, - accessibilitySupport: 'auto', - showUnused: true, - - viewInfo: { - extraEditorClassName: '', - disableMonospaceOptimizations: false, - rulers: [], - ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"), - renderLineNumbers: RenderLineNumbersType.On, - renderCustomLineNumbers: null, - cursorSurroundingLines: 0, - glyphMargin: true, - revealHorizontalRightPadding: 30, - roundedSelection: true, - overviewRulerLanes: 2, - overviewRulerBorder: true, - cursorBlinking: TextEditorCursorBlinkingStyle.Blink, - mouseWheelZoom: false, - cursorSmoothCaretAnimation: false, - cursorStyle: TextEditorCursorStyle.Line, - cursorWidth: 0, - hideCursorInOverviewRuler: false, - scrollBeyondLastLine: true, - scrollBeyondLastColumn: 5, - smoothScrolling: false, - stopRenderingLineAfter: 10000, - renderWhitespace: 'none', - renderControlCharacters: false, - fontLigatures: false, - renderIndentGuides: true, - highlightActiveIndentGuide: true, - renderLineHighlight: 'line', - scrollbar: { - vertical: ScrollbarVisibility.Auto, - horizontal: ScrollbarVisibility.Auto, - arrowSize: 11, - useShadows: true, - verticalHasArrows: false, - horizontalHasArrows: false, - horizontalScrollbarSize: 10, - horizontalSliderSize: 10, - verticalScrollbarSize: 14, - verticalSliderSize: 14, - handleMouseWheel: true, - mouseWheelScrollSensitivity: 1, - fastScrollSensitivity: 5, - }, - minimap: { - enabled: true, - side: 'right', - showSlider: 'mouseover', - renderCharacters: true, - maxColumn: 120 - }, - fixedOverflowWidgets: false, - }, + viewInfo: { + extraEditorClassName: '', + disableMonospaceOptimizations: false, + rulers: [], + cursorSurroundingLines: 0, + glyphMargin: true, + revealHorizontalRightPadding: 30, + roundedSelection: true, + overviewRulerLanes: 2, + overviewRulerBorder: true, + cursorBlinking: TextEditorCursorBlinkingStyle.Blink, + mouseWheelZoom: false, + cursorSmoothCaretAnimation: false, + cursorStyle: TextEditorCursorStyle.Line, + cursorWidth: 0, + hideCursorInOverviewRuler: false, + scrollBeyondLastLine: true, + scrollBeyondLastColumn: 5, + smoothScrolling: false, + stopRenderingLineAfter: 10000, + renderWhitespace: 'none', + renderControlCharacters: false, + fontLigatures: false, + renderIndentGuides: true, + highlightActiveIndentGuide: true, + renderLineHighlight: 'line', + fixedOverflowWidgets: false, + }, contribInfo: { hover: { @@ -2746,7 +1944,6 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { selectionHighlight: true, occurrencesHighlight: true, codeLens: true, - folding: true, foldingStrategy: 'auto', showFoldingControls: 'mouseover', matchBrackets: true, @@ -2763,7 +1960,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { }, }; -export interface IRawEditorOptionsBag { +export interface IRawEditorOptionsBag extends IEditorOptions { [key: string]: any; } @@ -2793,14 +1990,21 @@ export class ValidatedEditorOptions { } } +export interface IComputedEditorOptions { + get>(id: EditorOptionId): ComputedEditorOptionValue; +} + /** * @internal */ -export class ComputedEditorOptions { +export class ComputedEditorOptions implements IComputedEditorOptions { private readonly _values: any[] = []; public _read(id: EditorOptionId): T { return this._values[id]; } + public get>(id: EditorOptionId): ComputedEditorOptionValue { + return this._values[id]; + } public _write(id: EditorOptionId, value: T): void { this._values[id] = value; } @@ -2819,69 +2023,838 @@ export class ChangedEditorOptions { } } +export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; + export interface IEditorOption { readonly id: EditorOptionId; - readonly name: string; - readonly defaultValue: T1; + readonly name: PossibleKeyName; + readonly defaultValue: T2; read(options: IRawEditorOptionsBag): T1 | undefined; mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; validate(input: T1 | undefined): T2; - compute(value: T2): T3; + compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; equals(a: T3, b: T3): boolean; } -class BooleanEditorOption implements IEditorOption { +/** + * @internal + */ +export const editorOptionsRegistry: IEditorOption[] = []; + +function registerEditorOption(option: IEditorOption): IEditorOption { + editorOptionsRegistry[option.id] = option; + return option; +} + +export abstract class BaseEditorOption implements IEditorOption { + public readonly id: EditorOptionId; - public readonly name: string; - public readonly defaultValue: boolean; + public readonly name: PossibleKeyName; + public readonly defaultValue: T2; - constructor(id: EditorOptionId, name: string, defaultValue: boolean) { + constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T2, deps: EditorOptionId[] = []) { this.id = id; this.name = name; this.defaultValue = defaultValue; + for (const dep of deps) { + assert.ok(dep < id); + } } - - public read(options: IRawEditorOptionsBag): boolean | undefined { - return options[this.name]; + public read(options: IRawEditorOptionsBag): T1 | undefined { + return options[this.name]; } - - public mix(a: boolean | undefined, b: boolean | undefined): boolean | undefined { - return (typeof b !== 'undefined' ? b : a); + public mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined { + switch (typeof b) { + case 'bigint': return b; + case 'boolean': return b; + case 'function': return b; + case 'number': return b; + case 'object': return (Array.isArray(b) || typeof a !== 'object' ? b : objects.mixin(objects.mixin({}, a), b)); + case 'string': return b; + default: + return a; + } } + public abstract validate(input: T1 | undefined): T2; + public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; + public equals(a: T3, b: T3): boolean { + return (a === b); + } +} +class EditorBooleanOption extends BaseEditorOption { public validate(input: boolean | undefined): boolean { return _boolean(input, this.defaultValue); } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { + return value; + } +} - public compute(value: boolean): boolean { +class EditorIntOption extends BaseEditorOption { + public readonly minimum: number; + public readonly maximum: number; + constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOptionId[] = []) { + super(id, name, defaultValue, deps); + this.minimum = minimum; + this.maximum = maximum; + } + public validate(input: number | undefined): number { + return _clampedInt(input, this.defaultValue, this.minimum, this.maximum); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { return value; } +} - public equals(a: boolean, b: boolean): boolean { - return (a === b); +class EditorFloatOption extends BaseEditorOption { + public readonly validationFn: (value: number) => number; + constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOptionId[] = []) { + super(id, name, defaultValue, deps); + this.validationFn = validationFn; + } + public validate(input: number | undefined): number { + return this.validationFn(_float(input, this.defaultValue)); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { + return value; } } -/** - * @internal - */ -export const editorOptionsRegistry: IEditorOption[] = []; +class EditorStringOption extends BaseEditorOption { + public validate(input: string | undefined): string { + return _string(input, this.defaultValue); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { + return value; + } +} -function registerEditorOption(option: IEditorOption): IEditorOption { - editorOptionsRegistry[option.id] = option; - return option; +class EditorEnumOption extends BaseEditorOption { + public readonly allowedValues: T1[]; + public readonly convert: (value: T1) => T2; + constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOptionId[] = []) { + super(id, name, defaultValue, deps); + this.allowedValues = allowedValues; + this.convert = convert; + } + public validate(input: T1 | undefined): T1 { + return _stringSet(input, this.defaultValue, this.allowedValues); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T1): T2 { + return this.convert(value); + } +} + +class EditorPassthroughOption extends BaseEditorOption { + public validate(input: T | undefined): T { + if (typeof input === 'undefined') { + return this.defaultValue; + } + return input; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T): T { + return value; + } +} + +//#region renderLineNumbers + +export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + +export const enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 +} + +export interface InternalEditorRenderLineNumbersOptions { + readonly renderType: RenderLineNumbersType; + readonly renderFn: ((lineNumber: number) => string) | null; +} + +class EditorRenderLineNumbersOption extends BaseEditorOption { + public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions { + let renderType: RenderLineNumbersType = this.defaultValue.renderType; + let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; + + if (typeof lineNumbers !== 'undefined') { + if (typeof lineNumbers === 'function') { + renderType = RenderLineNumbersType.Custom; + renderFn = lineNumbers; + } else if (lineNumbers === 'interval') { + renderType = RenderLineNumbersType.Interval; + } else if (lineNumbers === 'relative') { + renderType = RenderLineNumbersType.Relative; + } else if (lineNumbers === 'on') { + renderType = RenderLineNumbersType.On; + } else { + renderType = RenderLineNumbersType.Off; + } + } + + return { + renderType, + renderFn + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorRenderLineNumbersOptions): InternalEditorRenderLineNumbersOptions { + return value; + } + public equals(a: InternalEditorRenderLineNumbersOptions, b: InternalEditorRenderLineNumbersOptions): boolean { + return ( + a.renderType === b.renderType + && a.renderFn === b.renderFn + ); + } } +//#endregion + +//#region minimap + +export interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly side: 'right' | 'left'; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; +} + +class EditorMinimapOption extends BaseEditorOption { + public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled), + side: _stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']), + showSlider: _stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']), + renderCharacters: _boolean(input.renderCharacters, this.defaultValue.renderCharacters), + maxColumn: _clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000), + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorMinimapOptions): InternalEditorMinimapOptions { + return value; + } + public equals(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean { + return ( + a.enabled === b.enabled + && a.side === b.side + && a.showSlider === b.showSlider + && a.renderCharacters === b.renderCharacters + && a.maxColumn === b.maxColumn + ); + } +} + +//#endregion + +//#region accessibilitySupport + +class EditorAccessibilitySupportOption extends BaseEditorOption<'auto' | 'off' | 'on', 'auto' | 'off' | 'on', AccessibilitySupport> { + public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' { + return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: 'auto' | 'off' | 'on'): AccessibilitySupport { + if (value === 'auto') { + // The editor reads the `accessibilitySupport` from the environment + return env.accessibilitySupport; + } else if (value === 'on') { + return AccessibilitySupport.Enabled; + } else { + return AccessibilitySupport.Disabled; + } + } +} + +//#endregion + +//#region ariaLabel + +class EditorAriaLabel extends BaseEditorOption { + public validate(input: string | undefined): string { + return _string(input, this.defaultValue); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { + const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + if (accessibilitySupport === AccessibilitySupport.Disabled) { + return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options."); + } + return value; + } +} + +//#endregion + +//#region scrollbar + +export interface InternalEditorScrollbarOptions { + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; +} + +class EditorScrollbarOption extends BaseEditorOption { + public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + const horizontalScrollbarSize = _clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000); + const verticalScrollbarSize = _clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000); + return { + arrowSize: _clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000), + vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical), + horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal), + useShadows: _boolean(input.useShadows, this.defaultValue.useShadows), + verticalHasArrows: _boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows), + horizontalHasArrows: _boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows), + handleMouseWheel: _boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel), + horizontalScrollbarSize: horizontalScrollbarSize, + horizontalSliderSize: _clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000), + verticalScrollbarSize: verticalScrollbarSize, + verticalSliderSize: _clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000), + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorScrollbarOptions): InternalEditorScrollbarOptions { + return value; + } + public equals(a: InternalEditorScrollbarOptions, b: InternalEditorScrollbarOptions): boolean { + return ( + a.arrowSize === b.arrowSize + && a.vertical === b.vertical + && a.horizontal === b.horizontal + && a.useShadows === b.useShadows + && a.verticalHasArrows === b.verticalHasArrows + && a.horizontalHasArrows === b.horizontalHasArrows + && a.handleMouseWheel === b.handleMouseWheel + && a.horizontalScrollbarSize === b.horizontalScrollbarSize + && a.horizontalSliderSize === b.horizontalSliderSize + && a.verticalScrollbarSize === b.verticalScrollbarSize + && a.verticalSliderSize === b.verticalSliderSize + ); + } +} + +//#endregion + +//#region layoutInfo + +/** + * A description for the overview ruler position. + */ +export interface OverviewRulerPosition { + /** + * Width of the overview ruler + */ + readonly width: number; + /** + * Height of the overview ruler + */ + readonly height: number; + /** + * Top position for the overview ruler + */ + readonly top: number; + /** + * Right position for the overview ruler + */ + readonly right: number; +} + +/** + * The internal layout details of the editor. + */ +export interface EditorLayoutInfo { + + /** + * Full editor width. + */ + readonly width: number; + /** + * Full editor height. + */ + readonly height: number; + + /** + * Left position for the glyph margin. + */ + readonly glyphMarginLeft: number; + /** + * The width of the glyph margin. + */ + readonly glyphMarginWidth: number; + /** + * The height of the glyph margin. + */ + readonly glyphMarginHeight: number; + + /** + * Left position for the line numbers. + */ + readonly lineNumbersLeft: number; + /** + * The width of the line numbers. + */ + readonly lineNumbersWidth: number; + /** + * The height of the line numbers. + */ + readonly lineNumbersHeight: number; + + /** + * Left position for the line decorations. + */ + readonly decorationsLeft: number; + /** + * The width of the line decorations. + */ + readonly decorationsWidth: number; + /** + * The height of the line decorations. + */ + readonly decorationsHeight: number; + + /** + * Left position for the content (actual text) + */ + readonly contentLeft: number; + /** + * The width of the content (actual text) + */ + readonly contentWidth: number; + /** + * The height of the content (actual height) + */ + readonly contentHeight: number; + + /** + * The position for the minimap + */ + readonly minimapLeft: number; + /** + * The width of the minimap + */ + readonly minimapWidth: number; + + /** + * Minimap render type + */ + readonly renderMinimap: RenderMinimap; + + /** + * The number of columns (of typical characters) fitting on a viewport line. + */ + readonly viewportColumn: number; + + /** + * The width of the vertical scrollbar. + */ + readonly verticalScrollbarWidth: number; + /** + * The height of the horizontal scrollbar. + */ + readonly horizontalScrollbarHeight: number; + + /** + * The position of the overview ruler. + */ + readonly overviewRuler: OverviewRulerPosition; +} + +/** + * @internal + */ +export class EditorLayoutInfoComputer extends BaseEditorOption { + public validate(input: undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorLayoutInfo { + const glyphMargin = options.get(EditorOptionId.glyphMargin); + const lineNumbersMinChars = options.get(EditorOptionId.lineNumbersMinChars); + const rawLineDecorationsWidth = options.get(EditorOptionId.lineDecorationsWidth); + const folding = options.get(EditorOptionId.folding); + const minimap = options.get(EditorOptionId.minimap); + const scrollbar = options.get(EditorOptionId.scrollbar); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + + let lineDecorationsWidth: number; + if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) { + const multiple = parseFloat(rawLineDecorationsWidth.substr(0, rawLineDecorationsWidth.length - 2)); + lineDecorationsWidth = multiple * env.fontInfo.typicalHalfwidthCharacterWidth; + } else { + lineDecorationsWidth = _clampedInt(rawLineDecorationsWidth, 0, 0, 1000); + } + if (folding) { + lineDecorationsWidth += 16; + } + + return EditorLayoutInfoComputer.compute({ + outerWidth: env.outerWidth, + outerHeight: env.outerHeight, + showGlyphMargin: glyphMargin, + lineHeight: env.fontInfo.lineHeight, + showLineNumbers: (renderLineNumbers.renderType !== RenderLineNumbersType.Off), + lineNumbersMinChars: lineNumbersMinChars, + lineNumbersDigitCount: env.lineNumbersDigitCount, + lineDecorationsWidth: lineDecorationsWidth, + typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth, + maxDigitWidth: env.fontInfo.maxDigitWidth, + verticalScrollbarWidth: scrollbar.verticalScrollbarSize, + horizontalScrollbarHeight: scrollbar.horizontalScrollbarSize, + scrollbarArrowSize: scrollbar.arrowSize, + verticalScrollbarHasArrows: scrollbar.verticalHasArrows, + minimap: minimap.enabled, + minimapSide: minimap.side, + minimapRenderCharacters: minimap.renderCharacters, + minimapMaxColumn: minimap.maxColumn, + pixelRatio: env.pixelRatio + }); + } + public equals(a: EditorLayoutInfo, b: EditorLayoutInfo): boolean { + return ( + a.width === b.width + && a.height === b.height + && a.glyphMarginLeft === b.glyphMarginLeft + && a.glyphMarginWidth === b.glyphMarginWidth + && a.glyphMarginHeight === b.glyphMarginHeight + && a.lineNumbersLeft === b.lineNumbersLeft + && a.lineNumbersWidth === b.lineNumbersWidth + && a.lineNumbersHeight === b.lineNumbersHeight + && a.decorationsLeft === b.decorationsLeft + && a.decorationsWidth === b.decorationsWidth + && a.decorationsHeight === b.decorationsHeight + && a.contentLeft === b.contentLeft + && a.contentWidth === b.contentWidth + && a.contentHeight === b.contentHeight + && a.renderMinimap === b.renderMinimap + && a.minimapLeft === b.minimapLeft + && a.minimapWidth === b.minimapWidth + && a.viewportColumn === b.viewportColumn + && a.verticalScrollbarWidth === b.verticalScrollbarWidth + && a.horizontalScrollbarHeight === b.horizontalScrollbarHeight + && EditorLayoutInfoComputer._equalsOverviewRuler(a.overviewRuler, b.overviewRuler) + ); + } + + /** + * @internal + */ + private static _equalsOverviewRuler(a: OverviewRulerPosition, b: OverviewRulerPosition): boolean { + return ( + a.width === b.width + && a.height === b.height + && a.top === b.top + && a.right === b.right + ); + } + + public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo { + const outerWidth = _opts.outerWidth | 0; + const outerHeight = _opts.outerHeight | 0; + const showGlyphMargin = _opts.showGlyphMargin; + const lineHeight = _opts.lineHeight | 0; + const showLineNumbers = _opts.showLineNumbers; + const lineNumbersMinChars = _opts.lineNumbersMinChars | 0; + const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0; + const lineDecorationsWidth = _opts.lineDecorationsWidth | 0; + const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth; + const maxDigitWidth = _opts.maxDigitWidth; + const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0; + const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows; + const scrollbarArrowSize = _opts.scrollbarArrowSize | 0; + const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0; + const minimap = _opts.minimap; + const minimapSide = _opts.minimapSide; + const minimapRenderCharacters = _opts.minimapRenderCharacters; + const minimapMaxColumn = _opts.minimapMaxColumn | 0; + const pixelRatio = _opts.pixelRatio; + + let lineNumbersWidth = 0; + if (showLineNumbers) { + const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars); + lineNumbersWidth = Math.round(digitCount * maxDigitWidth); + } + + let glyphMarginWidth = 0; + if (showGlyphMargin) { + glyphMarginWidth = lineHeight; + } + + let glyphMarginLeft = 0; + let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth; + let decorationsLeft = lineNumbersLeft + lineNumbersWidth; + let contentLeft = decorationsLeft + lineDecorationsWidth; + + const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth; + + let renderMinimap: RenderMinimap; + let minimapLeft: number; + let minimapWidth: number; + let contentWidth: number; + if (!minimap) { + minimapLeft = 0; + minimapWidth = 0; + renderMinimap = RenderMinimap.None; + contentWidth = remainingWidth; + } else { + let minimapCharWidth: number; + if (pixelRatio >= 2) { + renderMinimap = minimapRenderCharacters ? RenderMinimap.Large : RenderMinimap.LargeBlocks; + minimapCharWidth = 2 / pixelRatio; + } else { + renderMinimap = minimapRenderCharacters ? RenderMinimap.Small : RenderMinimap.SmallBlocks; + minimapCharWidth = 1 / pixelRatio; + } + + // Given: + // (leaving 2px for the cursor to have space after the last character) + // viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth + // minimapWidth = viewportColumn * minimapCharWidth + // contentWidth = remainingWidth - minimapWidth + // What are good values for contentWidth and minimapWidth ? + + // minimapWidth = ((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth) * minimapCharWidth + // typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth - 2) * minimapCharWidth + // typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth - 2) * minimapCharWidth + // (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth + // minimapWidth = ((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth) + + minimapWidth = Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth))); + let minimapColumns = minimapWidth / minimapCharWidth; + if (minimapColumns > minimapMaxColumn) { + minimapWidth = Math.floor(minimapMaxColumn * minimapCharWidth); + } + contentWidth = remainingWidth - minimapWidth; + + if (minimapSide === 'left') { + minimapLeft = 0; + glyphMarginLeft += minimapWidth; + lineNumbersLeft += minimapWidth; + decorationsLeft += minimapWidth; + contentLeft += minimapWidth; + } else { + minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth; + } + } + + // (leaving 2px for the cursor to have space after the last character) + const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth)); + + const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0); + + return { + width: outerWidth, + height: outerHeight, + + glyphMarginLeft: glyphMarginLeft, + glyphMarginWidth: glyphMarginWidth, + glyphMarginHeight: outerHeight, + + lineNumbersLeft: lineNumbersLeft, + lineNumbersWidth: lineNumbersWidth, + lineNumbersHeight: outerHeight, + + decorationsLeft: decorationsLeft, + decorationsWidth: lineDecorationsWidth, + decorationsHeight: outerHeight, + + contentLeft: contentLeft, + contentWidth: contentWidth, + contentHeight: outerHeight, + + renderMinimap: renderMinimap, + minimapLeft: minimapLeft, + minimapWidth: minimapWidth, + + viewportColumn: viewportColumn, + + verticalScrollbarWidth: verticalScrollbarWidth, + horizontalScrollbarHeight: horizontalScrollbarHeight, + + overviewRuler: { + top: verticalArrowSize, + width: verticalScrollbarWidth, + height: (outerHeight - 2 * verticalArrowSize), + right: 0 + } + }; + } +} + +//#endregion + +//#region wrappingInfo + +export interface EditorWrappingInfo { + readonly isDominatedByLongLines: boolean; + readonly isWordWrapMinified: boolean; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; +} + +class EditorWrappingInfoComputer extends BaseEditorOption { + public mix(a: undefined, b: undefined): undefined { + return undefined; + } + public validate(input: undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorWrappingInfo { + const wordWrap = options.get(EditorOptionId.wordWrap); + const wordWrapColumn = options.get(EditorOptionId.wordWrapColumn); + const wordWrapMinified = options.get(EditorOptionId.wordWrapMinified); + const layoutInfo = options.get(EditorOptionId.layoutInfo); + const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + + let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null; + { + if (accessibilitySupport === AccessibilitySupport.Enabled) { + // See https://github.com/Microsoft/vscode/issues/27766 + // Never enable wrapping when a screen reader is attached + // because arrow down etc. will not move the cursor in the way + // a screen reader expects. + bareWrappingInfo = { + isWordWrapMinified: false, + isViewportWrapping: false, + wrappingColumn: -1 + }; + } else if (wordWrapMinified && env.isDominatedByLongLines) { + // Force viewport width wrapping if model is dominated by long lines + bareWrappingInfo = { + isWordWrapMinified: true, + isViewportWrapping: true, + wrappingColumn: Math.max(1, layoutInfo.viewportColumn) + }; + } else if (wordWrap === 'on') { + bareWrappingInfo = { + isWordWrapMinified: false, + isViewportWrapping: true, + wrappingColumn: Math.max(1, layoutInfo.viewportColumn) + }; + } else if (wordWrap === 'bounded') { + bareWrappingInfo = { + isWordWrapMinified: false, + isViewportWrapping: true, + wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn) + }; + } else if (wordWrap === 'wordWrapColumn') { + bareWrappingInfo = { + isWordWrapMinified: false, + isViewportWrapping: false, + wrappingColumn: wordWrapColumn + }; + } else { + bareWrappingInfo = { + isWordWrapMinified: false, + isViewportWrapping: false, + wrappingColumn: -1 + }; + } + } + + return { + isDominatedByLongLines: env.isDominatedByLongLines, + isWordWrapMinified: bareWrappingInfo.isWordWrapMinified, + isViewportWrapping: bareWrappingInfo.isViewportWrapping, + wrappingColumn: bareWrappingInfo.wrappingColumn, + }; + } + public equals(a: EditorWrappingInfo, b: EditorWrappingInfo): boolean { + return ( + a.isDominatedByLongLines === b.isDominatedByLongLines + && a.isWordWrapMinified === b.isWordWrapMinified + && a.isViewportWrapping === b.isViewportWrapping + && a.wrappingColumn === b.wrappingColumn + ); + } +} + +//#endregion + export const enum EditorOptionId { + accessibilitySupport, + ariaLabel, + fastScrollSensitivity, + folding, + glyphMargin, + inDiffEditor, + lineDecorationsWidth, + lineNumbersMinChars, + minimap, + mouseWheelScrollSensitivity, renderFinalNewline, + renderLineNumbers, + scrollbar, selectionClipboard, selectOnLineNumbers, + wordWrap, + wordWrapBreakAfterCharacters, + wordWrapBreakBeforeCharacters, + wordWrapBreakObtrusiveCharacters, + wordWrapColumn, + wordWrapMinified, + wrappingIndent, + + layoutInfo, + wrappingInfo, } export const EditorOption = { - renderFinalNewline: registerEditorOption(new BooleanEditorOption(EditorOptionId.renderFinalNewline, 'renderFinalNewline', true)), - selectionClipboard: registerEditorOption(new BooleanEditorOption(EditorOptionId.selectionClipboard, 'selectionClipboard', true)), - selectOnLineNumbers: registerEditorOption(new BooleanEditorOption(EditorOptionId.selectOnLineNumbers, 'selectOnLineNumbers', true)), + accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOptionId.accessibilitySupport, 'accessibilitySupport', 'auto')), + ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOptionId.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOptionId.accessibilitySupport])), + fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOptionId.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))), + folding: registerEditorOption(new EditorBooleanOption(EditorOptionId.folding, 'folding', true)), + glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOptionId.glyphMargin, 'glyphMargin', true)), + inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOptionId.inDiffEditor, 'inDiffEditor', false)), + lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOptionId.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOptionId.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), + minimap: registerEditorOption(new EditorMinimapOption(EditorOptionId.minimap, 'minimap', { + enabled: true, + side: 'right', + showSlider: 'mouseover', + renderCharacters: true, + maxColumn: 120, + })), + mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOptionId.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), + renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOptionId.renderFinalNewline, 'renderFinalNewline', true)), + renderLineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOptionId.renderLineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), + scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOptionId.scrollbar, 'scrollbar', { + vertical: ScrollbarVisibility.Auto, + horizontal: ScrollbarVisibility.Auto, + arrowSize: 11, + useShadows: true, + verticalHasArrows: false, + horizontalHasArrows: false, + horizontalScrollbarSize: 10, + horizontalSliderSize: 10, + verticalScrollbarSize: 14, + verticalSliderSize: 14, + handleMouseWheel: true, + })), + selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectionClipboard, 'selectionClipboard', true)), + selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectOnLineNumbers, 'selectOnLineNumbers', true)), + wordWrap: registerEditorOption(new EditorEnumOption<'off' | 'on' | 'wordWrapColumn' | 'bounded'>(EditorOptionId.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), + wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), + wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), + wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), + wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOptionId.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), + wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOptionId.wordWrapMinified, 'wordWrapMinified', true)), + wrappingIndent: registerEditorOption(new EditorEnumOption<'none' | 'same' | 'indent' | 'deepIndent', WrappingIndent>(EditorOptionId.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), + + // Leave these at the end! + layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOptionId.layoutInfo, 'layoutInfo', undefined, [EditorOptionId.glyphMargin, EditorOptionId.lineDecorationsWidth, EditorOptionId.folding, EditorOptionId.minimap, EditorOptionId.scrollbar, EditorOptionId.renderLineNumbers])), + wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOptionId.wrappingInfo, 'wrappingInfo', undefined, [EditorOptionId.wordWrap, EditorOptionId.wordWrapColumn, EditorOptionId.wordWrapMinified, EditorOptionId.layoutInfo, EditorOptionId.accessibilitySupport])), }; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 87c3878b61c31..80775a63bd2d2 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -6,7 +6,7 @@ import { CharCode } from 'vs/base/common/charCode'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; -import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy } from 'vs/editor/common/config/editorOptions'; +import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -112,7 +112,7 @@ export class CursorConfiguration { public static shouldRecreate(e: IConfigurationChangedEvent): boolean { return ( - e.layoutInfo + e.hasChanged(EditorOptionId.layoutInfo) || e.wordSeparators || e.emptySelectionClipboard || e.multiCursorMergeOverlapping @@ -133,13 +133,15 @@ export class CursorConfiguration { ) { this._languageIdentifier = languageIdentifier; - let c = configuration.editor; + const c = configuration.editor; + const options = configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.readOnly = c.readOnly; this.tabSize = modelOptions.tabSize; this.indentSize = modelOptions.indentSize; this.insertSpaces = modelOptions.insertSpaces; - this.pageSize = Math.max(1, Math.floor(c.layoutInfo.height / c.fontInfo.lineHeight) - 2); + this.pageSize = Math.max(1, Math.floor(layoutInfo.height / c.fontInfo.lineHeight) - 2); this.lineHeight = c.lineHeight; this.useTabStops = c.useTabStops; this.wordSeparators = c.wordSeparators; diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index f070525b99bc7..6c9541592342f 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -152,8 +152,7 @@ export interface IConfiguration extends IDisposable { onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable; readonly editor: editorOptions.InternalEditorOptions; - - getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue; + readonly options: editorOptions.IComputedEditorOptions; setMaxLineNumber(maxLineNumber: number): void; updateOptions(newOptions: editorOptions.IEditorOptions): void; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 1af333dd0a41f..d3b4118c43340 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -332,6 +332,15 @@ export enum CursorChangeReason { Redo = 6 } +export enum AccessibilitySupport { + /** + * This should be the browser case where it is not known if a screen reader is attached or no. + */ + Unknown = 0, + Disabled = 1, + Enabled = 2 +} + export enum RenderMinimap { None = 0, Small = 1, @@ -431,9 +440,30 @@ export enum RenderLineNumbersType { } export enum EditorOptionId { - renderFinalNewline = 0, - selectionClipboard = 1, - selectOnLineNumbers = 2 + accessibilitySupport = 0, + ariaLabel = 1, + fastScrollSensitivity = 2, + folding = 3, + glyphMargin = 4, + inDiffEditor = 5, + lineDecorationsWidth = 6, + lineNumbersMinChars = 7, + minimap = 8, + mouseWheelScrollSensitivity = 9, + renderFinalNewline = 10, + renderLineNumbers = 11, + scrollbar = 12, + selectionClipboard = 13, + selectOnLineNumbers = 14, + wordWrap = 15, + wordWrapBreakAfterCharacters = 16, + wordWrapBreakBeforeCharacters = 17, + wordWrapBreakObtrusiveCharacters = 18, + wordWrapColumn = 19, + wordWrapMinified = 20, + wrappingIndent = 21, + layoutInfo = 22, + wrappingInfo = 23 } /** diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index 962579d3f0f62..47006636def33 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -6,7 +6,7 @@ import * as errors from 'vs/base/common/errors'; import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { ScrollEvent } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -34,32 +34,32 @@ export class ViewConfigurationChangedEvent { public readonly type = ViewEventType.ViewConfigurationChanged; + public readonly _source: IConfigurationChangedEvent; public readonly canUseLayerHinting: boolean; public readonly pixelRatio: boolean; public readonly editorClassName: boolean; public readonly lineHeight: boolean; public readonly readOnly: boolean; - public readonly accessibilitySupport: boolean; public readonly emptySelectionClipboard: boolean; public readonly copyWithSyntaxHighlighting: boolean; - public readonly layoutInfo: boolean; public readonly fontInfo: boolean; public readonly viewInfo: boolean; - public readonly wrappingInfo: boolean; constructor(source: IConfigurationChangedEvent) { + this._source = source; this.canUseLayerHinting = source.canUseLayerHinting; this.pixelRatio = source.pixelRatio; this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight; this.readOnly = source.readOnly; - this.accessibilitySupport = source.accessibilitySupport; this.emptySelectionClipboard = source.emptySelectionClipboard; this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; - this.layoutInfo = source.layoutInfo; this.fontInfo = source.fontInfo; this.viewInfo = source.viewInfo; - this.wrappingInfo = source.wrappingInfo; + } + + public hasChanged(id: EditorOptionId): boolean { + return this._source.hasChanged(id); } } diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index ad24479b4b2a9..978aa54a3bbf0 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -6,7 +6,7 @@ import { Event } from 'vs/base/common/event'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout'; import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; @@ -27,14 +27,17 @@ export class ViewLayout extends Disposable implements IViewLayout { super(); this._configuration = configuration; + const options = this._configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight); this.scrollable = this._register(new Scrollable(0, scheduleAtNextAnimationFrame)); this._configureSmoothScrollDuration(); this.scrollable.setScrollDimensions({ - width: configuration.editor.layoutInfo.contentWidth, - height: configuration.editor.layoutInfo.contentHeight + width: layoutInfo.contentWidth, + height: layoutInfo.contentHeight }); this.onDidScroll = this.scrollable.onScroll; @@ -59,10 +62,12 @@ export class ViewLayout extends Disposable implements IViewLayout { if (e.lineHeight) { this._linesLayout.setLineHeight(this._configuration.editor.lineHeight); } - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { + const options = this._configuration.options; + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.scrollable.setScrollDimensions({ - width: this._configuration.editor.layoutInfo.contentWidth, - height: this._configuration.editor.layoutInfo.contentHeight + width: layoutInfo.contentWidth, + height: layoutInfo.contentHeight }); } if (e.viewInfo) { @@ -83,7 +88,9 @@ export class ViewLayout extends Disposable implements IViewLayout { // ---- end view event handlers private _getHorizontalScrollbarHeight(scrollDimensions: IScrollDimensions): number { - if (this._configuration.editor.viewInfo.scrollbar.horizontal === ScrollbarVisibility.Hidden) { + const options = this._configuration.options; + const scrollbar = options.get(EditorOptionId.scrollbar); + if (scrollbar.horizontal === ScrollbarVisibility.Hidden) { // horizontal scrollbar not visible return 0; } @@ -91,7 +98,7 @@ export class ViewLayout extends Disposable implements IViewLayout { // horizontal scrollbar not visible return 0; } - return this._configuration.editor.viewInfo.scrollbar.horizontalScrollbarSize; + return scrollbar.horizontalScrollbarSize; } private _getTotalHeight(): number { @@ -138,7 +145,9 @@ export class ViewLayout extends Disposable implements IViewLayout { } private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number { - let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping; + const options = this._configuration.options; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + let isViewportWrapping = wrappingInfo.isViewportWrapping; if (!isViewportWrapping) { const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth(); diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 65284147a64ab..73350e182145c 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -6,7 +6,7 @@ import { Color } from 'vs/base/common/color'; import { IDisposable } from 'vs/base/common/lifecycle'; import * as strings from 'vs/base/common/strings'; -import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -60,20 +60,26 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } else { const conf = this.configuration.editor; + const options = this.configuration.options; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = options.get(EditorOptionId.wrappingIndent); let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( - conf.wrappingInfo.wordWrapBreakBeforeCharacters, - conf.wrappingInfo.wordWrapBreakAfterCharacters, - conf.wrappingInfo.wordWrapBreakObtrusiveCharacters + wordWrapBreakBeforeCharacters, + wordWrapBreakAfterCharacters, + wordWrapBreakObtrusiveCharacters ); this.lines = new SplitLinesCollection( this.model, hardWrappingLineMapperFactory, this.model.getOptions().tabSize, - conf.wrappingInfo.wrappingColumn, + wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth, - conf.wrappingInfo.wrappingIndent + wrappingIndent ); } @@ -147,8 +153,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel let restorePreviousViewportStart = false; const conf = this.configuration.editor; + const options = this.configuration.options; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingIndent = options.get(EditorOptionId.wrappingIndent); - if (this.lines.setWrappingSettings(conf.wrappingInfo.wrappingIndent, conf.wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) { + if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) { eventsCollector.emit(new viewEvents.ViewFlushedEvent()); eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent()); diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index d35752a078dec..3b31b2e3b578b 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -23,7 +23,7 @@ import { toDisposable } from 'vs/base/common/lifecycle'; import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { CONTEXT_FIND_INPUT_FOCUSED, CONTEXT_REPLACE_INPUT_FOCUSED, FIND_IDS, MATCHES_LIMIT } from 'vs/editor/contrib/find/findModel'; import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState'; @@ -183,11 +183,11 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } this._updateButtons(); } - if (e.layoutInfo) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { this._tryUpdateWidgetWidth(); } - if (e.accessibilitySupport) { + if (e.hasChanged(EditorOptionId.accessibilitySupport)) { this.updateAccessibilitySupport(); } @@ -642,7 +642,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas return; } - const editorContentWidth = this._codeEditor.getConfiguration().layoutInfo.contentWidth; + const layoutInfo = this._codeEditor.getLayoutInfo(); + const editorContentWidth = layoutInfo.contentWidth; if (editorContentWidth <= 0) { // for example, diff view original editor @@ -652,8 +653,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas dom.removeClass(this._domNode, 'hiddenEditor'); } - const editorWidth = this._codeEditor.getConfiguration().layoutInfo.width; - const minimapWidth = this._codeEditor.getConfiguration().layoutInfo.minimapWidth; + const editorWidth = layoutInfo.width; + const minimapWidth = layoutInfo.minimapWidth; let collapsedFindWidget = false; let reducedFindWidget = false; let narrowFindWidget = false; @@ -1187,7 +1188,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas if (!this._resized || currentWidth === FIND_WIDGET_INITIAL_WIDTH) { // 1. never resized before, double click should maximizes it // 2. users resized it already but its width is the same as default - width = this._codeEditor.getConfiguration().layoutInfo.width - 28 - this._codeEditor.getConfiguration().layoutInfo.minimapWidth - 15; + const layoutInfo = this._codeEditor.getLayoutInfo(); + width = layoutInfo.width - 28 - layoutInfo.minimapWidth - 15; this._resized = true; } else { /** diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index cd7cdbe1d13de..4a705db696e25 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -18,7 +18,7 @@ import { FoldingModel, setCollapseStateAtLevel, CollapseMemento, setCollapseStat import { FoldingDecorationProvider } from './foldingDecorations'; import { FoldingRegions, FoldingRegion } from './foldingRanges'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel'; import { IRange } from 'vs/editor/common/core/range'; @@ -87,7 +87,8 @@ export class FoldingController extends Disposable implements IEditorContribution ) { super(); this.editor = editor; - this._isEnabled = this.editor.getConfiguration().contribInfo.folding; + const options = this.editor.getOptions(); + this._isEnabled = options.get(EditorOptionId.folding); this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover'; this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation'; @@ -109,9 +110,10 @@ export class FoldingController extends Disposable implements IEditorContribution this._register(this.editor.onDidChangeModel(() => this.onModelChanged())); this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.contribInfo) { + if (e.contribInfo || e.hasChanged(EditorOptionId.folding)) { let oldIsEnabled = this._isEnabled; - this._isEnabled = this.editor.getConfiguration().contribInfo.folding; + const options = this.editor.getOptions(); + this._isEnabled = options.get(EditorOptionId.folding); this.foldingEnabled.set(this._isEnabled); if (oldIsEnabled !== this._isEnabled) { this.onModelChanged(); diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index 1981153c0c858..dc640cc2b3cf0 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -31,6 +31,7 @@ import { contrastBorder, editorWidgetBackground, widgetShadow, editorWidgetForeg import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey('accessibilityHelpWidgetVisible', false); @@ -224,6 +225,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { private _buildContent() { let opts = this._editor.getConfiguration(); + const options = this._editor.getOptions(); const selections = this._editor.getSelections(); let charactersSelected = 0; @@ -239,7 +241,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { let text = getSelectionLabel(selections, charactersSelected); - if (opts.wrappingInfo.inDiffEditor) { + if (options.get(EditorOptionId.inDiffEditor)) { if (opts.readOnly) { text += AccessibilityHelpNLS.readonlyDiffEditor; } else { diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index c3936c2a1b7dd..70d17b7f81bd8 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -352,6 +352,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { remeasureFonts: remeasureFonts, // enums + AccessibilitySupport: standaloneEnums.AccessibilitySupport, ScrollbarVisibility: standaloneEnums.ScrollbarVisibility, WrappingIndent: standaloneEnums.WrappingIndent, OverviewRulerLane: standaloneEnums.OverviewRulerLane, @@ -372,6 +373,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { EditorOptionId: standaloneEnums.EditorOptionId, // classes + BaseEditorOption: editorOptions.BaseEditorOption, InternalEditorOptions: editorOptions.InternalEditorOptions, BareFontInfo: BareFontInfo, FontInfo: FontInfo, diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index b35959ae2c25c..649c7f9718be7 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorHoverOptions } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; @@ -67,8 +67,10 @@ suite('Common Editor Config', () => { } function assertWrapping(config: TestConfiguration, isViewportWrapping: boolean, wrappingColumn: number): void { - assert.equal(config.editor.wrappingInfo.isViewportWrapping, isViewportWrapping); - assert.equal(config.editor.wrappingInfo.wrappingColumn, wrappingColumn); + const options = config.options; + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + assert.equal(wrappingInfo.isViewportWrapping, isViewportWrapping); + assert.equal(wrappingInfo.wrappingColumn, wrappingColumn); } test('wordWrap default', () => { diff --git a/src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts b/src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts index e35df432fcdfd..593f7b74126fe 100644 --- a/src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts +++ b/src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import { EditorLayoutInfo, EditorLayoutProvider, IEditorLayoutProviderOpts, RenderMinimap } from 'vs/editor/common/config/editorOptions'; +import { EditorLayoutInfo, EditorLayoutInfoComputer, IEditorLayoutProviderOpts, RenderMinimap } from 'vs/editor/common/config/editorOptions'; suite('Editor ViewLayout - EditorLayoutProvider', () => { function doTest(input: IEditorLayoutProviderOpts, expected: EditorLayoutInfo): void { - let actual = EditorLayoutProvider.compute(input); + let actual = EditorLayoutInfoComputer.compute(input); assert.deepEqual(actual, expected); } diff --git a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts index 9b053429da8be..20ba2e124371e 100644 --- a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts +++ b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts @@ -19,6 +19,7 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer' import { ILineMapping, ISimpleModel, SplitLine, SplitLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection'; import { ViewLineData } from 'vs/editor/common/viewModel/viewModel'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; suite('Editor ViewModel - SplitLinesCollection', () => { test('SplitLine', () => { @@ -88,15 +89,20 @@ suite('Editor ViewModel - SplitLinesCollection', () => { }); function withSplitLinesCollection(text: string, callback: (model: TextModel, linesCollection: SplitLinesCollection) => void): void { - let config = new TestConfiguration({}); - - let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( - config.editor.wrappingInfo.wordWrapBreakBeforeCharacters, - config.editor.wrappingInfo.wordWrapBreakAfterCharacters, - config.editor.wrappingInfo.wordWrapBreakObtrusiveCharacters + const config = new TestConfiguration({}); + const wrappingInfo = config.options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = config.options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = config.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = config.options.get(EditorOptionId.wrappingIndent); + + const hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( + wordWrapBreakBeforeCharacters, + wordWrapBreakAfterCharacters, + wordWrapBreakObtrusiveCharacters ); - let model = TextModel.createFromString([ + const model = TextModel.createFromString([ 'int main() {', '\tprintf("Hello world!");', '}', @@ -105,13 +111,13 @@ suite('Editor ViewModel - SplitLinesCollection', () => { '}', ].join('\n')); - let linesCollection = new SplitLinesCollection( + const linesCollection = new SplitLinesCollection( model, hardWrappingLineMapperFactory, model.getOptions().tabSize, - config.editor.wrappingInfo.wrappingColumn, + wrappingInfo.wrappingColumn, config.editor.fontInfo.typicalFullwidthCharacterWidth / config.editor.fontInfo.typicalHalfwidthCharacterWidth, - config.editor.wrappingInfo.wrappingIndent + wrappingIndent ); callback(model, linesCollection); @@ -732,25 +738,30 @@ suite('SplitLinesCollection', () => { }); function withSplitLinesCollection(model: TextModel, wordWrap: 'on' | 'off' | 'wordWrapColumn' | 'bounded', wordWrapColumn: number, callback: (splitLinesCollection: SplitLinesCollection) => void): void { - let configuration = new TestConfiguration({ + const configuration = new TestConfiguration({ wordWrap: wordWrap, wordWrapColumn: wordWrapColumn, wrappingIndent: 'indent' }); - - let factory = new CharacterHardWrappingLineMapperFactory( - configuration.editor.wrappingInfo.wordWrapBreakBeforeCharacters, - configuration.editor.wrappingInfo.wordWrapBreakAfterCharacters, - configuration.editor.wrappingInfo.wordWrapBreakObtrusiveCharacters + const wrappingInfo = configuration.options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = configuration.options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = configuration.options.get(EditorOptionId.wrappingIndent); + + const factory = new CharacterHardWrappingLineMapperFactory( + wordWrapBreakBeforeCharacters, + wordWrapBreakAfterCharacters, + wordWrapBreakObtrusiveCharacters ); - let linesCollection = new SplitLinesCollection( + const linesCollection = new SplitLinesCollection( model, factory, model.getOptions().tabSize, - configuration.editor.wrappingInfo.wrappingColumn, + wrappingInfo.wrappingColumn, configuration.editor.fontInfo.typicalFullwidthCharacterWidth / configuration.editor.fontInfo.typicalHalfwidthCharacterWidth, - configuration.editor.wrappingInfo.wrappingIndent + wrappingIndent ); callback(linesCollection); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 87d8500889508..32d7a932be419 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2408,6 +2408,15 @@ declare namespace monaco.editor { readonly reason: CursorChangeReason; } + export enum AccessibilitySupport { + /** + * This should be the browser case where it is not known if a screen reader is attached or no. + */ + Unknown = 0, + Disabled = 1, + Enabled = 2 + } + /** * Configuration options for editor scrollbars */ @@ -2653,7 +2662,7 @@ declare namespace monaco.editor { * Otherwise, line numbers will not be rendered. * Defaults to true. */ - lineNumbers?: 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + lineNumbers?: LineNumbersType; /** * Controls the minimal number of visible leading and trailing lines surrounding the cursor. * Defaults to 0. @@ -2826,7 +2835,7 @@ declare namespace monaco.editor { * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'. * Defaults to 'same' in vscode and to 'none' in monaco-editor. */ - wrappingIndent?: string; + wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent'; /** * Configure word wrapping characters. A break will be introduced before these characters. * Defaults to '{([+'. @@ -3105,6 +3114,8 @@ declare namespace monaco.editor { * Controls fading out of unused variables. */ showUnused?: boolean; + layoutInfo?: undefined; + wrappingInfo?: undefined; } /** @@ -3228,30 +3239,6 @@ declare namespace monaco.editor { UnderlineThin = 6 } - export interface InternalEditorScrollbarOptions { - readonly arrowSize: number; - readonly vertical: ScrollbarVisibility; - readonly horizontal: ScrollbarVisibility; - readonly useShadows: boolean; - readonly verticalHasArrows: boolean; - readonly horizontalHasArrows: boolean; - readonly handleMouseWheel: boolean; - readonly horizontalScrollbarSize: number; - readonly horizontalSliderSize: number; - readonly verticalScrollbarSize: number; - readonly verticalSliderSize: number; - readonly mouseWheelScrollSensitivity: number; - readonly fastScrollSensitivity: number; - } - - export interface InternalEditorMinimapOptions { - readonly enabled: boolean; - readonly side: 'right' | 'left'; - readonly showSlider: 'always' | 'mouseover'; - readonly renderCharacters: boolean; - readonly maxColumn: number; - } - export interface InternalEditorFindOptions { readonly seedSearchStringFromSelection: boolean; readonly autoFindInSelection: boolean; @@ -3284,33 +3271,10 @@ declare namespace monaco.editor { readonly cycle: boolean; } - export interface EditorWrappingInfo { - readonly inDiffEditor: boolean; - readonly isDominatedByLongLines: boolean; - readonly isWordWrapMinified: boolean; - readonly isViewportWrapping: boolean; - readonly wrappingColumn: number; - readonly wrappingIndent: WrappingIndent; - readonly wordWrapBreakBeforeCharacters: string; - readonly wordWrapBreakAfterCharacters: string; - readonly wordWrapBreakObtrusiveCharacters: string; - } - - export enum RenderLineNumbersType { - Off = 0, - On = 1, - Relative = 2, - Interval = 3, - Custom = 4 - } - export interface InternalEditorViewOptions { readonly extraEditorClassName: string; readonly disableMonospaceOptimizations: boolean; readonly rulers: number[]; - readonly ariaLabel: string; - readonly renderLineNumbers: RenderLineNumbersType; - readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly cursorSurroundingLines: number; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -3333,8 +3297,6 @@ declare namespace monaco.editor { readonly renderIndentGuides: boolean; readonly highlightActiveIndentGuide: boolean; readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly scrollbar: InternalEditorScrollbarOptions; - readonly minimap: InternalEditorMinimapOptions; readonly fixedOverflowWidgets: boolean; } @@ -3364,7 +3326,6 @@ declare namespace monaco.editor { readonly selectionHighlight: boolean; readonly occurrencesHighlight: boolean; readonly codeLens: boolean; - readonly folding: boolean; readonly foldingStrategy: 'auto' | 'indentation'; readonly showFoldingControls: 'always' | 'mouseover'; readonly matchBrackets: boolean; @@ -3399,13 +3360,124 @@ declare namespace monaco.editor { readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; - readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; - readonly wrappingInfo: EditorWrappingInfo; readonly contribInfo: EditorContribOptions; } + /** + * An event describing that the configuration of the editor has changed. + */ + export interface IConfigurationChangedEvent { + hasChanged(id: EditorOptionId): boolean; + readonly canUseLayerHinting: boolean; + readonly pixelRatio: boolean; + readonly editorClassName: boolean; + readonly lineHeight: boolean; + readonly readOnly: boolean; + readonly multiCursorModifier: boolean; + readonly multiCursorMergeOverlapping: boolean; + readonly wordSeparators: boolean; + readonly autoClosingBrackets: boolean; + readonly autoClosingQuotes: boolean; + readonly autoClosingOvertype: boolean; + readonly autoSurround: boolean; + readonly autoIndent: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly dragAndDrop: boolean; + readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; + readonly fontInfo: boolean; + readonly viewInfo: boolean; + readonly contribInfo: boolean; + } + + export interface IEnvironmentalOptions { + readonly outerWidth: number; + readonly outerHeight: number; + readonly fontInfo: FontInfo; + readonly extraEditorClassName: string; + readonly isDominatedByLongLines: boolean; + readonly lineNumbersDigitCount: number; + readonly emptySelectionClipboard: boolean; + readonly pixelRatio: number; + readonly tabFocusMode: boolean; + readonly accessibilitySupport: AccessibilitySupport; + } + + export interface IRawEditorOptionsBag extends IEditorOptions { + [key: string]: any; + } + + export interface IComputedEditorOptions { + get>(id: EditorOptionId): ComputedEditorOptionValue; + } + + export type PossibleKeyName = { + [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never; + }[keyof IEditorOptions]; + + export interface IEditorOption { + readonly id: EditorOptionId; + readonly name: PossibleKeyName; + readonly defaultValue: T2; + read(options: IRawEditorOptionsBag): T1 | undefined; + mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; + validate(input: T1 | undefined): T2; + compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; + equals(a: T3, b: T3): boolean; + } + + export abstract class BaseEditorOption implements IEditorOption { + readonly id: EditorOptionId; + readonly name: PossibleKeyName; + readonly defaultValue: T2; + constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T2, deps?: EditorOptionId[]); + read(options: IRawEditorOptionsBag): T1 | undefined; + mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; + abstract validate(input: T1 | undefined): T2; + abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; + equals(a: T3, b: T3): boolean; + } + + export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + + export enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 + } + + export interface InternalEditorRenderLineNumbersOptions { + readonly renderType: RenderLineNumbersType; + readonly renderFn: ((lineNumber: number) => string) | null; + } + + export interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly side: 'right' | 'left'; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; + } + + export interface InternalEditorScrollbarOptions { + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; + } + /** * A description for the overview ruler position. */ @@ -3518,62 +3590,65 @@ declare namespace monaco.editor { readonly overviewRuler: OverviewRulerPosition; } - /** - * An event describing that the configuration of the editor has changed. - */ - export interface IConfigurationChangedEvent { - hasChanged(id: EditorOptionId): boolean; - readonly canUseLayerHinting: boolean; - readonly pixelRatio: boolean; - readonly editorClassName: boolean; - readonly lineHeight: boolean; - readonly readOnly: boolean; - readonly accessibilitySupport: boolean; - readonly multiCursorModifier: boolean; - readonly multiCursorMergeOverlapping: boolean; - readonly wordSeparators: boolean; - readonly autoClosingBrackets: boolean; - readonly autoClosingQuotes: boolean; - readonly autoClosingOvertype: boolean; - readonly autoSurround: boolean; - readonly autoIndent: boolean; - readonly useTabStops: boolean; - readonly tabFocusMode: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; - readonly layoutInfo: boolean; - readonly fontInfo: boolean; - readonly viewInfo: boolean; - readonly wrappingInfo: boolean; - readonly contribInfo: boolean; - } - - export interface IRawEditorOptionsBag { - [key: string]: any; - } - - export interface IEditorOption { - readonly id: EditorOptionId; - readonly name: string; - readonly defaultValue: T1; - read(options: IRawEditorOptionsBag): T1 | undefined; - mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; - validate(input: T1 | undefined): T2; - compute(value: T2): T3; - equals(a: T3, b: T3): boolean; + export interface EditorWrappingInfo { + readonly isDominatedByLongLines: boolean; + readonly isWordWrapMinified: boolean; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; } export enum EditorOptionId { - renderFinalNewline = 0, - selectionClipboard = 1, - selectOnLineNumbers = 2 + accessibilitySupport = 0, + ariaLabel = 1, + fastScrollSensitivity = 2, + folding = 3, + glyphMargin = 4, + inDiffEditor = 5, + lineDecorationsWidth = 6, + lineNumbersMinChars = 7, + minimap = 8, + mouseWheelScrollSensitivity = 9, + renderFinalNewline = 10, + renderLineNumbers = 11, + scrollbar = 12, + selectionClipboard = 13, + selectOnLineNumbers = 14, + wordWrap = 15, + wordWrapBreakAfterCharacters = 16, + wordWrapBreakBeforeCharacters = 17, + wordWrapBreakObtrusiveCharacters = 18, + wordWrapColumn = 19, + wordWrapMinified = 20, + wrappingIndent = 21, + layoutInfo = 22, + wrappingInfo = 23 } export const EditorOption: { + accessibilitySupport: IEditorOption<"auto" | "on" | "off", "auto" | "on" | "off", any>; + ariaLabel: IEditorOption; + fastScrollSensitivity: IEditorOption; + folding: IEditorOption; + glyphMargin: IEditorOption; + inDiffEditor: IEditorOption; + lineDecorationsWidth: IEditorOption; + lineNumbersMinChars: IEditorOption; + minimap: IEditorOption; + mouseWheelScrollSensitivity: IEditorOption; renderFinalNewline: IEditorOption; + renderLineNumbers: IEditorOption; + scrollbar: IEditorOption; selectionClipboard: IEditorOption; selectOnLineNumbers: IEditorOption; + wordWrap: IEditorOption<"on" | "off" | "wordWrapColumn" | "bounded", "on" | "off" | "wordWrapColumn" | "bounded", "on" | "off" | "wordWrapColumn" | "bounded">; + wordWrapBreakAfterCharacters: IEditorOption; + wordWrapBreakBeforeCharacters: IEditorOption; + wordWrapBreakObtrusiveCharacters: IEditorOption; + wordWrapColumn: IEditorOption; + wordWrapMinified: IEditorOption; + wrappingIndent: IEditorOption<"none" | "same" | "indent" | "deepIndent", "none" | "same" | "indent" | "deepIndent", WrappingIndent>; + layoutInfo: IEditorOption; + wrappingInfo: IEditorOption; }; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; @@ -4027,6 +4102,7 @@ declare namespace monaco.editor { * Returns the current editor's configuration */ getConfiguration(): InternalEditorOptions; + getOptions(): IComputedEditorOptions; getOption>(id: EditorOptionId): ComputedEditorOptionValue; /** * Get value of the current model attached to this editor. diff --git a/src/vs/workbench/api/browser/mainThreadEditor.ts b/src/vs/workbench/api/browser/mainThreadEditor.ts index ff8e1cd513813..10437ec2ed6ff 100644 --- a/src/vs/workbench/api/browser/mainThreadEditor.ts +++ b/src/vs/workbench/api/browser/mainThreadEditor.ts @@ -6,7 +6,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -59,8 +59,10 @@ export class MainThreadTextEditorProperties { let lineNumbers: RenderLineNumbersType; if (codeEditor) { const codeEditorOpts = codeEditor.getConfiguration(); + const options = codeEditor.getOptions(); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); cursorStyle = codeEditorOpts.viewInfo.cursorStyle; - lineNumbers = codeEditorOpts.viewInfo.renderLineNumbers; + lineNumbers = renderLineNumbers.renderType; } else if (previousProperties) { cursorStyle = previousProperties.options.cursorStyle; lineNumbers = previousProperties.options.lineNumbers; diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index ed5bbacdd3e29..f96fcd3b787cf 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -35,7 +35,7 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ITextFileService, SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; -import { IConfigurationChangedEvent, IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, IEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { deepClone } from 'vs/base/common/objects'; @@ -584,7 +584,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { // Hook Listener for Configuration changes this.activeEditorListeners.add(activeCodeEditor.onDidChangeConfiguration((event: IConfigurationChangedEvent) => { - if (event.accessibilitySupport) { + if (event.hasChanged(EditorOptionId.accessibilitySupport)) { this.onScreenReaderModeChange(activeCodeEditor); } })); diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts index eb15bf10a1fb6..e8472a05fe634 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts @@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; -import { EDITOR_DEFAULTS, InternalEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; @@ -68,7 +68,7 @@ function readWordWrapState(model: ITextModel, configurationService: ITextResourc const _transientState = readTransientState(model, codeEditorService); return { configuredWordWrap: _configuredWordWrap, - configuredWordWrapMinified: (typeof _configuredWordWrapMinified === 'boolean' ? _configuredWordWrapMinified : EDITOR_DEFAULTS.wordWrapMinified), + configuredWordWrapMinified: (typeof _configuredWordWrapMinified === 'boolean' ? _configuredWordWrapMinified : EditorOption.wordWrapMinified.defaultValue), transientState: _transientState }; } @@ -83,10 +83,9 @@ function toggleWordWrap(editor: ICodeEditor, state: IWordWrapState): IWordWrapSt }; } - const config = editor.getConfiguration(); let transientState: IWordWrapTransientState; - const actualWrappingInfo = config.wrappingInfo; + const actualWrappingInfo = editor.getOption(EditorOptionId.wrappingInfo); if (actualWrappingInfo.isWordWrapMinified) { // => wrapping due to minified file transientState = { @@ -139,8 +138,7 @@ class ToggleWordWrapAction extends EditorAction { if (!editor.hasModel()) { return; } - const editorConfiguration = editor.getConfiguration(); - if (editorConfiguration.wrappingInfo.inDiffEditor) { + if (editor.getOption(EditorOptionId.inDiffEditor)) { // Cannot change wrapping settings inside the diff editor const notificationService = accessor.get(INotificationService); notificationService.info(nls.localize('wordWrap.notInDiffEditor', "Cannot toggle word wrap in a diff editor.")); @@ -177,20 +175,22 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution ) { super(); - const configuration = this.editor.getConfiguration(); - const isWordWrapMinified = this.contextKeyService.createKey(isWordWrapMinifiedKey, this._isWordWrapMinified(configuration)); - const isDominatedByLongLines = this.contextKeyService.createKey(isDominatedByLongLinesKey, this._isDominatedByLongLines(configuration)); - const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, this._inDiffEditor(configuration)); + const options = this.editor.getOptions(); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const isWordWrapMinified = this.contextKeyService.createKey(isWordWrapMinifiedKey, wrappingInfo.isWordWrapMinified); + const isDominatedByLongLines = this.contextKeyService.createKey(isDominatedByLongLinesKey, wrappingInfo.isDominatedByLongLines); + const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOptionId.inDiffEditor)); let currentlyApplyingEditorConfig = false; this._register(editor.onDidChangeConfiguration((e) => { - if (!e.wrappingInfo) { + if (!e.hasChanged(EditorOptionId.wrappingInfo) || !e.hasChanged(EditorOptionId.inDiffEditor)) { return; } - const configuration = this.editor.getConfiguration(); - isWordWrapMinified.set(this._isWordWrapMinified(configuration)); - isDominatedByLongLines.set(this._isDominatedByLongLines(configuration)); - inDiffEditor.set(this._inDiffEditor(configuration)); + const options = this.editor.getOptions(); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + isWordWrapMinified.set(wrappingInfo.isWordWrapMinified); + isDominatedByLongLines.set(wrappingInfo.isDominatedByLongLines); + inDiffEditor.set(options.get(EditorOptionId.inDiffEditor)); if (!currentlyApplyingEditorConfig) { // I am not the cause of the word wrap getting changed ensureWordWrapSettings(); @@ -216,8 +216,7 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution return; } - const configuration = this.editor.getConfiguration(); - if (this._inDiffEditor(configuration)) { + if (this.editor.getOption(EditorOptionId.inDiffEditor)) { return; } @@ -255,18 +254,6 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution }); } - private _isWordWrapMinified(config: InternalEditorOptions): boolean { - return config.wrappingInfo.isWordWrapMinified; - } - - private _isDominatedByLongLines(config: InternalEditorOptions): boolean { - return config.wrappingInfo.isDominatedByLongLines; - } - - private _inDiffEditor(config: InternalEditorOptions): boolean { - return config.wrappingInfo.inDiffEditor; - } - public getId(): string { return ToggleWordWrapController._ID; } diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index d5cfcfb4f19dc..94a1a35948188 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -37,6 +37,7 @@ import { COMMENTEDITOR_DECORATION_KEY, ReviewZoneWidget } from 'vs/workbench/con import { ctxCommentEditorFocused, SimpleCommentEditor } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; export const ID = 'editor.contrib.review'; @@ -590,7 +591,7 @@ export class ReviewController implements IEditorContribution { } this._commentInfos = commentInfos; - let lineDecorationsWidth: number = this.editor.getConfiguration().layoutInfo.decorationsWidth; + let lineDecorationsWidth: number = this.editor.getLayoutInfo().decorationsWidth; if (this._commentInfos.some(info => Boolean(info.commentingRanges && (Array.isArray(info.commentingRanges) ? info.commentingRanges : info.commentingRanges.ranges).length))) { if (!this._commentingRangeSpaceReserved) { @@ -601,7 +602,8 @@ export class ReviewController implements IEditorContribution { extraEditorClassName = configuredExtraClassName.split(' '); } - if (this.editor.getConfiguration().contribInfo.folding) { + const options = this.editor.getOptions(); + if (options.get(EditorOptionId.folding)) { lineDecorationsWidth -= 16; } lineDecorationsWidth += 9; diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 66678cbfffb4c..6b7383786097c 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -33,6 +33,7 @@ import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/p import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences'; +import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class SettingsHeaderWidget extends Widget implements IViewZone { @@ -85,8 +86,9 @@ export class SettingsHeaderWidget extends Widget implements IViewZone { private layout(): void { const configuration = this.editor.getConfiguration(); + const options = this.editor.getOptions(); this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; - if (!configuration.contribInfo.folding) { + if (!options.get(EditorOptionId.folding)) { this.titleContainer.style.paddingLeft = '6px'; } } diff --git a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts index 3dcbb07c16c52..eaafa00f21b54 100644 --- a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts @@ -16,7 +16,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IRange } from 'vs/editor/common/core/range'; import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; -import { IEditorOptions, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RenderLineNumbersType, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; @@ -50,8 +50,9 @@ export class GotoLineAction extends QuickOpenAction { let restoreOptions: IEditorOptions | null = null; if (isCodeEditor(activeTextEditorWidget)) { - const config = activeTextEditorWidget.getConfiguration(); - if (config.viewInfo.renderLineNumbers === RenderLineNumbersType.Relative) { + const options = activeTextEditorWidget.getOptions(); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + if (renderLineNumbers.renderType === RenderLineNumbersType.Relative) { activeTextEditorWidget.updateOptions({ lineNumbers: 'on' }); From 9ab08c2d308c30ce3774afa110dd1082959ac4ad Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Sep 2019 00:19:00 +0200 Subject: [PATCH 006/204] Adopt conditional types for editor options reading --- .../editor/browser/controller/mouseHandler.ts | 10 +- .../editor/browser/controller/mouseTarget.ts | 6 +- .../browser/controller/textAreaHandler.ts | 16 +- src/vs/editor/browser/editorBrowser.ts | 19 ++- src/vs/editor/browser/view/viewImpl.ts | 5 +- src/vs/editor/browser/view/viewOverlays.ts | 11 +- .../contentWidgets/contentWidgets.ts | 7 +- .../currentLineHighlight.ts | 7 +- .../currentLineMarginHighlight.ts | 7 +- .../editorScrollbar/editorScrollbar.ts | 18 +-- .../viewParts/glyphMargin/glyphMargin.ts | 7 +- .../viewParts/indentGuides/indentGuides.ts | 7 +- .../viewParts/lineNumbers/lineNumbers.ts | 8 +- .../browser/viewParts/lines/viewLines.ts | 6 +- .../linesDecorations/linesDecorations.ts | 7 +- .../editor/browser/viewParts/margin/margin.ts | 7 +- .../browser/viewParts/minimap/minimap.ts | 6 +- .../overlayWidgets/overlayWidgets.ts | 7 +- .../overviewRuler/decorationsOverviewRuler.ts | 6 +- .../scrollDecoration/scrollDecoration.ts | 9 +- .../viewParts/viewCursors/viewCursors.ts | 10 +- .../browser/viewParts/viewZones/viewZones.ts | 7 +- .../editor/browser/widget/codeEditorWidget.ts | 48 +++--- .../editor/browser/widget/diffEditorWidget.ts | 32 ++-- src/vs/editor/browser/widget/diffReview.ts | 4 +- .../editor/browser/widget/inlineDiffMargin.ts | 3 +- .../common/config/commonEditorConfig.ts | 99 ++++++------ src/vs/editor/common/config/editorOptions.ts | 142 ++++++++++-------- src/vs/editor/common/controller/cursor.ts | 3 +- .../editor/common/controller/cursorCommon.ts | 8 +- .../common/standalone/standaloneEnums.ts | 30 ++-- src/vs/editor/common/view/viewEvents.ts | 2 - src/vs/editor/common/viewLayout/viewLayout.ts | 10 +- .../common/viewModel/viewModelDecorations.ts | 3 +- .../editor/common/viewModel/viewModelImpl.ts | 20 +-- .../contrib/codeAction/codeActionModel.ts | 3 +- src/vs/editor/contrib/find/findController.ts | 3 +- src/vs/editor/contrib/find/findWidget.ts | 10 +- src/vs/editor/contrib/folding/folding.ts | 6 +- src/vs/editor/contrib/hover/hover.ts | 4 +- src/vs/editor/contrib/suggest/suggestModel.ts | 3 +- .../accessibilityHelp/accessibilityHelp.ts | 13 +- .../iPadShowKeyboard/iPadShowKeyboard.ts | 3 +- .../common/config/commonEditorConfig.test.ts | 4 +- .../viewModel/splitLinesCollection.test.ts | 23 +-- src/vs/monaco.d.ts | 110 +++++++------- .../workbench/api/browser/mainThreadEditor.ts | 4 +- .../browser/parts/editor/editorStatus.ts | 7 +- .../browser/accessibility/accessibility.ts | 10 +- .../codeEditor/browser/selectionClipboard.ts | 6 +- .../codeEditor/browser/toggleWordWrap.ts | 16 +- .../browser/commentsEditorContribution.ts | 4 +- .../debug/browser/debugEditorContribution.ts | 4 +- .../browser/keybindingsEditorContribution.ts | 5 +- .../preferences/browser/preferencesWidgets.ts | 4 +- .../quickopen/browser/gotoLineHandler.ts | 4 +- .../bulkEdit/browser/bulkEditService.ts | 3 +- 57 files changed, 442 insertions(+), 404 deletions(-) diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index ce65849c4184e..a28b811da241d 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -21,7 +21,8 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + /** * Merges mouse events when mouse move events are throttled @@ -217,7 +218,7 @@ export class MouseHandler extends ViewEventHandler { const targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY); const targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS); const targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS); - const selectOnLineNumbers = this._context.configuration.options.get(EditorOptionId.selectOnLineNumbers); + const selectOnLineNumbers = this._context.configuration.options.get(EditorOptionId.selectOnLineNumbers); const targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE); const targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET); @@ -352,7 +353,10 @@ class MouseDownOperation extends Disposable { // Overwrite the detail of the MouseEvent, as it will be sent out in an event and contributions might rely on it. e.detail = this._mouseState.count; - if (!this._context.configuration.editor.readOnly + const options = this._context.configuration.options; + const readOnly = options.get(EditorOptionId.readOnly); + + if (!readOnly && this._context.configuration.editor.dragAndDrop && !this._mouseState.altKey // we don't support multiple mouse && e.detail < 2 // only single click on a selection can work diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index 58948e740aa73..cde6cad5f2dfc 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -10,7 +10,7 @@ import { ClientCoordinates, EditorMouseEvent, EditorPagePosition, PageCoordinate import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart'; import { ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine'; import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; -import { EditorLayoutInfo, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorLayoutInfo, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range as EditorRange } from 'vs/editor/common/core/range'; import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; @@ -240,7 +240,7 @@ export class HitTestContext { constructor(context: ViewContext, viewHelper: IPointerHandlerHelper, lastViewCursorsRenderData: IViewCursorRenderData[]) { this.model = context.model; const options = context.configuration.options; - this.layoutInfo = options.get(EditorOptionId.layoutInfo); + this.layoutInfo = options.get(EditorOptionId.layoutInfo); this.viewDomNode = viewHelper.viewDomNode; this.lineHeight = context.configuration.editor.lineHeight; this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; @@ -715,7 +715,7 @@ export class MouseTargetFactory { public getMouseColumn(editorPos: EditorPagePosition, pos: PageCoordinates): number { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); const mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft; return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index bfefbfff922e9..c02aaef8ecd22 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -16,7 +16,7 @@ import { ViewController } from 'vs/editor/browser/view/viewController'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; import { LineNumbersOverlay } from 'vs/editor/browser/viewParts/lineNumbers/lineNumbers'; import { Margin } from 'vs/editor/browser/viewParts/margin/margin'; -import { RenderLineNumbersType, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { BareFontInfo } from 'vs/editor/common/config/fontInfo'; import { WordCharacterClass, getMapForWordSeparators } from 'vs/editor/common/controller/wordCharacterClassifier'; import { Position } from 'vs/editor/common/core/position'; @@ -120,9 +120,9 @@ export class TextAreaHandler extends ViewPart { const conf = this._context.configuration.editor; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); - this._accessibilitySupport = conf.accessibilitySupport; + this._accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; @@ -145,7 +145,7 @@ export class TextAreaHandler extends ViewPart { this.textArea.setAttribute('autocapitalize', 'off'); this.textArea.setAttribute('autocomplete', 'off'); this.textArea.setAttribute('spellcheck', 'false'); - this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); + this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); this.textArea.setAttribute('role', 'textbox'); this.textArea.setAttribute('aria-multiline', 'true'); this.textArea.setAttribute('aria-haspopup', 'false'); @@ -379,10 +379,10 @@ export class TextAreaHandler extends ViewPart { this._fontInfo = conf.fontInfo; } if (e.viewInfo) { - this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); + this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); } if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; @@ -391,7 +391,7 @@ export class TextAreaHandler extends ViewPart { this._lineHeight = conf.lineHeight; } if (e.hasChanged(EditorOptionId.accessibilitySupport)) { - this._accessibilitySupport = conf.accessibilitySupport; + this._accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); this._textAreaInput.writeScreenReaderContent('strategy changed'); } if (e.emptySelectionClipboard) { @@ -553,7 +553,7 @@ export class TextAreaHandler extends ViewPart { if (this._context.configuration.editor.viewInfo.glyphMargin) { tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME); } else { - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); if (renderLineNumbers.renderType !== RenderLineNumbersType.Off) { tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME); } else { diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index de7dcc54683f3..5e94f07990bd6 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -6,7 +6,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IMouseEvent, IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; import { IDisposable } from 'vs/base/common/lifecycle'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { OverviewRulerPosition, IConfigurationChangedEvent, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOptionId, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { IPosition, Position } from 'vs/editor/common/core/position'; @@ -315,7 +315,7 @@ export interface IOverviewRuler { getDomNode(): HTMLElement; dispose(): void; setZones(zones: OverviewRulerZone[]): void; - setLayout(position: editorOptions.OverviewRulerPosition): void; + setLayout(position: OverviewRulerPosition): void; } /** @@ -351,7 +351,7 @@ export interface ICodeEditor extends editorCommon.IEditor { * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) * @event */ - onDidChangeConfiguration(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable; + onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; /** * An event emitted when the cursor position has changed. * @event @@ -481,7 +481,7 @@ export interface ICodeEditor extends editorCommon.IEditor { * An event emitted when the layout of the editor has changed. * @event */ - onDidLayoutChange(listener: (e: editorOptions.EditorLayoutInfo) => void): IDisposable; + onDidLayoutChange(listener: (e: EditorLayoutInfo) => void): IDisposable; /** * An event emitted when the scroll in the editor has changed. * @event @@ -534,17 +534,16 @@ export interface ICodeEditor extends editorCommon.IEditor { /** * Returns the current editor's configuration */ - getConfiguration(): editorOptions.InternalEditorOptions; + getConfiguration(): InternalEditorOptions; - getOptions(): editorOptions.IComputedEditorOptions; - - getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue; + getOptions(): IComputedEditorOptions; + getOption(id: T): FindComputedEditorOptionValueById; /** * Returns the 'raw' editor's configuration (without any validation or defaults). * @internal */ - getRawConfiguration(): editorOptions.IEditorOptions; + getRawConfiguration(): IEditorOptions; /** * Get value of the current model attached to this editor. @@ -659,7 +658,7 @@ export interface ICodeEditor extends editorCommon.IEditor { /** * Get the layout info for the editor. */ - getLayoutInfo(): editorOptions.EditorLayoutInfo; + getLayoutInfo(): EditorLayoutInfo; /** * Returns the ranges that are currently visible. diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 67fca03779377..41a04db7b4a6a 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -48,7 +48,8 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData' import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export interface IContentWidgetData { widget: editorBrowser.IContentWidget; @@ -283,7 +284,7 @@ export class View extends ViewEventHandler { private _setLayout(): void { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.domNode.setWidth(layoutInfo.width); this.domNode.setHeight(layoutInfo.height); diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index 5182408db5aea..5e0015eb0a90d 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -14,7 +14,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class ViewOverlays extends ViewPart implements IVisibleLinesHost { @@ -217,7 +218,7 @@ export class ContentViewOverlays extends ViewOverlays { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentWidth = layoutInfo.contentWidth; this.domNode.setHeight(0); @@ -228,7 +229,7 @@ export class ContentViewOverlays extends ViewOverlays { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentWidth = layoutInfo.contentWidth; } return super.onConfigurationChanged(e); @@ -254,7 +255,7 @@ export class MarginViewOverlays extends ViewOverlays { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this.domNode.setClassName('margin-view-overlays'); @@ -271,7 +272,7 @@ export class MarginViewOverlays extends ViewOverlays { } if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; shouldRender = true; } diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index 9c7998b742722..6975b25a6bc7f 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -14,7 +14,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + class Coordinate { _coordinateBrand: void; @@ -209,7 +210,7 @@ class Widget { this.suppressMouseDown = this._actual.suppressMouseDown || false; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets; this._contentWidth = layoutInfo.contentWidth; @@ -239,7 +240,7 @@ class Widget { } if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._maxWidth = this._getMaxWidth(); diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index 65343ec07eb8c..63aa133402253 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -10,7 +10,8 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class CurrentLineHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; @@ -25,7 +26,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; @@ -55,7 +56,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { } if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentWidth = layoutInfo.contentWidth; } return true; diff --git a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts index 1389ed0e1b0dd..3601770f5b8f6 100644 --- a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts @@ -10,7 +10,8 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; @@ -24,7 +25,7 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; @@ -51,7 +52,7 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { } if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; } return true; diff --git a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts index 24185fbc1c54c..df5316bfb8043 100644 --- a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts +++ b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts @@ -14,7 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class EditorScrollbar extends ViewPart { @@ -31,9 +31,9 @@ export class EditorScrollbar extends ViewPart { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); - const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); - const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); + const scrollbar = options.get(EditorOptionId.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); const scrollbarOptions: ScrollableElementCreationOptions = { listenOnDomNode: viewDomNode.domNode, @@ -101,11 +101,11 @@ export class EditorScrollbar extends ViewPart { private _setLayout(): void { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.scrollbarDomNode.setLeft(layoutInfo.contentLeft); - const minimap = options.get(EditorOptionId.minimap); + const minimap = options.get(EditorOptionId.minimap); const side = minimap.side; if (side === 'right') { this.scrollbarDomNode.setWidth(layoutInfo.contentWidth + layoutInfo.minimapWidth); @@ -136,9 +136,9 @@ export class EditorScrollbar extends ViewPart { || e.hasChanged(EditorOptionId.fastScrollSensitivity) ) { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); - const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); - const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); + const scrollbar = options.get(EditorOptionId.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); const newOpts: ScrollableElementChangeOptions = { handleMouseWheel: scrollbar.handleMouseWheel, mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, diff --git a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts index c063c6680715c..516cdb1f4686c 100644 --- a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts +++ b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts @@ -8,7 +8,8 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class DecorationToRender { _decorationToRenderBrand: void; @@ -86,7 +87,7 @@ export class GlyphMarginOverlay extends DedupOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; this._glyphMarginLeft = layoutInfo.glyphMarginLeft; @@ -113,7 +114,7 @@ export class GlyphMarginOverlay extends DedupOverlay { this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; } if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; } diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index a8ba2a3936aa5..9da6446edf96b 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -11,7 +11,8 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class IndentGuidesOverlay extends DynamicViewOverlay { @@ -33,7 +34,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); @@ -63,7 +64,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; } if (e.hasChanged(EditorOptionId.wrappingInfo) || e.fontInfo) { - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index d07bbdc92aef9..aa078b1b8341c 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -6,7 +6,7 @@ import 'vs/css!./lineNumbers'; import * as platform from 'vs/base/common/platform'; import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; -import { RenderLineNumbersType, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { editorActiveLineNumber, editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -44,11 +44,11 @@ export class LineNumbersOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const config = this._context.configuration.editor; this._lineHeight = config.lineHeight; - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); this._renderLineNumbers = renderLineNumbers.renderType; this._renderCustomLineNumbers = renderLineNumbers.renderFn; - this._renderFinalNewline = options.get(EditorOptionId.renderFinalNewline); - const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._renderFinalNewline = options.get(EditorOptionId.renderFinalNewline); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineNumbersLeft = layoutInfo.lineNumbersLeft; this._lineNumbersWidth = layoutInfo.lineNumbersWidth; } diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 2e64c0c8056c8..80c851b008410 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -18,7 +18,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { Viewport } from 'vs/editor/common/viewModel/viewModel'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; class LastRenderedData { @@ -92,7 +92,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const conf = this._context.configuration; const options = this._context.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); this._lineHeight = conf.editor.lineHeight; this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; @@ -152,7 +152,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; } if (e.hasChanged(EditorOptionId.wrappingInfo)) { - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); this._isViewportWrapping = wrappingInfo.isViewportWrapping; } if (e.viewInfo) { diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts index 1d709f5b917b4..4beec4716a164 100644 --- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts +++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts @@ -8,7 +8,8 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class LinesDecorationsOverlay extends DedupOverlay { @@ -22,7 +23,7 @@ export class LinesDecorationsOverlay extends DedupOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._decorationsLeft = layoutInfo.decorationsLeft; this._decorationsWidth = layoutInfo.decorationsWidth; this._renderResult = null; @@ -40,7 +41,7 @@ export class LinesDecorationsOverlay extends DedupOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._decorationsLeft = layoutInfo.decorationsLeft; this._decorationsWidth = layoutInfo.decorationsWidth; } diff --git a/src/vs/editor/browser/viewParts/margin/margin.ts b/src/vs/editor/browser/viewParts/margin/margin.ts index f49a24845e7a9..79cc1b4f500f2 100644 --- a/src/vs/editor/browser/viewParts/margin/margin.ts +++ b/src/vs/editor/browser/viewParts/margin/margin.ts @@ -8,7 +8,8 @@ import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class Margin extends ViewPart { @@ -25,7 +26,7 @@ export class Margin extends ViewPart { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; this._contentLeft = layoutInfo.contentLeft; @@ -62,7 +63,7 @@ export class Margin extends ViewPart { } if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 747ef26183079..ce8218c915f06 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -13,7 +13,7 @@ import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ILine, RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; -import { RenderMinimap, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderMinimap, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { RGBA8 } from 'vs/editor/common/core/rgba'; import { IConfiguration, ScrollType } from 'vs/editor/common/editorCommon'; @@ -109,13 +109,13 @@ class MinimapOptions { constructor(configuration: IConfiguration) { const options = configuration.options; const pixelRatio = configuration.editor.pixelRatio; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); const viewInfo = configuration.editor.viewInfo; const fontInfo = configuration.editor.fontInfo; this.renderMinimap = layoutInfo.renderMinimap | 0; this.scrollBeyondLastLine = viewInfo.scrollBeyondLastLine; - const minimapOpts = options.get(EditorOptionId.minimap); + const minimapOpts = options.get(EditorOptionId.minimap); this.showSlider = minimapOpts.showSlider; this.pixelRatio = pixelRatio; this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; diff --git a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts index 0fa9087323df6..2d1380345688d 100644 --- a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts +++ b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts @@ -10,7 +10,8 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + interface IWidgetData { widget: IOverlayWidget; @@ -37,7 +38,7 @@ export class ViewOverlayWidgets extends ViewPart { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._widgets = {}; this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; @@ -66,7 +67,7 @@ export class ViewOverlayWidgets extends ViewPart { const options = this._context.configuration.options; if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; this._minimapWidth = layoutInfo.minimapWidth; this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index b620c0ed4ea85..463a4592c2768 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -15,7 +15,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ITheme } from 'vs/platform/theme/common/themeService'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; class Settings { @@ -58,7 +58,7 @@ class Settings { this.themeType = theme.type; - const minimapOpts = options.get(EditorOptionId.minimap); + const minimapOpts = options.get(EditorOptionId.minimap); const minimapEnabled = minimapOpts.enabled; const minimapSide = minimapOpts.side; const backgroundColor = (minimapEnabled ? TokenizationRegistry.getDefaultBackground() : null); @@ -68,7 +68,7 @@ class Settings { this.backgroundColor = Color.Format.CSS.formatHex(backgroundColor); } - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); const position = layoutInfo.overviewRuler; this.top = position.top; this.right = position.right; diff --git a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts index d3b4ae392cdd7..8a482e5603101 100644 --- a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts +++ b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts @@ -11,7 +11,8 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export class ScrollDecorationViewPart extends ViewPart { @@ -29,7 +30,7 @@ export class ScrollDecorationViewPart extends ViewPart { this._updateWidth(); this._shouldShow = false; const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOptionId.scrollbar); this._useShadows = scrollbar.useShadows; this._domNode = createFastDomNode(document.createElement('div')); this._domNode.setAttribute('role', 'presentation'); @@ -55,7 +56,7 @@ export class ScrollDecorationViewPart extends ViewPart { private _updateWidth(): boolean { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); let newWidth = 0; if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) { newWidth = layoutInfo.width; @@ -75,7 +76,7 @@ export class ScrollDecorationViewPart extends ViewPart { let shouldRender = false; if (e.hasChanged(EditorOptionId.scrollbar)) { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOptionId.scrollbar); this._useShadows = scrollbar.useShadows; } if (e.hasChanged(EditorOptionId.layoutInfo)) { diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts index 023e031dd0279..ede284d354316 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts @@ -8,7 +8,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IntervalTimer, TimeoutTimer } from 'vs/base/common/async'; import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { IViewCursorRenderData, ViewCursor } from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; -import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions'; +import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { editorCursorBackground, editorCursorForeground } from 'vs/editor/common/view/editorColorRegistry'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -43,7 +43,8 @@ export class ViewCursors extends ViewPart { constructor(context: ViewContext) { super(context); - this._readOnly = this._context.configuration.editor.readOnly; + const options = this._context.configuration.options; + this._readOnly = options.get(EditorOptionId.readOnly); this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation; @@ -84,9 +85,10 @@ export class ViewCursors extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { + const options = this._context.configuration.options; - if (e.readOnly) { - this._readOnly = this._context.configuration.editor.readOnly; + if (e.hasChanged(EditorOptionId.readOnly)) { + this._readOnly = options.get(EditorOptionId.readOnly); } if (e.viewInfo) { this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; diff --git a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts index 3e0f58f547542..13bf932d19b3a 100644 --- a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts +++ b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts @@ -12,7 +12,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { IViewWhitespaceViewportData } from 'vs/editor/common/viewModel/viewModel'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + export interface IMyViewZone { whitespaceId: string; @@ -42,7 +43,7 @@ export class ViewZones extends ViewPart { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._contentWidth = layoutInfo.contentWidth; @@ -96,7 +97,7 @@ export class ViewZones extends ViewPart { } if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index ca2133d8ab22d..d0cdffa1ca28f 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl'; import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOptionId, InternalEditorOptions, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; import { Cursor, CursorStateChangedEvent } from 'vs/editor/common/controller/cursor'; import { CursorColumns, ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; @@ -125,8 +125,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE private readonly _onDidChangeModelDecorations: Emitter = this._register(new Emitter()); public readonly onDidChangeModelDecorations: Event = this._onDidChangeModelDecorations.event; - private readonly _onDidChangeConfiguration: Emitter = this._register(new Emitter()); - public readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; + private readonly _onDidChangeConfiguration: Emitter = this._register(new Emitter()); + public readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; protected readonly _onDidChangeModel: Emitter = this._register(new Emitter()); public readonly onDidChangeModel: Event = this._onDidChangeModel.event; @@ -140,8 +140,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE private readonly _onDidAttemptReadOnlyEdit: Emitter = this._register(new Emitter()); public readonly onDidAttemptReadOnlyEdit: Event = this._onDidAttemptReadOnlyEdit.event; - private readonly _onDidLayoutChange: Emitter = this._register(new Emitter()); - public readonly onDidLayoutChange: Event = this._onDidLayoutChange.event; + private readonly _onDidLayoutChange: Emitter = this._register(new Emitter()); + public readonly onDidLayoutChange: Event = this._onDidLayoutChange.event; private readonly _editorTextFocus: BooleanEventEmitter = this._register(new BooleanEventEmitter()); public readonly onDidFocusEditorText: Event = this._editorTextFocus.onDidChangeToTrue; @@ -236,7 +236,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE constructor( domElement: HTMLElement, - options: editorOptions.IEditorOptions, + options: IEditorOptions, codeEditorWidgetOptions: ICodeEditorWidgetOptions, @IInstantiationService instantiationService: IInstantiationService, @ICodeEditorService codeEditorService: ICodeEditorService, @@ -259,9 +259,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._register(this._configuration.onDidChange((e) => { this._onDidChangeConfiguration.fire(e); - if (e.hasChanged(editorOptions.EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._configuration.options; - const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._onDidLayoutChange.fire(layoutInfo); } if (this._configuration.editor.showUnused) { @@ -329,7 +329,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._codeEditorService.addCodeEditor(this); } - protected _createConfiguration(options: editorOptions.IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration { + protected _createConfiguration(options: IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration { return new Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService); } @@ -364,23 +364,23 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE return this._instantiationService.invokeFunction(fn); } - public updateOptions(newOptions: editorOptions.IEditorOptions): void { + public updateOptions(newOptions: IEditorOptions): void { this._configuration.updateOptions(newOptions); } - public getConfiguration(): editorOptions.InternalEditorOptions { + public getConfiguration(): InternalEditorOptions { return this._configuration.editor; } - public getOptions(): editorOptions.IComputedEditorOptions { + public getOptions(): IComputedEditorOptions { return this._configuration.options; } - public getOption>(id: editorOptions.EditorOptionId): editorOptions.ComputedEditorOptionValue { - return this._configuration.options.get(id); + public getOption(id: T): FindComputedEditorOptionValueById { + return this._configuration.options.get(id); } - public getRawConfiguration(): editorOptions.IEditorOptions { + public getRawConfiguration(): IEditorOptions { return this._configuration.getRawOptions(); } @@ -982,7 +982,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return false; } - if (this._configuration.editor.readOnly) { + if (this._configuration.options.get(EditorOptionId.readOnly)) { // read only editor => sorry! return false; } @@ -994,7 +994,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return false; } - if (this._configuration.editor.readOnly) { + if (this._configuration.options.get(EditorOptionId.readOnly)) { // read only editor => sorry! return false; } @@ -1038,7 +1038,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return null; } - return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.editor.readOnly); + return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.options.get(EditorOptionId.readOnly)); } public deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[] { @@ -1129,9 +1129,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } } - public getLayoutInfo(): editorOptions.EditorLayoutInfo { + public getLayoutInfo(): EditorLayoutInfo { const options = this._configuration.options; - const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); return layoutInfo; } @@ -1281,7 +1281,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE const position = this._modelData.model.validatePosition(rawPosition); const options = this._configuration.options; - const layoutInfo = options.get(editorOptions.EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); const top = CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, position.lineNumber, position.column) - this.getScrollTop(); const left = this._modelData.view.getOffsetForColumn(position.lineNumber, position.column) + layoutInfo.glyphMarginWidth + layoutInfo.lineNumbersWidth + layoutInfo.decorationsWidth - this.getScrollLeft(); @@ -1614,10 +1614,10 @@ class EditorContextKeysManager extends Disposable { } private _updateFromConfig(): void { - const config = this._editor.getConfiguration(); + const options = this._editor.getOptions(); - this._editorTabMovesFocus.set(config.tabFocusMode); - this._editorReadonly.set(config.readOnly); + this._editorTabMovesFocus.set(options.get(EditorOptionId.tabFocusMode)); + this._editorReadonly.set(options.get(EditorOptionId.readOnly)); } private _updateFromSelection(): void { diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index da9e1ddf553bb..d2ba7bd565d35 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -20,7 +20,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { DiffReview } from 'vs/editor/browser/widget/diffReview'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { IDiffEditorOptions, IEditorOptions, EDITOR_DEFAULTS, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -213,7 +213,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE constructor( domElement: HTMLElement, - options: editorOptions.IDiffEditorOptions, + options: IDiffEditorOptions, @IEditorWorkerService editorWorkerService: IEditorWorkerService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService instantiationService: IInstantiationService, @@ -422,7 +422,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE this._layoutOverviewRulers(); } - private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget { + private _createLeftHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget { const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable)); this._register(editor.onDidScrollChange((e) => { @@ -455,7 +455,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return editor; } - private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget { + private _createRightHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget { const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options)); this._register(editor.onDidScrollChange((e) => { @@ -494,7 +494,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return editor; } - protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: editorOptions.IEditorOptions): CodeEditorWidget { + protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: IEditorOptions): CodeEditorWidget { return instantiationService.createInstance(CodeEditorWidget, container, options, {}); } @@ -568,7 +568,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return this.modifiedEditor; } - public updateOptions(newOptions: editorOptions.IDiffEditorOptions): void { + public updateOptions(newOptions: IDiffEditorOptions): void { // Handle side by side let renderSideBySideChanged = false; @@ -967,8 +967,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE } } - private _adjustOptionsForSubEditor(options: editorOptions.IDiffEditorOptions): editorOptions.IDiffEditorOptions { - let clonedOptions: editorOptions.IDiffEditorOptions = objects.deepClone(options || {}); + private _adjustOptionsForSubEditor(options: IDiffEditorOptions): IDiffEditorOptions { + let clonedOptions: IDiffEditorOptions = objects.deepClone(options || {}); clonedOptions.inDiffEditor = true; clonedOptions.wordWrap = 'off'; clonedOptions.wordWrapMinified = false; @@ -986,7 +986,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return clonedOptions; } - private _adjustOptionsForLeftHandSide(options: editorOptions.IDiffEditorOptions, isEditable: boolean): editorOptions.IEditorOptions { + private _adjustOptionsForLeftHandSide(options: IDiffEditorOptions, isEditable: boolean): IEditorOptions { let result = this._adjustOptionsForSubEditor(options); result.readOnly = !isEditable; result.overviewRulerLanes = 1; @@ -994,9 +994,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE return result; } - private _adjustOptionsForRightHandSide(options: editorOptions.IDiffEditorOptions): editorOptions.IEditorOptions { + private _adjustOptionsForRightHandSide(options: IDiffEditorOptions): IEditorOptions { let result = this._adjustOptionsForSubEditor(options); - result.revealHorizontalRightPadding = editorOptions.EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH; + result.revealHorizontalRightPadding = EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH; result.scrollbar!.verticalHasArrows = false; result.extraEditorClassName = 'modified-in-monaco-diff-editor'; return result; @@ -1830,7 +1830,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito this.decorationsLeft = dataSource.getOriginalEditor().getLayoutInfo().decorationsLeft; - this._register(dataSource.getOriginalEditor().onDidLayoutChange((layoutInfo: editorOptions.EditorLayoutInfo) => { + this._register(dataSource.getOriginalEditor().onDidLayoutChange((layoutInfo: EditorLayoutInfo) => { if (this.decorationsLeft !== layoutInfo.decorationsLeft) { this.decorationsLeft = layoutInfo.decorationsLeft; dataSource.relayoutEditors(); @@ -1946,8 +1946,8 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito class InlineViewZonesComputer extends ViewZonesComputer { private readonly originalModel: ITextModel; - private readonly modifiedEditorConfiguration: editorOptions.InternalEditorOptions; - private readonly modifiedEditorOptions: editorOptions.IComputedEditorOptions; + private readonly modifiedEditorConfiguration: InternalEditorOptions; + private readonly modifiedEditorOptions: IComputedEditorOptions; private readonly modifiedEditorTabSize: number; private readonly renderIndicators: boolean; @@ -1995,7 +1995,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { let sb = createStringBuilder(10000); let marginHTML: string[] = []; - const layoutInfo = this.modifiedEditorOptions.get(editorOptions.EditorOptionId.layoutInfo); + const layoutInfo = this.modifiedEditorOptions.get(EditorOptionId.layoutInfo); const lineDecorationsWidth = layoutInfo.decorationsWidth; let lineHeight = this.modifiedEditorConfiguration.lineHeight; @@ -2042,7 +2042,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { }; } - private _renderOriginalLine(count: number, originalModel: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { + private _renderOriginalLine(count: number, originalModel: ITextModel, config: InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { const lineTokens = originalModel.getLineTokens(lineNumber); const lineContent = lineTokens.getLineContent(); diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index f6ab9ce2f141f..8c51ecede42d9 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -667,10 +667,10 @@ export class DiffReview extends Disposable { originalLineEnd - originalLineStart ); - const originalLayoutInfo = originalOptions.get(editorOptions.EditorOptionId.layoutInfo); + const originalLayoutInfo = originalOptions.get(editorOptions.EditorOptionId.layoutInfo); const originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth; - const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOptionId.layoutInfo); + const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOptionId.layoutInfo); const modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth; for (let i = 0; i <= cnt; i++) { diff --git a/src/vs/editor/browser/widget/inlineDiffMargin.ts b/src/vs/editor/browser/widget/inlineDiffMargin.ts index 7933869ab4ff2..afc6287dc02cf 100644 --- a/src/vs/editor/browser/widget/inlineDiffMargin.ts +++ b/src/vs/editor/browser/widget/inlineDiffMargin.ts @@ -12,6 +12,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { Range } from 'vs/editor/common/core/range'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export interface IDiffLinesChange { readonly originalStartLineNumber: number; @@ -97,7 +98,7 @@ export class InlineDiffMargin extends Disposable { actions.push(copyLineAction); } - const readOnly = editor.getConfiguration().readOnly; + const readOnly = editor.getOption(EditorOptionId.readOnly); if (!readOnly) { actions.push(new Action('diff.inline.revertChange', nls.localize('diff.inline.revertChange.label', "Revert this change"), undefined, true, async () => { if (diff.modifiedEndLineNumber === 0) { diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index a5dc25319e20b..921bb9d99b8f1 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -8,15 +8,12 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOption, EDITOR_MODEL_DEFAULTS, blinkingStyleToString, cursorStyleToString } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { ConfigurationScope, Extensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; -import EDITOR_DEFAULTS = editorOptions.EDITOR_DEFAULTS; -import EDITOR_FONT_DEFAULTS = editorOptions.EDITOR_FONT_DEFAULTS; -import EDITOR_MODEL_DEFAULTS = editorOptions.EDITOR_MODEL_DEFAULTS; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; /** @@ -64,47 +61,47 @@ export interface IEnvConfiguration { const hasOwnProperty = Object.hasOwnProperty; export class EditorConfiguration2 { - public static readOptions(options: editorOptions.IEditorOptions): editorOptions.RawEditorOptions { + public static readOptions(options: IEditorOptions): RawEditorOptions { // console.log(`parseOptions`, options); - const result = new editorOptions.RawEditorOptions(); - for (const editorOption of editorOptions.editorOptionsRegistry) { + const result = new RawEditorOptions(); + for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.read(options)); } return result; } - public static mixOptions(a: editorOptions.RawEditorOptions, b: editorOptions.IEditorOptions): editorOptions.RawEditorOptions { + public static mixOptions(a: RawEditorOptions, b: IEditorOptions): RawEditorOptions { // console.log(`mixOptions`, a, b); - const result = new editorOptions.RawEditorOptions(); - for (const editorOption of editorOptions.editorOptionsRegistry) { + const result = new RawEditorOptions(); + for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.mix(a._read(editorOption.id), editorOption.read(b))); } return result; } - public static validateOptions(options: editorOptions.RawEditorOptions): editorOptions.ValidatedEditorOptions { + public static validateOptions(options: RawEditorOptions): ValidatedEditorOptions { // console.log(`validateOptions`, options); - const result = new editorOptions.ValidatedEditorOptions(); - for (const editorOption of editorOptions.editorOptionsRegistry) { + const result = new ValidatedEditorOptions(); + for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.validate(options._read(editorOption.id))); } return result; } - public static computeOptions(options: editorOptions.ValidatedEditorOptions, env: editorOptions.IEnvironmentalOptions): editorOptions.ComputedEditorOptions { + public static computeOptions(options: ValidatedEditorOptions, env: IEnvironmentalOptions): ComputedEditorOptions { // console.log(`computeOptions`, options, env); - const result = new editorOptions.ComputedEditorOptions(); - for (const editorOption of editorOptions.editorOptionsRegistry) { + const result = new ComputedEditorOptions(); + for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.compute(env, result, options._read(editorOption.id))); } return result; } - public static checkEquals(a: editorOptions.ComputedEditorOptions, b: editorOptions.ComputedEditorOptions): editorOptions.ChangedEditorOptions | null { + public static checkEquals(a: ComputedEditorOptions, b: ComputedEditorOptions): ChangedEditorOptions | null { // console.log(`equals`, a, b); - const result = new editorOptions.ChangedEditorOptions(); + const result = new ChangedEditorOptions(); let somethingChanged = false; - for (const editorOption of editorOptions.editorOptionsRegistry) { + for (const editorOption of editorOptionsRegistry) { const changed = !editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); result._write(editorOption.id, changed); if (changed) { @@ -118,7 +115,7 @@ export class EditorConfiguration2 { /** * Compatibility with old options */ -function migrateOptions(options: editorOptions.IEditorOptions): void { +function migrateOptions(options: IEditorOptions): void { let wordWrap = options.wordWrap; if (wordWrap === true) { options.wordWrap = 'on'; @@ -137,20 +134,20 @@ function migrateOptions(options: editorOptions.IEditorOptions): void { export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { public readonly isSimpleWidget: boolean; - protected _rawOptions: editorOptions.IEditorOptions; - protected _validatedOptions: editorOptions.IValidatedEditorOptions; - public editor!: editorOptions.InternalEditorOptions; + protected _rawOptions: IEditorOptions; + protected _validatedOptions: IValidatedEditorOptions; + public editor!: InternalEditorOptions; private _isDominatedByLongLines: boolean; private _lineNumbersDigitCount: number; - private _onDidChange = this._register(new Emitter()); - public readonly onDidChange: Event = this._onDidChange.event; + private _onDidChange = this._register(new Emitter()); + public readonly onDidChange: Event = this._onDidChange.event; - private _rawOptions2: editorOptions.RawEditorOptions; - private _validatedOptions2: editorOptions.ValidatedEditorOptions; - public options!: editorOptions.ComputedEditorOptions; + private _rawOptions2: RawEditorOptions; + private _validatedOptions2: ValidatedEditorOptions; + public options!: ComputedEditorOptions; - constructor(isSimpleWidget: boolean, options: editorOptions.IEditorOptions) { + constructor(isSimpleWidget: boolean, options: IEditorOptions) { super(); migrateOptions(options); @@ -164,7 +161,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {}); this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {}); - this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); + this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); this._rawOptions2 = EditorConfiguration2.readOptions(options); this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); @@ -202,15 +199,15 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed } } - public getRawOptions(): editorOptions.IEditorOptions { + public getRawOptions(): IEditorOptions { return this._rawOptions; } - private _computeInternalOptions(): [editorOptions.InternalEditorOptions, editorOptions.ComputedEditorOptions] { + private _computeInternalOptions(): [InternalEditorOptions, ComputedEditorOptions] { const opts = this._validatedOptions; const partialEnv = this._getEnvConfiguration(); const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget); - const env: editorOptions.IEnvironmentalOptions = { + const env: IEnvironmentalOptions = { outerWidth: partialEnv.outerWidth, outerHeight: partialEnv.outerHeight, fontInfo: this.readConfiguration(bareFontInfo), @@ -222,7 +219,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed tabFocusMode: TabFocus.getTabFocusMode(), accessibilitySupport: partialEnv.accessibilitySupport }; - const r = editorOptions.InternalEditorOptionsFactory.createInternalEditorOptions(env, opts); + const r = InternalEditorOptionsFactory.createInternalEditorOptions(env, opts); const r2 = EditorConfiguration2.computeOptions(this._validatedOptions2, env); return [r, r2]; } @@ -267,7 +264,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed return true; } - public updateOptions(newOptions: editorOptions.IEditorOptions): void { + public updateOptions(newOptions: IEditorOptions): void { if (typeof newOptions === 'undefined') { return; } @@ -278,7 +275,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._rawOptions = objects.mixin(this._rawOptions, newOptions || {}); this._rawOptions2 = EditorConfiguration2.mixOptions(this._rawOptions2, newOptions); - this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); + this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); this._recomputeOptions(); @@ -366,7 +363,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.renderFinalNewline': { 'type': 'boolean', - 'default': editorOptions.EditorOption.renderFinalNewline.defaultValue, + 'default': EditorOption.renderFinalNewline.defaultValue, 'description': nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }, 'editor.rulers': { @@ -434,29 +431,29 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.minimap.enabled': { 'type': 'boolean', - 'default': editorOptions.EditorOption.minimap.defaultValue.enabled, + 'default': EditorOption.minimap.defaultValue.enabled, 'description': nls.localize('minimap.enabled', "Controls whether the minimap is shown.") }, 'editor.minimap.side': { 'type': 'string', 'enum': ['left', 'right'], - 'default': editorOptions.EditorOption.minimap.defaultValue.side, + 'default': EditorOption.minimap.defaultValue.side, 'description': nls.localize('minimap.side', "Controls the side where to render the minimap.") }, 'editor.minimap.showSlider': { 'type': 'string', 'enum': ['always', 'mouseover'], - 'default': editorOptions.EditorOption.minimap.defaultValue.showSlider, + 'default': EditorOption.minimap.defaultValue.showSlider, 'description': nls.localize('minimap.showSlider', "Controls whether the minimap slider is automatically hidden.") }, 'editor.minimap.renderCharacters': { 'type': 'boolean', - 'default': editorOptions.EditorOption.minimap.defaultValue.renderCharacters, + 'default': EditorOption.minimap.defaultValue.renderCharacters, 'description': nls.localize('minimap.renderCharacters', "Render the actual characters on a line as opposed to color blocks.") }, 'editor.minimap.maxColumn': { 'type': 'number', - 'default': editorOptions.EditorOption.minimap.defaultValue.maxColumn, + 'default': EditorOption.minimap.defaultValue.maxColumn, 'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.") }, 'editor.hover.enabled': { @@ -515,7 +512,7 @@ const editorConfiguration: IConfigurationNode = { ] }, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."), ], - 'default': editorOptions.EditorOption.wordWrap.defaultValue, + 'default': EditorOption.wordWrap.defaultValue, 'description': nls.localize({ key: 'wordWrap', comment: [ @@ -526,7 +523,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.wordWrapColumn': { 'type': 'integer', - 'default': editorOptions.EditorOption.wordWrapColumn.defaultValue, + 'default': EditorOption.wordWrapColumn.defaultValue, 'minimum': 1, 'markdownDescription': nls.localize({ key: 'wordWrapColumn', @@ -550,12 +547,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.mouseWheelScrollSensitivity': { 'type': 'number', - 'default': editorOptions.EditorOption.mouseWheelScrollSensitivity.defaultValue, + 'default': EditorOption.mouseWheelScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }, 'editor.fastScrollSensitivity': { 'type': 'number', - 'default': editorOptions.EditorOption.fastScrollSensitivity.defaultValue, + 'default': EditorOption.fastScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`.") }, 'editor.multiCursorModifier': { @@ -972,7 +969,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.cursorBlinking': { 'type': 'string', 'enum': ['blink', 'smooth', 'phase', 'expand', 'solid'], - 'default': editorOptions.blinkingStyleToString(EDITOR_DEFAULTS.viewInfo.cursorBlinking), + 'default': blinkingStyleToString(EDITOR_DEFAULTS.viewInfo.cursorBlinking), 'description': nls.localize('cursorBlinking', "Control the cursor animation style.") }, 'editor.mouseWheelZoom': { @@ -988,7 +985,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.cursorStyle': { 'type': 'string', 'enum': ['block', 'block-outline', 'line', 'line-thin', 'underline', 'underline-thin'], - 'default': editorOptions.cursorStyleToString(EDITOR_DEFAULTS.viewInfo.cursorStyle), + 'default': cursorStyleToString(EDITOR_DEFAULTS.viewInfo.cursorStyle), 'description': nls.localize('cursorStyle', "Controls the cursor style.") }, 'editor.cursorWidth': { @@ -1052,7 +1049,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.folding': { 'type': 'boolean', - 'default': editorOptions.EditorOption.folding.defaultValue, + 'default': EditorOption.folding.defaultValue, 'description': nls.localize('folding', "Controls whether the editor has code folding enabled.") }, 'editor.foldingStrategy': { @@ -1105,7 +1102,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader."), nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."), ], - 'default': editorOptions.EditorOption.accessibilitySupport.defaultValue, + 'default': EditorOption.accessibilitySupport.defaultValue, 'description': nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers.") }, 'editor.showUnused': { @@ -1158,7 +1155,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.selectionClipboard': { 'type': 'boolean', - 'default': editorOptions.EditorOption.selectionClipboard.defaultValue, + 'default': EditorOption.selectionClipboard.defaultValue, 'description': nls.localize('selectionClipboard', "Controls whether the Linux primary clipboard should be supported."), 'included': platform.isLinux }, diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index dc915f4f80be0..8b81ce7e46425 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -729,7 +729,20 @@ export interface IEditorOptions { */ showUnused?: boolean; + /** + * Do not use. + * @internal + */ + tabFocusMode?: undefined; + /** + * Do not use. + * @internal + */ layoutInfo?: undefined; + /** + * Do not use. + * @internal + */ wrappingInfo?: undefined; } @@ -1018,7 +1031,6 @@ export interface EditorContribOptions { export interface IValidatedEditorOptions { readonly wordSeparators: string; readonly lineDecorationsWidth: number | string; - readonly readOnly: boolean; readonly mouseStyle: 'text' | 'default' | 'copy'; readonly disableLayerHinting: boolean; readonly automaticLayout: boolean; @@ -1049,11 +1061,6 @@ export class InternalEditorOptions { readonly pixelRatio: number; readonly editorClassName: string; readonly lineHeight: number; - readonly readOnly: boolean; - /** - * @internal - */ - readonly accessibilitySupport: AccessibilitySupport; readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; readonly multiCursorMergeOverlapping: boolean; readonly showUnused: boolean; @@ -1066,7 +1073,6 @@ export class InternalEditorOptions { readonly autoSurround: EditorAutoSurroundStrategy; readonly autoIndent: boolean; readonly useTabStops: boolean; - readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; @@ -1084,7 +1090,6 @@ export class InternalEditorOptions { pixelRatio: number; editorClassName: string; lineHeight: number; - readOnly: boolean; multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; multiCursorMergeOverlapping: boolean; wordSeparators: string; @@ -1094,7 +1099,6 @@ export class InternalEditorOptions { autoSurround: EditorAutoSurroundStrategy; autoIndent: boolean; useTabStops: boolean; - tabFocusMode: boolean; dragAndDrop: boolean; emptySelectionClipboard: boolean; copyWithSyntaxHighlighting: boolean; @@ -1107,7 +1111,6 @@ export class InternalEditorOptions { this.pixelRatio = source.pixelRatio; this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight | 0; - this.readOnly = source.readOnly; this.multiCursorModifier = source.multiCursorModifier; this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping; this.wordSeparators = source.wordSeparators; @@ -1117,7 +1120,6 @@ export class InternalEditorOptions { this.autoSurround = source.autoSurround; this.autoIndent = source.autoIndent; this.useTabStops = source.useTabStops; - this.tabFocusMode = source.tabFocusMode; this.dragAndDrop = source.dragAndDrop; this.emptySelectionClipboard = source.emptySelectionClipboard; this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; @@ -1136,7 +1138,6 @@ export class InternalEditorOptions { && this.pixelRatio === other.pixelRatio && this.editorClassName === other.editorClassName && this.lineHeight === other.lineHeight - && this.readOnly === other.readOnly && this.multiCursorModifier === other.multiCursorModifier && this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping && this.wordSeparators === other.wordSeparators @@ -1146,7 +1147,6 @@ export class InternalEditorOptions { && this.autoSurround === other.autoSurround && this.autoIndent === other.autoIndent && this.useTabStops === other.useTabStops - && this.tabFocusMode === other.tabFocusMode && this.dragAndDrop === other.dragAndDrop && this.showUnused === other.showUnused && this.emptySelectionClipboard === other.emptySelectionClipboard @@ -1172,7 +1172,6 @@ export class InternalEditorOptions { pixelRatio: (this.pixelRatio !== newOpts.pixelRatio), editorClassName: (this.editorClassName !== newOpts.editorClassName), lineHeight: (this.lineHeight !== newOpts.lineHeight), - readOnly: (this.readOnly !== newOpts.readOnly), multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier), multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping), wordSeparators: (this.wordSeparators !== newOpts.wordSeparators), @@ -1182,7 +1181,6 @@ export class InternalEditorOptions { autoSurround: (this.autoSurround !== newOpts.autoSurround), autoIndent: (this.autoIndent !== newOpts.autoIndent), useTabStops: (this.useTabStops !== newOpts.useTabStops), - tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode), dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop), emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard), copyWithSyntaxHighlighting: (this.copyWithSyntaxHighlighting !== newOpts.copyWithSyntaxHighlighting), @@ -1353,7 +1351,6 @@ export interface IConfigurationChangedEvent { readonly pixelRatio: boolean; readonly editorClassName: boolean; readonly lineHeight: boolean; - readonly readOnly: boolean; readonly multiCursorModifier: boolean; readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; @@ -1363,7 +1360,6 @@ export interface IConfigurationChangedEvent { readonly autoSurround: boolean; readonly autoIndent: boolean; readonly useTabStops: boolean; - readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; @@ -1534,7 +1530,6 @@ export class EditorOptionsValidator { return { wordSeparators: _string(opts.wordSeparators, defaults.wordSeparators), lineDecorationsWidth: (typeof opts.lineDecorationsWidth === 'undefined' ? defaults.lineDecorationsWidth : opts.lineDecorationsWidth), - readOnly: _boolean(opts.readOnly, defaults.readOnly), mouseStyle: _stringSet<'text' | 'default' | 'copy'>(opts.mouseStyle, defaults.mouseStyle, ['text', 'default', 'copy']), disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting), automaticLayout: _boolean(opts.automaticLayout, defaults.automaticLayout), @@ -1768,7 +1763,6 @@ export class InternalEditorOptionsFactory { pixelRatio: env.pixelRatio, editorClassName: className, lineHeight: env.fontInfo.lineHeight, - readOnly: opts.readOnly, multiCursorModifier: opts.multiCursorModifier, multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping, wordSeparators: opts.wordSeparators, @@ -1778,7 +1772,6 @@ export class InternalEditorOptionsFactory { autoSurround: opts.autoSurround, autoIndent: opts.autoIndent, useTabStops: opts.useTabStops, - tabFocusMode: opts.readOnly ? true : env.tabFocusMode, dragAndDrop: opts.dragAndDrop, emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard, copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting, @@ -1858,7 +1851,6 @@ export const EDITOR_MODEL_DEFAULTS = { export const EDITOR_DEFAULTS: IValidatedEditorOptions = { wordSeparators: USUAL_WORD_SEPARATORS, lineDecorationsWidth: 10, - readOnly: false, mouseStyle: 'text', disableLayerHinting: false, automaticLayout: false, @@ -1991,7 +1983,7 @@ export class ValidatedEditorOptions { } export interface IComputedEditorOptions { - get>(id: EditorOptionId): ComputedEditorOptionValue; + get(id: T): FindComputedEditorOptionValueById; } /** @@ -2002,7 +1994,7 @@ export class ComputedEditorOptions implements IComputedEditorOptions { public _read(id: EditorOptionId): T { return this._values[id]; } - public get>(id: EditorOptionId): ComputedEditorOptionValue { + public get(id: T): FindComputedEditorOptionValueById { return this._values[id]; } public _write(id: EditorOptionId, value: T): void { @@ -2025,8 +2017,8 @@ export class ChangedEditorOptions { export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; -export interface IEditorOption { - readonly id: EditorOptionId; +export interface IEditorOption { + readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; read(options: IRawEditorOptionsBag): T1 | undefined; @@ -2039,20 +2031,20 @@ export interface IEditorOption { /** * @internal */ -export const editorOptionsRegistry: IEditorOption[] = []; +export const editorOptionsRegistry: IEditorOption[] = []; -function registerEditorOption(option: IEditorOption): IEditorOption { +function registerEditorOption(option: IEditorOption): IEditorOption { editorOptionsRegistry[option.id] = option; return option; } -export abstract class BaseEditorOption implements IEditorOption { +export abstract class BaseEditorOption implements IEditorOption { - public readonly id: EditorOptionId; + public readonly id: K; public readonly name: PossibleKeyName; public readonly defaultValue: T2; - constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T2, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps: EditorOptionId[] = []) { this.id = id; this.name = name; this.defaultValue = defaultValue; @@ -2082,7 +2074,7 @@ export abstract class BaseEditorOption implements IEditorO } } -class EditorBooleanOption extends BaseEditorOption { +class EditorBooleanOption extends BaseEditorOption { public validate(input: boolean | undefined): boolean { return _boolean(input, this.defaultValue); } @@ -2091,10 +2083,10 @@ class EditorBooleanOption extends BaseEditorOption { } } -class EditorIntOption extends BaseEditorOption { +class EditorIntOption extends BaseEditorOption { public readonly minimum: number; public readonly maximum: number; - constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOptionId[] = []) { super(id, name, defaultValue, deps); this.minimum = minimum; this.maximum = maximum; @@ -2107,9 +2099,9 @@ class EditorIntOption extends BaseEditorOption { } } -class EditorFloatOption extends BaseEditorOption { +class EditorFloatOption extends BaseEditorOption { public readonly validationFn: (value: number) => number; - constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOptionId[] = []) { super(id, name, defaultValue, deps); this.validationFn = validationFn; } @@ -2121,7 +2113,7 @@ class EditorFloatOption extends BaseEditorOption { } } -class EditorStringOption extends BaseEditorOption { +class EditorStringOption extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } @@ -2130,10 +2122,10 @@ class EditorStringOption extends BaseEditorOption { } } -class EditorEnumOption extends BaseEditorOption { +class EditorEnumOption extends BaseEditorOption { public readonly allowedValues: T1[]; public readonly convert: (value: T1) => T2; - constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOptionId[] = []) { super(id, name, defaultValue, deps); this.allowedValues = allowedValues; this.convert = convert; @@ -2146,7 +2138,7 @@ class EditorEnumOption extends BaseEditorOption { } } -class EditorPassthroughOption extends BaseEditorOption { +class EditorPassthroughOption extends BaseEditorOption { public validate(input: T | undefined): T { if (typeof input === 'undefined') { return this.defaultValue; @@ -2175,7 +2167,7 @@ export interface InternalEditorRenderLineNumbersOptions { readonly renderFn: ((lineNumber: number) => string) | null; } -class EditorRenderLineNumbersOption extends BaseEditorOption { +class EditorRenderLineNumbersOption extends BaseEditorOption { public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions { let renderType: RenderLineNumbersType = this.defaultValue.renderType; let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; @@ -2223,7 +2215,7 @@ export interface InternalEditorMinimapOptions { readonly maxColumn: number; } -class EditorMinimapOption extends BaseEditorOption { +class EditorMinimapOption extends BaseEditorOption { public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2254,7 +2246,7 @@ class EditorMinimapOption extends BaseEditorOption { +class EditorAccessibilitySupportOption extends BaseEditorOption { public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' { return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']); } @@ -2274,12 +2266,12 @@ class EditorAccessibilitySupportOption extends BaseEditorOption<'auto' | 'off' | //#region ariaLabel -class EditorAriaLabel extends BaseEditorOption { +class EditorAriaLabel extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { - const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); if (accessibilitySupport === AccessibilitySupport.Disabled) { return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options."); } @@ -2289,6 +2281,20 @@ class EditorAriaLabel extends BaseEditorOption { //#endregion +//#region tabFocusMode + +class EditorTabFocusMode extends BaseEditorOption { + public validate(input: undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): boolean { + const readOnly = options.get(EditorOptionId.readOnly); + return (readOnly ? true : env.tabFocusMode); + } +} + +//#endregion + //#region scrollbar export interface InternalEditorScrollbarOptions { @@ -2305,7 +2311,7 @@ export interface InternalEditorScrollbarOptions { readonly verticalSliderSize: number; } -class EditorScrollbarOption extends BaseEditorOption { +class EditorScrollbarOption extends BaseEditorOption { public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2475,18 +2481,18 @@ export interface EditorLayoutInfo { /** * @internal */ -export class EditorLayoutInfoComputer extends BaseEditorOption { +export class EditorLayoutInfoComputer extends BaseEditorOption { public validate(input: undefined): undefined { return undefined; } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorLayoutInfo { - const glyphMargin = options.get(EditorOptionId.glyphMargin); - const lineNumbersMinChars = options.get(EditorOptionId.lineNumbersMinChars); - const rawLineDecorationsWidth = options.get(EditorOptionId.lineDecorationsWidth); - const folding = options.get(EditorOptionId.folding); - const minimap = options.get(EditorOptionId.minimap); - const scrollbar = options.get(EditorOptionId.scrollbar); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const glyphMargin = options.get(EditorOptionId.glyphMargin); + const lineNumbersMinChars = options.get(EditorOptionId.lineNumbersMinChars); + const rawLineDecorationsWidth = options.get(EditorOptionId.lineDecorationsWidth); + const folding = options.get(EditorOptionId.folding); + const minimap = options.get(EditorOptionId.minimap); + const scrollbar = options.get(EditorOptionId.scrollbar); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); let lineDecorationsWidth: number; if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) { @@ -2547,9 +2553,6 @@ export class EditorLayoutInfoComputer extends BaseEditorOption { +class EditorWrappingInfoComputer extends BaseEditorOption { public mix(a: undefined, b: undefined): undefined { return undefined; } @@ -2711,11 +2714,11 @@ class EditorWrappingInfoComputer extends BaseEditorOption(EditorOptionId.wordWrap); - const wordWrapColumn = options.get(EditorOptionId.wordWrapColumn); - const wordWrapMinified = options.get(EditorOptionId.wordWrapMinified); - const layoutInfo = options.get(EditorOptionId.layoutInfo); - const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + const wordWrap = options.get(EditorOptionId.wordWrap); + const wordWrapColumn = options.get(EditorOptionId.wordWrapColumn); + const wordWrapMinified = options.get(EditorOptionId.wordWrapMinified); + const layoutInfo = options.get(EditorOptionId.layoutInfo); + const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null; { @@ -2793,11 +2796,13 @@ export const enum EditorOptionId { lineNumbersMinChars, minimap, mouseWheelScrollSensitivity, + readOnly, renderFinalNewline, renderLineNumbers, scrollbar, selectionClipboard, selectOnLineNumbers, + tabFocusMode, wordWrap, wordWrapBreakAfterCharacters, wordWrapBreakBeforeCharacters, @@ -2817,7 +2822,7 @@ export const EditorOption = { folding: registerEditorOption(new EditorBooleanOption(EditorOptionId.folding, 'folding', true)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOptionId.glyphMargin, 'glyphMargin', true)), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOptionId.inDiffEditor, 'inDiffEditor', false)), - lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOptionId.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOptionId.lineDecorationsWidth, 'lineDecorationsWidth', 10)), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOptionId.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), minimap: registerEditorOption(new EditorMinimapOption(EditorOptionId.minimap, 'minimap', { enabled: true, @@ -2827,6 +2832,7 @@ export const EditorOption = { maxColumn: 120, })), mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOptionId.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), + readOnly: registerEditorOption(new EditorBooleanOption(EditorOptionId.readOnly, 'readOnly', false)), renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOptionId.renderFinalNewline, 'renderFinalNewline', true)), renderLineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOptionId.renderLineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOptionId.scrollbar, 'scrollbar', { @@ -2844,17 +2850,21 @@ export const EditorOption = { })), selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectionClipboard, 'selectionClipboard', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectOnLineNumbers, 'selectOnLineNumbers', true)), - wordWrap: registerEditorOption(new EditorEnumOption<'off' | 'on' | 'wordWrapColumn' | 'bounded'>(EditorOptionId.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), + tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOptionId.tabFocusMode, 'tabFocusMode', undefined, [EditorOptionId.readOnly])), + wordWrap: registerEditorOption(new EditorEnumOption(EditorOptionId.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOptionId.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOptionId.wordWrapMinified, 'wordWrapMinified', true)), - wrappingIndent: registerEditorOption(new EditorEnumOption<'none' | 'same' | 'indent' | 'deepIndent', WrappingIndent>(EditorOptionId.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), + wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOptionId.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), // Leave these at the end! layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOptionId.layoutInfo, 'layoutInfo', undefined, [EditorOptionId.glyphMargin, EditorOptionId.lineDecorationsWidth, EditorOptionId.folding, EditorOptionId.minimap, EditorOptionId.scrollbar, EditorOptionId.renderLineNumbers])), wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOptionId.wrappingInfo, 'wrappingInfo', undefined, [EditorOptionId.wordWrap, EditorOptionId.wordWrapColumn, EditorOptionId.wordWrapMinified, EditorOptionId.layoutInfo, EditorOptionId.accessibilitySupport])), }; -export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; +export type EditorOptionType = typeof EditorOption; +export type FindEditorOptionKeyById = { [K in keyof EditorOptionType]: EditorOptionType[K]['id'] extends T ? K : never }[keyof EditorOptionType]; +export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; +export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index b76218fe99bab..fce316527de3c 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -20,6 +20,7 @@ import { RawContentChangedType } from 'vs/editor/common/model/textModelEvents'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { dispose } from 'vs/base/common/lifecycle'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; function containsLineMappingChanged(events: viewEvents.ViewEvent[]): boolean { for (let i = 0, len = events.length; i < len; i++) { @@ -673,7 +674,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._isDoingComposition = false; } - if (this._configuration.editor.readOnly) { + if (this._configuration.options.get(EditorOptionId.readOnly)) { // All the remaining handlers will try to edit the model, // but we cannot edit when read only... this._onDidAttemptReadOnlyEdit.fire(undefined); diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 80775a63bd2d2..8c9ecb6a3d764 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -6,7 +6,7 @@ import { CharCode } from 'vs/base/common/charCode'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; -import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -122,7 +122,7 @@ export class CursorConfiguration { || e.autoSurround || e.useTabStops || e.lineHeight - || e.readOnly + || e.hasChanged(EditorOptionId.readOnly) ); } @@ -135,9 +135,9 @@ export class CursorConfiguration { const c = configuration.editor; const options = configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); - this.readOnly = c.readOnly; + this.readOnly = options.get(EditorOptionId.readOnly); this.tabSize = modelOptions.tabSize; this.indentSize = modelOptions.indentSize; this.insertSpaces = modelOptions.insertSpaces; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index d3b4118c43340..b23d2a1b9b246 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -450,20 +450,22 @@ export enum EditorOptionId { lineNumbersMinChars = 7, minimap = 8, mouseWheelScrollSensitivity = 9, - renderFinalNewline = 10, - renderLineNumbers = 11, - scrollbar = 12, - selectionClipboard = 13, - selectOnLineNumbers = 14, - wordWrap = 15, - wordWrapBreakAfterCharacters = 16, - wordWrapBreakBeforeCharacters = 17, - wordWrapBreakObtrusiveCharacters = 18, - wordWrapColumn = 19, - wordWrapMinified = 20, - wrappingIndent = 21, - layoutInfo = 22, - wrappingInfo = 23 + readOnly = 10, + renderFinalNewline = 11, + renderLineNumbers = 12, + scrollbar = 13, + selectionClipboard = 14, + selectOnLineNumbers = 15, + tabFocusMode = 16, + wordWrap = 17, + wordWrapBreakAfterCharacters = 18, + wordWrapBreakBeforeCharacters = 19, + wordWrapBreakObtrusiveCharacters = 20, + wordWrapColumn = 21, + wordWrapMinified = 22, + wrappingIndent = 23, + layoutInfo = 24, + wrappingInfo = 25 } /** diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index 47006636def33..ebb674197e099 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -39,7 +39,6 @@ export class ViewConfigurationChangedEvent { public readonly pixelRatio: boolean; public readonly editorClassName: boolean; public readonly lineHeight: boolean; - public readonly readOnly: boolean; public readonly emptySelectionClipboard: boolean; public readonly copyWithSyntaxHighlighting: boolean; public readonly fontInfo: boolean; @@ -51,7 +50,6 @@ export class ViewConfigurationChangedEvent { this.pixelRatio = source.pixelRatio; this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight; - this.readOnly = source.readOnly; this.emptySelectionClipboard = source.emptySelectionClipboard; this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; this.fontInfo = source.fontInfo; diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index 978aa54a3bbf0..99cd7efff4362 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -6,7 +6,7 @@ import { Event } from 'vs/base/common/event'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout'; import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; @@ -28,7 +28,7 @@ export class ViewLayout extends Disposable implements IViewLayout { this._configuration = configuration; const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight); @@ -64,7 +64,7 @@ export class ViewLayout extends Disposable implements IViewLayout { } if (e.hasChanged(EditorOptionId.layoutInfo)) { const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOptionId.layoutInfo); this.scrollable.setScrollDimensions({ width: layoutInfo.contentWidth, height: layoutInfo.contentHeight @@ -89,7 +89,7 @@ export class ViewLayout extends Disposable implements IViewLayout { private _getHorizontalScrollbarHeight(scrollDimensions: IScrollDimensions): number { const options = this._configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOptionId.scrollbar); if (scrollbar.horizontal === ScrollbarVisibility.Hidden) { // horizontal scrollbar not visible return 0; @@ -146,7 +146,7 @@ export class ViewLayout extends Disposable implements IViewLayout { private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number { const options = this._configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); let isViewportWrapping = wrappingInfo.isViewportWrapping; if (!isViewportWrapping) { const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; diff --git a/src/vs/editor/common/viewModel/viewModelDecorations.ts b/src/vs/editor/common/viewModel/viewModelDecorations.ts index 07df48c622efb..bedcfb72b8318 100644 --- a/src/vs/editor/common/viewModel/viewModelDecorations.ts +++ b/src/vs/editor/common/viewModel/viewModelDecorations.ts @@ -10,6 +10,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import { IModelDecoration, ITextModel } from 'vs/editor/common/model'; import { IViewModelLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection'; import { ICoordinatesConverter, InlineDecoration, InlineDecorationType, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export interface IDecorationsViewportData { /** @@ -103,7 +104,7 @@ export class ViewModelDecorations implements IDisposable { } private _getDecorationsViewportData(viewportRange: Range): IDecorationsViewportData { - const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.editor.readOnly); + const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.options.get(EditorOptionId.readOnly)); const startLineNumber = viewportRange.startLineNumber; const endLineNumber = viewportRange.endLineNumber; diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 73350e182145c..8ccdd124225eb 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -6,7 +6,7 @@ import { Color } from 'vs/base/common/color'; import { IDisposable } from 'vs/base/common/lifecycle'; import * as strings from 'vs/base/common/strings'; -import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -61,11 +61,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } else { const conf = this.configuration.editor; const options = this.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = options.get(EditorOptionId.wrappingIndent); let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, @@ -154,8 +154,8 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel const conf = this.configuration.editor; const options = this.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); - const wrappingIndent = options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingIndent = options.get(EditorOptionId.wrappingIndent); if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) { eventsCollector.emit(new viewEvents.ViewFlushedEvent()); @@ -170,7 +170,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } } - if (e.readOnly) { + if (e.hasChanged(EditorOptionId.readOnly)) { // Must read again all decorations due to readOnly filtering this.decorations.reset(); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent()); @@ -561,7 +561,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } public getAllOverviewRulerDecorations(theme: ITheme): IOverviewRulerDecorations { - return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.editor.readOnly, theme); + return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.options.get(EditorOptionId.readOnly), theme); } public invalidateOverviewRulerColorCache(): void { diff --git a/src/vs/editor/contrib/codeAction/codeActionModel.ts b/src/vs/editor/contrib/codeAction/codeActionModel.ts index d1b33028aeec7..3c8b4dacdd17c 100644 --- a/src/vs/editor/contrib/codeAction/codeActionModel.ts +++ b/src/vs/editor/contrib/codeAction/codeActionModel.ts @@ -17,6 +17,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers'; import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { getCodeActions, CodeActionSet } from './codeAction'; import { CodeActionTrigger } from './codeActionTrigger'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export const SUPPORTED_CODE_ACTIONS = new RawContextKey('supportedCodeAction', ''); @@ -192,7 +193,7 @@ export class CodeActionModel extends Disposable { const model = this._editor.getModel(); if (model && CodeActionProviderRegistry.has(model) - && !this._editor.getConfiguration().readOnly + && !this._editor.getOption(EditorOptionId.readOnly) ) { const supportedActions: string[] = []; for (const provider of CodeActionProviderRegistry.all(model)) { diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index 664bc8c8bf32e..253052dace32e 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -26,6 +26,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { INotificationService } from 'vs/platform/notification/common/notification'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; const SEARCH_STRING_MAX_LENGTH = 524288; @@ -698,7 +699,7 @@ export class StartFindReplaceAction extends EditorAction { } public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void { - if (!editor.hasModel() || editor.getConfiguration().readOnly) { + if (!editor.hasModel() || editor.getOption(EditorOptionId.readOnly)) { return; } diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index 3b31b2e3b578b..c62ff1190bfee 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -176,8 +176,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._findInput.inputBox.layout(); this._register(this._codeEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.readOnly) { - if (this._codeEditor.getConfiguration().readOnly) { + if (e.hasChanged(EditorOptionId.readOnly)) { + if (this._codeEditor.getOption(EditorOptionId.readOnly)) { // Hide replace part if editor becomes read only this._state.change({ isReplaceRevealed: false }, false); } @@ -315,7 +315,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } if (e.isReplaceRevealed) { if (this._state.isReplaceRevealed) { - if (!this._codeEditor.getConfiguration().readOnly && !this._isReplaceVisible) { + if (!this._codeEditor.getOption(EditorOptionId.readOnly) && !this._isReplaceVisible) { this._isReplaceVisible = true; this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode); this._updateButtons(); @@ -456,7 +456,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._toggleReplaceBtn.toggleClass('expand', this._isReplaceVisible); this._toggleReplaceBtn.setExpanded(this._isReplaceVisible); - let canReplace = !this._codeEditor.getConfiguration().readOnly; + let canReplace = !this._codeEditor.getOption(EditorOptionId.readOnly); this._toggleReplaceBtn.setEnabled(this._isVisible && canReplace); } @@ -1210,7 +1210,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private updateAccessibilitySupport(): void { - const value = this._codeEditor.getConfiguration().accessibilitySupport; + const value = this._codeEditor.getOption(EditorOptionId.accessibilitySupport); this._findInput.setFocusInputOnOptionClick(value !== AccessibilitySupport.Enabled); } } diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 4a705db696e25..4c4c0f2adc776 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -18,7 +18,7 @@ import { FoldingModel, setCollapseStateAtLevel, CollapseMemento, setCollapseStat import { FoldingDecorationProvider } from './foldingDecorations'; import { FoldingRegions, FoldingRegion } from './foldingRanges'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel'; import { IRange } from 'vs/editor/common/core/range'; @@ -88,7 +88,7 @@ export class FoldingController extends Disposable implements IEditorContribution super(); this.editor = editor; const options = this.editor.getOptions(); - this._isEnabled = options.get(EditorOptionId.folding); + this._isEnabled = options.get(EditorOptionId.folding); this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover'; this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation'; @@ -113,7 +113,7 @@ export class FoldingController extends Disposable implements IEditorContribution if (e.contribInfo || e.hasChanged(EditorOptionId.folding)) { let oldIsEnabled = this._isEnabled; const options = this.editor.getOptions(); - this._isEnabled = options.get(EditorOptionId.folding); + this._isEnabled = options.get(EditorOptionId.folding); this.foldingEnabled.set(this._isEnabled); if (oldIsEnabled !== this._isEnabled) { this.onModelChanged(); diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index 583e4c65dee91..36cd010daff5e 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -11,7 +11,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution, IScrollEvent } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; @@ -265,7 +265,7 @@ class ShowHoverAction extends EditorAction { } const position = editor.getPosition(); const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column); - const focus = editor.getConfiguration().accessibilitySupport === AccessibilitySupport.Enabled; + const focus = editor.getOption(EditorOptionId.accessibilitySupport) === AccessibilitySupport.Enabled; controller.showContentHover(range, HoverStartMode.Immediate, focus); } } diff --git a/src/vs/editor/contrib/suggest/suggestModel.ts b/src/vs/editor/contrib/suggest/suggestModel.ts index d34f911cea87c..c82ea98b95b5a 100644 --- a/src/vs/editor/contrib/suggest/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/suggestModel.ts @@ -20,6 +20,7 @@ import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2 import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export interface ICancelEvent { readonly retrigger: boolean; @@ -183,7 +184,7 @@ export class SuggestModel implements IDisposable { dispose(this._triggerCharacterListener); - if (this._editor.getConfiguration().readOnly + if (this._editor.getOption(EditorOptionId.readOnly) || !this._editor.hasModel() || !this._editor.getConfiguration().contribInfo.suggestOnTriggerCharacters) { diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index dc640cc2b3cf0..a0afb73c16444 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -31,7 +31,7 @@ import { contrastBorder, editorWidgetBackground, widgetShadow, editorWidgetForeg import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey('accessibilityHelpWidgetVisible', false); @@ -224,7 +224,6 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } private _buildContent() { - let opts = this._editor.getConfiguration(); const options = this._editor.getOptions(); const selections = this._editor.getSelections(); @@ -241,14 +240,14 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { let text = getSelectionLabel(selections, charactersSelected); - if (options.get(EditorOptionId.inDiffEditor)) { - if (opts.readOnly) { + if (options.get(EditorOptionId.inDiffEditor)) { + if (options.get(EditorOptionId.readOnly)) { text += AccessibilityHelpNLS.readonlyDiffEditor; } else { text += AccessibilityHelpNLS.editableDiffEditor; } } else { - if (opts.readOnly) { + if (options.get(EditorOptionId.readOnly)) { text += AccessibilityHelpNLS.readonlyEditor; } else { text += AccessibilityHelpNLS.editableEditor; @@ -260,7 +259,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { ? AccessibilityHelpNLS.changeConfigToOnMac : AccessibilityHelpNLS.changeConfigToOnWinLinux ); - switch (opts.accessibilitySupport) { + switch (options.get(EditorOptionId.accessibilitySupport)) { case AccessibilitySupport.Unknown: text += '\n\n - ' + turnOnMessage; break; @@ -274,7 +273,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } - if (opts.tabFocusMode) { + if (options.get(EditorOptionId.tabFocusMode)) { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, AccessibilityHelpNLS.tabFocusModeOnMsg, AccessibilityHelpNLS.tabFocusModeOnMsgNoKb); } else { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, AccessibilityHelpNLS.tabFocusModeOffMsg, AccessibilityHelpNLS.tabFocusModeOffMsgNoKb); diff --git a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts index b36f6ecdc23bb..82c5fb1a312d9 100644 --- a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts +++ b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts @@ -10,6 +10,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class IPadShowKeyboard extends Disposable implements IEditorContribution { @@ -29,7 +30,7 @@ export class IPadShowKeyboard extends Disposable implements IEditorContribution } private update(): void { - const shouldHaveWidget = (!this.editor.getConfiguration().readOnly); + const shouldHaveWidget = (!this.editor.getOption(EditorOptionId.readOnly)); if (!this.widget && shouldHaveWidget) { diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index 649c7f9718be7..9a0c8edad129a 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorHoverOptions, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; @@ -68,7 +68,7 @@ suite('Common Editor Config', () => { function assertWrapping(config: TestConfiguration, isViewportWrapping: boolean, wrappingColumn: number): void { const options = config.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); assert.equal(wrappingInfo.isViewportWrapping, isViewportWrapping); assert.equal(wrappingInfo.wrappingColumn, wrappingColumn); } diff --git a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts index 20ba2e124371e..faa9ac1409758 100644 --- a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts +++ b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts @@ -19,7 +19,8 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer' import { ILineMapping, ISimpleModel, SplitLine, SplitLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection'; import { ViewLineData } from 'vs/editor/common/viewModel/viewModel'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; + suite('Editor ViewModel - SplitLinesCollection', () => { test('SplitLine', () => { @@ -90,11 +91,11 @@ suite('Editor ViewModel - SplitLinesCollection', () => { function withSplitLinesCollection(text: string, callback: (model: TextModel, linesCollection: SplitLinesCollection) => void): void { const config = new TestConfiguration({}); - const wrappingInfo = config.options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = config.options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = config.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = config.options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = config.options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = config.options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = config.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = config.options.get(EditorOptionId.wrappingIndent); const hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, @@ -743,11 +744,11 @@ suite('SplitLinesCollection', () => { wordWrapColumn: wordWrapColumn, wrappingIndent: 'indent' }); - const wrappingInfo = configuration.options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = configuration.options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = configuration.options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = configuration.options.get(EditorOptionId.wrappingInfo); + const wordWrapBreakAfterCharacters = configuration.options.get(EditorOptionId.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = configuration.options.get(EditorOptionId.wrappingIndent); const factory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 32d7a932be419..ab2061dd683ea 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3114,8 +3114,6 @@ declare namespace monaco.editor { * Controls fading out of unused variables. */ showUnused?: boolean; - layoutInfo?: undefined; - wrappingInfo?: undefined; } /** @@ -3345,7 +3343,6 @@ declare namespace monaco.editor { readonly pixelRatio: number; readonly editorClassName: string; readonly lineHeight: number; - readonly readOnly: boolean; readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; readonly multiCursorMergeOverlapping: boolean; readonly showUnused: boolean; @@ -3356,7 +3353,6 @@ declare namespace monaco.editor { readonly autoSurround: EditorAutoSurroundStrategy; readonly autoIndent: boolean; readonly useTabStops: boolean; - readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; @@ -3374,7 +3370,6 @@ declare namespace monaco.editor { readonly pixelRatio: boolean; readonly editorClassName: boolean; readonly lineHeight: boolean; - readonly readOnly: boolean; readonly multiCursorModifier: boolean; readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; @@ -3384,7 +3379,6 @@ declare namespace monaco.editor { readonly autoSurround: boolean; readonly autoIndent: boolean; readonly useTabStops: boolean; - readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; readonly copyWithSyntaxHighlighting: boolean; @@ -3411,15 +3405,15 @@ declare namespace monaco.editor { } export interface IComputedEditorOptions { - get>(id: EditorOptionId): ComputedEditorOptionValue; + get(id: T): FindComputedEditorOptionValueById; } export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never; }[keyof IEditorOptions]; - export interface IEditorOption { - readonly id: EditorOptionId; + export interface IEditorOption { + readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; read(options: IRawEditorOptionsBag): T1 | undefined; @@ -3429,11 +3423,11 @@ declare namespace monaco.editor { equals(a: T3, b: T3): boolean; } - export abstract class BaseEditorOption implements IEditorOption { - readonly id: EditorOptionId; + export abstract class BaseEditorOption implements IEditorOption { + readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; - constructor(id: EditorOptionId, name: PossibleKeyName, defaultValue: T2, deps?: EditorOptionId[]); + constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps?: EditorOptionId[]); read(options: IRawEditorOptionsBag): T1 | undefined; mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; abstract validate(input: T1 | undefined): T2; @@ -3608,50 +3602,62 @@ declare namespace monaco.editor { lineNumbersMinChars = 7, minimap = 8, mouseWheelScrollSensitivity = 9, - renderFinalNewline = 10, - renderLineNumbers = 11, - scrollbar = 12, - selectionClipboard = 13, - selectOnLineNumbers = 14, - wordWrap = 15, - wordWrapBreakAfterCharacters = 16, - wordWrapBreakBeforeCharacters = 17, - wordWrapBreakObtrusiveCharacters = 18, - wordWrapColumn = 19, - wordWrapMinified = 20, - wrappingIndent = 21, - layoutInfo = 22, - wrappingInfo = 23 + readOnly = 10, + renderFinalNewline = 11, + renderLineNumbers = 12, + scrollbar = 13, + selectionClipboard = 14, + selectOnLineNumbers = 15, + tabFocusMode = 16, + wordWrap = 17, + wordWrapBreakAfterCharacters = 18, + wordWrapBreakBeforeCharacters = 19, + wordWrapBreakObtrusiveCharacters = 20, + wordWrapColumn = 21, + wordWrapMinified = 22, + wrappingIndent = 23, + layoutInfo = 24, + wrappingInfo = 25 } export const EditorOption: { - accessibilitySupport: IEditorOption<"auto" | "on" | "off", "auto" | "on" | "off", any>; - ariaLabel: IEditorOption; - fastScrollSensitivity: IEditorOption; - folding: IEditorOption; - glyphMargin: IEditorOption; - inDiffEditor: IEditorOption; - lineDecorationsWidth: IEditorOption; - lineNumbersMinChars: IEditorOption; - minimap: IEditorOption; - mouseWheelScrollSensitivity: IEditorOption; - renderFinalNewline: IEditorOption; - renderLineNumbers: IEditorOption; - scrollbar: IEditorOption; - selectionClipboard: IEditorOption; - selectOnLineNumbers: IEditorOption; - wordWrap: IEditorOption<"on" | "off" | "wordWrapColumn" | "bounded", "on" | "off" | "wordWrapColumn" | "bounded", "on" | "off" | "wordWrapColumn" | "bounded">; - wordWrapBreakAfterCharacters: IEditorOption; - wordWrapBreakBeforeCharacters: IEditorOption; - wordWrapBreakObtrusiveCharacters: IEditorOption; - wordWrapColumn: IEditorOption; - wordWrapMinified: IEditorOption; - wrappingIndent: IEditorOption<"none" | "same" | "indent" | "deepIndent", "none" | "same" | "indent" | "deepIndent", WrappingIndent>; - layoutInfo: IEditorOption; - wrappingInfo: IEditorOption; + accessibilitySupport: IEditorOption; + ariaLabel: IEditorOption; + fastScrollSensitivity: IEditorOption; + folding: IEditorOption; + glyphMargin: IEditorOption; + inDiffEditor: IEditorOption; + lineDecorationsWidth: IEditorOption; + lineNumbersMinChars: IEditorOption; + minimap: IEditorOption; + mouseWheelScrollSensitivity: IEditorOption; + readOnly: IEditorOption; + renderFinalNewline: IEditorOption; + renderLineNumbers: IEditorOption; + scrollbar: IEditorOption; + selectionClipboard: IEditorOption; + selectOnLineNumbers: IEditorOption; + tabFocusMode: IEditorOption; + wordWrap: IEditorOption; + wordWrapBreakAfterCharacters: IEditorOption; + wordWrapBreakBeforeCharacters: IEditorOption; + wordWrapBreakObtrusiveCharacters: IEditorOption; + wordWrapColumn: IEditorOption; + wordWrapMinified: IEditorOption; + wrappingIndent: IEditorOption; + layoutInfo: IEditorOption; + wrappingInfo: IEditorOption; }; - export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; + export type EditorOptionType = typeof EditorOption; + + export type FindEditorOptionKeyById = { + [K in keyof EditorOptionType]: EditorOptionType[K]['id'] extends T ? K : never; + }[keyof EditorOptionType]; + + export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; + + export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; /** * A view zone is a full horizontal rectangle that 'pushes' text down. @@ -4103,7 +4109,7 @@ declare namespace monaco.editor { */ getConfiguration(): InternalEditorOptions; getOptions(): IComputedEditorOptions; - getOption>(id: EditorOptionId): ComputedEditorOptionValue; + getOption(id: T): FindComputedEditorOptionValueById; /** * Get value of the current model attached to this editor. * @see `ITextModel.getValue` diff --git a/src/vs/workbench/api/browser/mainThreadEditor.ts b/src/vs/workbench/api/browser/mainThreadEditor.ts index 10437ec2ed6ff..7d1d2022fed4d 100644 --- a/src/vs/workbench/api/browser/mainThreadEditor.ts +++ b/src/vs/workbench/api/browser/mainThreadEditor.ts @@ -6,7 +6,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -60,7 +60,7 @@ export class MainThreadTextEditorProperties { if (codeEditor) { const codeEditorOpts = codeEditor.getConfiguration(); const options = codeEditor.getOptions(); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); cursorStyle = codeEditorOpts.viewInfo.cursorStyle; lineNumbers = renderLineNumbers.renderType; } else if (previousProperties) { diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index f96fcd3b787cf..94e8258b4c130 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -708,7 +708,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { } } - screenReaderMode = (editorWidget.getConfiguration().accessibilitySupport === AccessibilitySupport.Enabled); + screenReaderMode = (editorWidget.getOption(EditorOptionId.accessibilitySupport) === AccessibilitySupport.Enabled); } if (screenReaderMode === false && this.screenReaderNotification) { @@ -758,7 +758,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { private onEOLChange(editorWidget: ICodeEditor | undefined): void { const info: StateDelta = { EOL: undefined }; - if (editorWidget && !editorWidget.getConfiguration().readOnly) { + if (editorWidget && !editorWidget.getOption(EditorOptionId.readOnly)) { const codeEditorModel = editorWidget.getModel(); if (codeEditorModel) { info.EOL = codeEditorModel.getEOL(); @@ -819,8 +819,7 @@ function isWritableCodeEditor(codeEditor: ICodeEditor | undefined): boolean { if (!codeEditor) { return false; } - const config = codeEditor.getConfiguration(); - return (!config.readOnly); + return !codeEditor.getOption(EditorOptionId.readOnly); } function isWritableBaseEditor(e: IBaseEditor): boolean { diff --git a/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts b/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts index a45ab6500316c..4f84e1dc2b488 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts @@ -17,7 +17,7 @@ import * as strings from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser'; import { EditorAction, EditorCommand, registerEditorAction, registerEditorCommand, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode'; @@ -185,13 +185,13 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } private _buildContent() { - let opts = this._editor.getConfiguration(); + const options = this._editor.getOptions(); let text = nls.localize('introMsg', "Thank you for trying out VS Code's accessibility options."); text += '\n\n' + nls.localize('status', "Status:"); - const configuredValue = this._configurationService.getValue('editor').accessibilitySupport; - const actualValue = opts.accessibilitySupport; + const configuredValue = this._configurationService.getValue('editor').accessibilitySupport; + const actualValue = options.get(EditorOptionId.accessibilitySupport); const emergencyTurnOnMessage = ( platform.isMacintosh @@ -229,7 +229,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { const NLS_TAB_FOCUS_MODE_OFF = nls.localize('tabFocusModeOffMsg', "Pressing Tab in the current editor will insert the tab character. Toggle this behavior by pressing {0}."); const NLS_TAB_FOCUS_MODE_OFF_NO_KB = nls.localize('tabFocusModeOffMsgNoKb', "Pressing Tab in the current editor will insert the tab character. The command {0} is currently not triggerable by a keybinding."); - if (opts.tabFocusMode) { + if (options.get(EditorOptionId.tabFocusMode)) { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, NLS_TAB_FOCUS_MODE_ON, NLS_TAB_FOCUS_MODE_ON_NO_KB); } else { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, NLS_TAB_FOCUS_MODE_OFF, NLS_TAB_FOCUS_MODE_OFF_NO_KB); diff --git a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts index 18aa8e4965e01..da10b808d17b4 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts @@ -9,7 +9,7 @@ import * as process from 'vs/base/common/process'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -24,11 +24,11 @@ export class SelectionClipboard extends Disposable implements IEditorContributio super(); if (platform.isLinux) { - let isEnabled = editor.getOption(EditorOptionId.selectionClipboard); + let isEnabled = editor.getOption(EditorOptionId.selectionClipboard); this._register(editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { if (e.hasChanged(EditorOptionId.selectionClipboard)) { - isEnabled = editor.getOption(EditorOptionId.selectionClipboard); + isEnabled = editor.getOption(EditorOptionId.selectionClipboard); } })); diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts index e8472a05fe634..8d22a06dcba95 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts @@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; @@ -85,7 +85,7 @@ function toggleWordWrap(editor: ICodeEditor, state: IWordWrapState): IWordWrapSt let transientState: IWordWrapTransientState; - const actualWrappingInfo = editor.getOption(EditorOptionId.wrappingInfo); + const actualWrappingInfo = editor.getOption(EditorOptionId.wrappingInfo); if (actualWrappingInfo.isWordWrapMinified) { // => wrapping due to minified file transientState = { @@ -138,7 +138,7 @@ class ToggleWordWrapAction extends EditorAction { if (!editor.hasModel()) { return; } - if (editor.getOption(EditorOptionId.inDiffEditor)) { + if (editor.getOption(EditorOptionId.inDiffEditor)) { // Cannot change wrapping settings inside the diff editor const notificationService = accessor.get(INotificationService); notificationService.info(nls.localize('wordWrap.notInDiffEditor', "Cannot toggle word wrap in a diff editor.")); @@ -176,10 +176,10 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution super(); const options = this.editor.getOptions(); - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); const isWordWrapMinified = this.contextKeyService.createKey(isWordWrapMinifiedKey, wrappingInfo.isWordWrapMinified); const isDominatedByLongLines = this.contextKeyService.createKey(isDominatedByLongLinesKey, wrappingInfo.isDominatedByLongLines); - const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOptionId.inDiffEditor)); + const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOptionId.inDiffEditor)); let currentlyApplyingEditorConfig = false; this._register(editor.onDidChangeConfiguration((e) => { @@ -187,10 +187,10 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution return; } const options = this.editor.getOptions(); - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOptionId.wrappingInfo); isWordWrapMinified.set(wrappingInfo.isWordWrapMinified); isDominatedByLongLines.set(wrappingInfo.isDominatedByLongLines); - inDiffEditor.set(options.get(EditorOptionId.inDiffEditor)); + inDiffEditor.set(options.get(EditorOptionId.inDiffEditor)); if (!currentlyApplyingEditorConfig) { // I am not the cause of the word wrap getting changed ensureWordWrapSettings(); @@ -216,7 +216,7 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution return; } - if (this.editor.getOption(EditorOptionId.inDiffEditor)) { + if (this.editor.getOption(EditorOptionId.inDiffEditor)) { return; } diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 94a1a35948188..52068f454fcaa 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -37,7 +37,7 @@ import { COMMENTEDITOR_DECORATION_KEY, ReviewZoneWidget } from 'vs/workbench/con import { ctxCommentEditorFocused, SimpleCommentEditor } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export const ID = 'editor.contrib.review'; @@ -603,7 +603,7 @@ export class ReviewController implements IEditorContribution { } const options = this.editor.getOptions(); - if (options.get(EditorOptionId.folding)) { + if (options.get(EditorOptionId.folding)) { lineDecorationsWidth -= 16; } lineDecorationsWidth += 9; diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts index 2074a14ab74b4..d0d7906907c90 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts @@ -41,7 +41,7 @@ import { ContextSubMenu } from 'vs/base/browser/contextmenu'; import { memoize } from 'vs/base/common/decorators'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { getHover } from 'vs/editor/contrib/hover/getHover'; -import { IEditorHoverOptions } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { CancellationToken } from 'vs/base/common/cancellation'; import { BreakpointWidget } from 'vs/workbench/contrib/debug/browser/breakpointWidget'; import { DebugHoverWidget } from 'vs/workbench/contrib/debug/browser/debugHover'; @@ -540,7 +540,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { if (this.configurationWidget) { this.configurationWidget.dispose(); } - if (model && LAUNCH_JSON_REGEX.test(model.uri.toString()) && !this.editor.getConfiguration().readOnly) { + if (model && LAUNCH_JSON_REGEX.test(model.uri.toString()) && !this.editor.getOption(EditorOptionId.readOnly)) { this.configurationWidget = this.instantiationService.createInstance(FloatingClickWidget, this.editor, nls.localize('addConfiguration', "Add Configuration..."), null); this.configurationWidget.render(); this.toDispose.push(this.configurationWidget.onClick(() => this.addLaunchConfiguration())); diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts index d9b7e38db910b..f3e4b3ca25559 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts @@ -30,6 +30,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { KeybindingParser } from 'vs/base/common/keybindingParser'; import Severity from 'vs/base/common/severity'; import { SeverityIcon } from 'vs/platform/severityIcon/common/severityIcon'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding"); const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout."); @@ -82,7 +83,7 @@ export class DefineKeybindingController extends Disposable implements editorComm this._createKeybindingDecorationRenderer(); // The button to define keybindings is shown only for the user keybindings.json - if (!this._editor.getConfiguration().readOnly) { + if (!this._editor.getOption(EditorOptionId.readOnly)) { this._createKeybindingWidgetRenderer(); } else { this._disposeKeybindingWidgetRenderer(); @@ -377,7 +378,7 @@ class DefineKeybindingCommand extends EditorCommand { } runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void { - if (!isInterestingEditorModel(editor) || editor.getConfiguration().readOnly) { + if (!isInterestingEditorModel(editor) || editor.getOption(EditorOptionId.readOnly)) { return; } const controller = DefineKeybindingController.get(editor); diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 6b7383786097c..6f4eb6a5551fe 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -33,7 +33,7 @@ import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/p import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences'; -import { EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; export class SettingsHeaderWidget extends Widget implements IViewZone { @@ -88,7 +88,7 @@ export class SettingsHeaderWidget extends Widget implements IViewZone { const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; - if (!options.get(EditorOptionId.folding)) { + if (!options.get(EditorOptionId.folding)) { this.titleContainer.style.paddingLeft = '6px'; } } diff --git a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts index eaafa00f21b54..418aafc01303c 100644 --- a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts @@ -16,7 +16,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IRange } from 'vs/editor/common/core/range'; import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; -import { IEditorOptions, RenderLineNumbersType, EditorOption, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; @@ -51,7 +51,7 @@ export class GotoLineAction extends QuickOpenAction { if (isCodeEditor(activeTextEditorWidget)) { const options = activeTextEditorWidget.getOptions(); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); if (renderLineNumbers.renderType === RenderLineNumbersType.Relative) { activeTextEditorWidget.updateOptions({ lineNumbers: 'on' diff --git a/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts b/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts index fff264d6463f0..4571d5e6ef85c 100644 --- a/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts +++ b/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts @@ -23,6 +23,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ILabelService } from 'vs/platform/label/common/label'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; abstract class Recording { @@ -414,7 +415,7 @@ export class BulkEditService implements IBulkEditService { } } - if (codeEditor && codeEditor.getConfiguration().readOnly) { + if (codeEditor && codeEditor.getOption(EditorOptionId.readOnly)) { // If the code editor is readonly still allow bulk edits to be applied #68549 codeEditor = undefined; } From 16c1772bdf3092c5d41225725c65e566ea8bfd6d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Sep 2019 00:22:23 +0200 Subject: [PATCH 007/204] renames --- .../editor/browser/controller/mouseHandler.ts | 6 +- .../editor/browser/controller/mouseTarget.ts | 6 +- .../browser/controller/textAreaHandler.ts | 20 +-- src/vs/editor/browser/editorBrowser.ts | 4 +- src/vs/editor/browser/view/viewImpl.ts | 6 +- src/vs/editor/browser/view/viewLayer.ts | 4 +- src/vs/editor/browser/view/viewOverlays.ts | 14 +- .../contentWidgets/contentWidgets.ts | 8 +- .../currentLineHighlight.ts | 8 +- .../currentLineMarginHighlight.ts | 8 +- .../editorScrollbar/editorScrollbar.ts | 26 +-- .../viewParts/glyphMargin/glyphMargin.ts | 8 +- .../viewParts/indentGuides/indentGuides.ts | 8 +- .../viewParts/lineNumbers/lineNumbers.ts | 8 +- .../browser/viewParts/lines/viewLines.ts | 12 +- .../linesDecorations/linesDecorations.ts | 8 +- .../editor/browser/viewParts/margin/margin.ts | 8 +- .../browser/viewParts/minimap/minimap.ts | 6 +- .../overlayWidgets/overlayWidgets.ts | 8 +- .../overviewRuler/decorationsOverviewRuler.ts | 6 +- .../editor/browser/viewParts/rulers/rulers.ts | 4 +- .../scrollDecoration/scrollDecoration.ts | 12 +- .../viewParts/viewCursors/viewCursors.ts | 8 +- .../browser/viewParts/viewZones/viewZones.ts | 8 +- .../editor/browser/widget/codeEditorWidget.ts | 22 +-- .../editor/browser/widget/diffEditorWidget.ts | 4 +- src/vs/editor/browser/widget/diffReview.ts | 4 +- .../editor/browser/widget/inlineDiffMargin.ts | 4 +- .../common/config/commonEditorConfig.ts | 28 ++-- src/vs/editor/common/config/editorOptions.ts | 158 +++++++++--------- src/vs/editor/common/controller/cursor.ts | 4 +- .../editor/common/controller/cursorCommon.ts | 10 +- .../common/standalone/standaloneEnums.ts | 2 +- src/vs/editor/common/view/viewEvents.ts | 4 +- src/vs/editor/common/viewLayout/viewLayout.ts | 12 +- .../common/viewModel/viewModelDecorations.ts | 4 +- .../editor/common/viewModel/viewModelImpl.ts | 20 +-- .../contrib/codeAction/codeActionModel.ts | 4 +- src/vs/editor/contrib/find/findController.ts | 4 +- src/vs/editor/contrib/find/findWidget.ts | 16 +- src/vs/editor/contrib/folding/folding.ts | 8 +- src/vs/editor/contrib/hover/hover.ts | 4 +- src/vs/editor/contrib/suggest/suggestModel.ts | 4 +- .../accessibilityHelp/accessibilityHelp.ts | 12 +- .../iPadShowKeyboard/iPadShowKeyboard.ts | 4 +- .../standalone/browser/standaloneEditor.ts | 4 +- .../common/config/commonEditorConfig.test.ts | 4 +- .../viewModel/splitLinesCollection.test.ts | 22 +-- src/vs/monaco.d.ts | 78 ++++----- .../workbench/api/browser/mainThreadEditor.ts | 4 +- .../browser/parts/editor/editorStatus.ts | 10 +- .../browser/accessibility/accessibility.ts | 6 +- .../codeEditor/browser/selectionClipboard.ts | 8 +- .../codeEditor/browser/toggleWordWrap.ts | 20 +-- .../browser/commentsEditorContribution.ts | 4 +- .../debug/browser/debugEditorContribution.ts | 4 +- .../browser/keybindingsEditorContribution.ts | 6 +- .../preferences/browser/preferencesWidgets.ts | 4 +- .../quickopen/browser/gotoLineHandler.ts | 4 +- .../bulkEdit/browser/bulkEditService.ts | 4 +- 60 files changed, 364 insertions(+), 364 deletions(-) diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index a28b811da241d..f9b2f538465e2 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -21,7 +21,7 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; /** @@ -218,7 +218,7 @@ export class MouseHandler extends ViewEventHandler { const targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY); const targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS); const targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS); - const selectOnLineNumbers = this._context.configuration.options.get(EditorOptionId.selectOnLineNumbers); + const selectOnLineNumbers = this._context.configuration.options.get(EditorOption.selectOnLineNumbers); const targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE); const targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET); @@ -354,7 +354,7 @@ class MouseDownOperation extends Disposable { e.detail = this._mouseState.count; const options = this._context.configuration.options; - const readOnly = options.get(EditorOptionId.readOnly); + const readOnly = options.get(EditorOption.readOnly); if (!readOnly && this._context.configuration.editor.dragAndDrop diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index cde6cad5f2dfc..1db7f2849a444 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -10,7 +10,7 @@ import { ClientCoordinates, EditorMouseEvent, EditorPagePosition, PageCoordinate import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart'; import { ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine'; import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; -import { EditorLayoutInfo, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorLayoutInfo, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range as EditorRange } from 'vs/editor/common/core/range'; import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; @@ -240,7 +240,7 @@ export class HitTestContext { constructor(context: ViewContext, viewHelper: IPointerHandlerHelper, lastViewCursorsRenderData: IViewCursorRenderData[]) { this.model = context.model; const options = context.configuration.options; - this.layoutInfo = options.get(EditorOptionId.layoutInfo); + this.layoutInfo = options.get(EditorOption.layoutInfo); this.viewDomNode = viewHelper.viewDomNode; this.lineHeight = context.configuration.editor.lineHeight; this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; @@ -715,7 +715,7 @@ export class MouseTargetFactory { public getMouseColumn(editorPos: EditorPagePosition, pos: PageCoordinates): number { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); const mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft; return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index c02aaef8ecd22..347cd523a817f 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -16,7 +16,7 @@ import { ViewController } from 'vs/editor/browser/view/viewController'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; import { LineNumbersOverlay } from 'vs/editor/browser/viewParts/lineNumbers/lineNumbers'; import { Margin } from 'vs/editor/browser/viewParts/margin/margin'; -import { RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOption } from 'vs/editor/common/config/editorOptions'; import { BareFontInfo } from 'vs/editor/common/config/fontInfo'; import { WordCharacterClass, getMapForWordSeparators } from 'vs/editor/common/controller/wordCharacterClassifier'; import { Position } from 'vs/editor/common/core/position'; @@ -120,9 +120,9 @@ export class TextAreaHandler extends ViewPart { const conf = this._context.configuration.editor; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); - this._accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + this._accessibilitySupport = options.get(EditorOption.accessibilitySupport); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; @@ -145,7 +145,7 @@ export class TextAreaHandler extends ViewPart { this.textArea.setAttribute('autocapitalize', 'off'); this.textArea.setAttribute('autocomplete', 'off'); this.textArea.setAttribute('spellcheck', 'false'); - this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); + this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel)); this.textArea.setAttribute('role', 'textbox'); this.textArea.setAttribute('aria-multiline', 'true'); this.textArea.setAttribute('aria-haspopup', 'false'); @@ -379,10 +379,10 @@ export class TextAreaHandler extends ViewPart { this._fontInfo = conf.fontInfo; } if (e.viewInfo) { - this.textArea.setAttribute('aria-label', options.get(EditorOptionId.ariaLabel)); + this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel)); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; @@ -390,8 +390,8 @@ export class TextAreaHandler extends ViewPart { if (e.lineHeight) { this._lineHeight = conf.lineHeight; } - if (e.hasChanged(EditorOptionId.accessibilitySupport)) { - this._accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + if (e.hasChanged(EditorOption.accessibilitySupport)) { + this._accessibilitySupport = options.get(EditorOption.accessibilitySupport); this._textAreaInput.writeScreenReaderContent('strategy changed'); } if (e.emptySelectionClipboard) { @@ -553,7 +553,7 @@ export class TextAreaHandler extends ViewPart { if (this._context.configuration.editor.viewInfo.glyphMargin) { tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME); } else { - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOption.renderLineNumbers); if (renderLineNumbers.renderType !== RenderLineNumbersType.Off) { tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME); } else { diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index 5e94f07990bd6..c8f7a8ee5caa8 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -6,7 +6,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IMouseEvent, IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { OverviewRulerPosition, IConfigurationChangedEvent, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOptionId, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { OverviewRulerPosition, IConfigurationChangedEvent, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { IPosition, Position } from 'vs/editor/common/core/position'; @@ -538,7 +538,7 @@ export interface ICodeEditor extends editorCommon.IEditor { getOptions(): IComputedEditorOptions; - getOption(id: T): FindComputedEditorOptionValueById; + getOption(id: T): FindComputedEditorOptionValueById; /** * Returns the 'raw' editor's configuration (without any validation or defaults). * @internal diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 41a04db7b4a6a..2a31441bc8641 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -48,7 +48,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData' import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IContentWidgetData { @@ -284,7 +284,7 @@ export class View extends ViewEventHandler { private _setLayout(): void { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this.domNode.setWidth(layoutInfo.width); this.domNode.setHeight(layoutInfo.height); @@ -307,7 +307,7 @@ export class View extends ViewEventHandler { if (e.editorClassName) { this.domNode.setClassName(this.getEditorClassName()); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { this._setLayout(); } return false; diff --git a/src/vs/editor/browser/view/viewLayer.ts b/src/vs/editor/browser/view/viewLayer.ts index c5624ce9c83e7..eec48240c906e 100644 --- a/src/vs/editor/browser/view/viewLayer.ts +++ b/src/vs/editor/browser/view/viewLayer.ts @@ -7,7 +7,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; /** * Represents a visible line @@ -270,7 +270,7 @@ export class VisibleLinesCollection { // ---- begin view event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { return true; } return false; diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index 5e0015eb0a90d..bf7fed99d46a2 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -14,7 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class ViewOverlays extends ViewPart implements IVisibleLinesHost { @@ -218,7 +218,7 @@ export class ContentViewOverlays extends ViewOverlays { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentWidth = layoutInfo.contentWidth; this.domNode.setHeight(0); @@ -227,9 +227,9 @@ export class ContentViewOverlays extends ViewOverlays { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentWidth = layoutInfo.contentWidth; } return super.onConfigurationChanged(e); @@ -255,7 +255,7 @@ export class MarginViewOverlays extends ViewOverlays { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this.domNode.setClassName('margin-view-overlays'); @@ -270,9 +270,9 @@ export class MarginViewOverlays extends ViewOverlays { Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); shouldRender = true; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; shouldRender = true; } diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index 6975b25a6bc7f..74ca7cbd66a6f 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -14,7 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class Coordinate { @@ -210,7 +210,7 @@ class Widget { this.suppressMouseDown = this._actual.suppressMouseDown || false; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets; this._contentWidth = layoutInfo.contentWidth; @@ -238,9 +238,9 @@ class Widget { if (e.lineHeight) { this._lineHeight = this._context.configuration.editor.lineHeight; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._maxWidth = this._getMaxWidth(); diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index 63aa133402253..41cb1c2080cd4 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -10,7 +10,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class CurrentLineHighlightOverlay extends DynamicViewOverlay { @@ -26,7 +26,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; @@ -54,9 +54,9 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { if (e.viewInfo) { this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentWidth = layoutInfo.contentWidth; } return true; diff --git a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts index 3601770f5b8f6..e6d01e2ebcf8e 100644 --- a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts @@ -10,7 +10,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { @@ -25,7 +25,7 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; @@ -50,9 +50,9 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { if (e.viewInfo) { this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; } return true; diff --git a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts index df5316bfb8043..d816f1265e829 100644 --- a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts +++ b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts @@ -14,7 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class EditorScrollbar extends ViewPart { @@ -31,9 +31,9 @@ export class EditorScrollbar extends ViewPart { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); - const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); - const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); + const scrollbar = options.get(EditorOption.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOption.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOption.fastScrollSensitivity); const scrollbarOptions: ScrollableElementCreationOptions = { listenOnDomNode: viewDomNode.domNode, @@ -101,11 +101,11 @@ export class EditorScrollbar extends ViewPart { private _setLayout(): void { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this.scrollbarDomNode.setLeft(layoutInfo.contentLeft); - const minimap = options.get(EditorOptionId.minimap); + const minimap = options.get(EditorOption.minimap); const side = minimap.side; if (side === 'right') { this.scrollbarDomNode.setWidth(layoutInfo.contentWidth + layoutInfo.minimapWidth); @@ -131,14 +131,14 @@ export class EditorScrollbar extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { if ( - e.hasChanged(EditorOptionId.scrollbar) - || e.hasChanged(EditorOptionId.mouseWheelScrollSensitivity) - || e.hasChanged(EditorOptionId.fastScrollSensitivity) + e.hasChanged(EditorOption.scrollbar) + || e.hasChanged(EditorOption.mouseWheelScrollSensitivity) + || e.hasChanged(EditorOption.fastScrollSensitivity) ) { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); - const mouseWheelScrollSensitivity = options.get(EditorOptionId.mouseWheelScrollSensitivity); - const fastScrollSensitivity = options.get(EditorOptionId.fastScrollSensitivity); + const scrollbar = options.get(EditorOption.scrollbar); + const mouseWheelScrollSensitivity = options.get(EditorOption.mouseWheelScrollSensitivity); + const fastScrollSensitivity = options.get(EditorOption.fastScrollSensitivity); const newOpts: ScrollableElementChangeOptions = { handleMouseWheel: scrollbar.handleMouseWheel, mouseWheelScrollSensitivity: mouseWheelScrollSensitivity, @@ -146,7 +146,7 @@ export class EditorScrollbar extends ViewPart { }; this.scrollbar.updateOptions(newOpts); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { this._setLayout(); } return true; diff --git a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts index 516cdb1f4686c..a402d430826db 100644 --- a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts +++ b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts @@ -8,7 +8,7 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class DecorationToRender { @@ -87,7 +87,7 @@ export class GlyphMarginOverlay extends DedupOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; this._glyphMarginLeft = layoutInfo.glyphMarginLeft; @@ -113,8 +113,8 @@ export class GlyphMarginOverlay extends DedupOverlay { if (e.viewInfo) { this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; } diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index 9da6446edf96b..fb275d96ba3d2 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -11,7 +11,7 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class IndentGuidesOverlay extends DynamicViewOverlay { @@ -34,7 +34,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); @@ -63,8 +63,8 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; } - if (e.hasChanged(EditorOptionId.wrappingInfo) || e.fontInfo) { - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + if (e.hasChanged(EditorOption.wrappingInfo) || e.fontInfo) { + const wrappingInfo = options.get(EditorOption.wrappingInfo); const wrappingColumn = wrappingInfo.wrappingColumn; this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); } diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index aa078b1b8341c..8673e31f1538b 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -6,7 +6,7 @@ import 'vs/css!./lineNumbers'; import * as platform from 'vs/base/common/platform'; import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay'; -import { RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { editorActiveLineNumber, editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry'; import { RenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -44,11 +44,11 @@ export class LineNumbersOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const config = this._context.configuration.editor; this._lineHeight = config.lineHeight; - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOption.renderLineNumbers); this._renderLineNumbers = renderLineNumbers.renderType; this._renderCustomLineNumbers = renderLineNumbers.renderFn; - this._renderFinalNewline = options.get(EditorOptionId.renderFinalNewline); - const layoutInfo = options.get(EditorOptionId.layoutInfo); + this._renderFinalNewline = options.get(EditorOption.renderFinalNewline); + const layoutInfo = options.get(EditorOption.layoutInfo); this._lineNumbersLeft = layoutInfo.lineNumbersLeft; this._lineNumbersWidth = layoutInfo.lineNumbersWidth; } diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 80c851b008410..7fff4453ba588 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -18,7 +18,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { Viewport } from 'vs/editor/common/viewModel/viewModel'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class LastRenderedData { @@ -92,7 +92,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const conf = this._context.configuration; const options = this._context.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); this._lineHeight = conf.editor.lineHeight; this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; @@ -138,7 +138,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { this._visibleLines.onConfigurationChanged(e); - if (e.hasChanged(EditorOptionId.wrappingInfo)) { + if (e.hasChanged(EditorOption.wrappingInfo)) { this._maxLineWidth = 0; } @@ -151,8 +151,8 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, if (e.fontInfo) { this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; } - if (e.hasChanged(EditorOptionId.wrappingInfo)) { - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + if (e.hasChanged(EditorOption.wrappingInfo)) { + const wrappingInfo = options.get(EditorOption.wrappingInfo); this._isViewportWrapping = wrappingInfo.isViewportWrapping; } if (e.viewInfo) { @@ -168,7 +168,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._onOptionsMaybeChanged(); - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { this._maxLineWidth = 0; } diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts index 4beec4716a164..c8ad48eb26f38 100644 --- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts +++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts @@ -8,7 +8,7 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl import { RenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class LinesDecorationsOverlay extends DedupOverlay { @@ -23,7 +23,7 @@ export class LinesDecorationsOverlay extends DedupOverlay { super(); this._context = context; const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._decorationsLeft = layoutInfo.decorationsLeft; this._decorationsWidth = layoutInfo.decorationsWidth; this._renderResult = null; @@ -40,8 +40,8 @@ export class LinesDecorationsOverlay extends DedupOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._decorationsLeft = layoutInfo.decorationsLeft; this._decorationsWidth = layoutInfo.decorationsWidth; } diff --git a/src/vs/editor/browser/viewParts/margin/margin.ts b/src/vs/editor/browser/viewParts/margin/margin.ts index 79cc1b4f500f2..2710a194dd094 100644 --- a/src/vs/editor/browser/viewParts/margin/margin.ts +++ b/src/vs/editor/browser/viewParts/margin/margin.ts @@ -8,7 +8,7 @@ import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class Margin extends ViewPart { @@ -26,7 +26,7 @@ export class Margin extends ViewPart { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; this._contentLeft = layoutInfo.contentLeft; @@ -62,8 +62,8 @@ export class Margin extends ViewPart { this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index ce8218c915f06..7df0b183c3ca1 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -13,7 +13,7 @@ import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ILine, RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer'; import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart'; -import { RenderMinimap, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderMinimap, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { RGBA8 } from 'vs/editor/common/core/rgba'; import { IConfiguration, ScrollType } from 'vs/editor/common/editorCommon'; @@ -109,13 +109,13 @@ class MinimapOptions { constructor(configuration: IConfiguration) { const options = configuration.options; const pixelRatio = configuration.editor.pixelRatio; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); const viewInfo = configuration.editor.viewInfo; const fontInfo = configuration.editor.fontInfo; this.renderMinimap = layoutInfo.renderMinimap | 0; this.scrollBeyondLastLine = viewInfo.scrollBeyondLastLine; - const minimapOpts = options.get(EditorOptionId.minimap); + const minimapOpts = options.get(EditorOption.minimap); this.showSlider = minimapOpts.showSlider; this.pixelRatio = pixelRatio; this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; diff --git a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts index 2d1380345688d..ba9128c06de90 100644 --- a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts +++ b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts @@ -10,7 +10,7 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; interface IWidgetData { @@ -38,7 +38,7 @@ export class ViewOverlayWidgets extends ViewPart { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._widgets = {}; this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; @@ -66,8 +66,8 @@ export class ViewOverlayWidgets extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; this._minimapWidth = layoutInfo.minimapWidth; this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index 463a4592c2768..2f02db4df4350 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -15,7 +15,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ITheme } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class Settings { @@ -58,7 +58,7 @@ class Settings { this.themeType = theme.type; - const minimapOpts = options.get(EditorOptionId.minimap); + const minimapOpts = options.get(EditorOption.minimap); const minimapEnabled = minimapOpts.enabled; const minimapSide = minimapOpts.side; const backgroundColor = (minimapEnabled ? TokenizationRegistry.getDefaultBackground() : null); @@ -68,7 +68,7 @@ class Settings { this.backgroundColor = Color.Format.CSS.formatHex(backgroundColor); } - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); const position = layoutInfo.overviewRuler; this.top = position.top; this.right = position.right; diff --git a/src/vs/editor/browser/viewParts/rulers/rulers.ts b/src/vs/editor/browser/viewParts/rulers/rulers.ts index ceb396185fd56..21981080a0ef5 100644 --- a/src/vs/editor/browser/viewParts/rulers/rulers.ts +++ b/src/vs/editor/browser/viewParts/rulers/rulers.ts @@ -11,7 +11,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class Rulers extends ViewPart { @@ -39,7 +39,7 @@ export class Rulers extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { if (e.viewInfo - || e.hasChanged(EditorOptionId.layoutInfo) + || e.hasChanged(EditorOption.layoutInfo) || e.fontInfo ) { this._rulers = this._context.configuration.editor.viewInfo.rulers; diff --git a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts index 8a482e5603101..7e516f8e221d9 100644 --- a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts +++ b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts @@ -11,7 +11,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class ScrollDecorationViewPart extends ViewPart { @@ -30,7 +30,7 @@ export class ScrollDecorationViewPart extends ViewPart { this._updateWidth(); this._shouldShow = false; const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOption.scrollbar); this._useShadows = scrollbar.useShadows; this._domNode = createFastDomNode(document.createElement('div')); this._domNode.setAttribute('role', 'presentation'); @@ -56,7 +56,7 @@ export class ScrollDecorationViewPart extends ViewPart { private _updateWidth(): boolean { const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); let newWidth = 0; if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) { newWidth = layoutInfo.width; @@ -74,12 +74,12 @@ export class ScrollDecorationViewPart extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { let shouldRender = false; - if (e.hasChanged(EditorOptionId.scrollbar)) { + if (e.hasChanged(EditorOption.scrollbar)) { const options = this._context.configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOption.scrollbar); this._useShadows = scrollbar.useShadows; } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { shouldRender = this._updateWidth(); } return this._updateShouldShow() || shouldRender; diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts index ede284d354316..f9dc4932f760f 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts @@ -8,7 +8,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IntervalTimer, TimeoutTimer } from 'vs/base/common/async'; import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { IViewCursorRenderData, ViewCursor } from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; -import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { editorCursorBackground, editorCursorForeground } from 'vs/editor/common/view/editorColorRegistry'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -44,7 +44,7 @@ export class ViewCursors extends ViewPart { super(context); const options = this._context.configuration.options; - this._readOnly = options.get(EditorOptionId.readOnly); + this._readOnly = options.get(EditorOption.readOnly); this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation; @@ -87,8 +87,8 @@ export class ViewCursors extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.hasChanged(EditorOptionId.readOnly)) { - this._readOnly = options.get(EditorOptionId.readOnly); + if (e.hasChanged(EditorOption.readOnly)) { + this._readOnly = options.get(EditorOption.readOnly); } if (e.viewInfo) { this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; diff --git a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts index 13bf932d19b3a..ed6976ba9fa53 100644 --- a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts +++ b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts @@ -12,7 +12,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { IViewWhitespaceViewportData } from 'vs/editor/common/viewModel/viewModel'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IMyViewZone { @@ -43,7 +43,7 @@ export class ViewZones extends ViewPart { constructor(context: ViewContext) { super(context); const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; this._contentWidth = layoutInfo.contentWidth; @@ -96,8 +96,8 @@ export class ViewZones extends ViewPart { return this._recomputeWhitespacesProps(); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { - const layoutInfo = options.get(EditorOptionId.layoutInfo); + if (e.hasChanged(EditorOption.layoutInfo)) { + const layoutInfo = options.get(EditorOption.layoutInfo); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index d0cdffa1ca28f..cdc154e5521dd 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl'; import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents'; -import { IConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOptionId, InternalEditorOptions, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, InternalEditorOptions, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; import { Cursor, CursorStateChangedEvent } from 'vs/editor/common/controller/cursor'; import { CursorColumns, ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; @@ -259,9 +259,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._register(this._configuration.onDidChange((e) => { this._onDidChangeConfiguration.fire(e); - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._onDidLayoutChange.fire(layoutInfo); } if (this._configuration.editor.showUnused) { @@ -376,7 +376,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE return this._configuration.options; } - public getOption(id: T): FindComputedEditorOptionValueById { + public getOption(id: T): FindComputedEditorOptionValueById { return this._configuration.options.get(id); } @@ -982,7 +982,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return false; } - if (this._configuration.options.get(EditorOptionId.readOnly)) { + if (this._configuration.options.get(EditorOption.readOnly)) { // read only editor => sorry! return false; } @@ -994,7 +994,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return false; } - if (this._configuration.options.get(EditorOptionId.readOnly)) { + if (this._configuration.options.get(EditorOption.readOnly)) { // read only editor => sorry! return false; } @@ -1038,7 +1038,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (!this._modelData) { return null; } - return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.options.get(EditorOptionId.readOnly)); + return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.options.get(EditorOption.readOnly)); } public deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[] { @@ -1131,7 +1131,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE public getLayoutInfo(): EditorLayoutInfo { const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); return layoutInfo; } @@ -1281,7 +1281,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE const position = this._modelData.model.validatePosition(rawPosition); const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); const top = CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, position.lineNumber, position.column) - this.getScrollTop(); const left = this._modelData.view.getOffsetForColumn(position.lineNumber, position.column) + layoutInfo.glyphMarginWidth + layoutInfo.lineNumbersWidth + layoutInfo.decorationsWidth - this.getScrollLeft(); @@ -1616,8 +1616,8 @@ class EditorContextKeysManager extends Disposable { private _updateFromConfig(): void { const options = this._editor.getOptions(); - this._editorTabMovesFocus.set(options.get(EditorOptionId.tabFocusMode)); - this._editorReadonly.set(options.get(EditorOptionId.readOnly)); + this._editorTabMovesFocus.set(options.get(EditorOption.tabFocusMode)); + this._editorReadonly.set(options.get(EditorOption.readOnly)); } private _updateFromSelection(): void { diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index d2ba7bd565d35..c07f9ec9552f9 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -20,7 +20,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { DiffReview } from 'vs/editor/browser/widget/diffReview'; -import { IDiffEditorOptions, IEditorOptions, EDITOR_DEFAULTS, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IDiffEditorOptions, IEditorOptions, EDITOR_DEFAULTS, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -1995,7 +1995,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { let sb = createStringBuilder(10000); let marginHTML: string[] = []; - const layoutInfo = this.modifiedEditorOptions.get(EditorOptionId.layoutInfo); + const layoutInfo = this.modifiedEditorOptions.get(EditorOption.layoutInfo); const lineDecorationsWidth = layoutInfo.decorationsWidth; let lineHeight = this.modifiedEditorConfiguration.lineHeight; diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index 8c51ecede42d9..63eba820ab8bf 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -667,10 +667,10 @@ export class DiffReview extends Disposable { originalLineEnd - originalLineStart ); - const originalLayoutInfo = originalOptions.get(editorOptions.EditorOptionId.layoutInfo); + const originalLayoutInfo = originalOptions.get(editorOptions.EditorOption.layoutInfo); const originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth; - const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOptionId.layoutInfo); + const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOption.layoutInfo); const modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth; for (let i = 0; i <= cnt; i++) { diff --git a/src/vs/editor/browser/widget/inlineDiffMargin.ts b/src/vs/editor/browser/widget/inlineDiffMargin.ts index afc6287dc02cf..a55022c8b522b 100644 --- a/src/vs/editor/browser/widget/inlineDiffMargin.ts +++ b/src/vs/editor/browser/widget/inlineDiffMargin.ts @@ -12,7 +12,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { Range } from 'vs/editor/common/core/range'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IDiffLinesChange { readonly originalStartLineNumber: number; @@ -98,7 +98,7 @@ export class InlineDiffMargin extends Disposable { actions.push(copyLineAction); } - const readOnly = editor.getOption(EditorOptionId.readOnly); + const readOnly = editor.getOption(EditorOption.readOnly); if (!readOnly) { actions.push(new Action('diff.inline.revertChange', nls.localize('diff.inline.revertChange.label', "Revert this change"), undefined, true, async () => { if (diff.modifiedEndLineNumber === 0) { diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 921bb9d99b8f1..433788372bd8e 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; -import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOption, EDITOR_MODEL_DEFAULTS, blinkingStyleToString, cursorStyleToString } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, blinkingStyleToString, cursorStyleToString } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -363,7 +363,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.renderFinalNewline': { 'type': 'boolean', - 'default': EditorOption.renderFinalNewline.defaultValue, + 'default': EditorOptions.renderFinalNewline.defaultValue, 'description': nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }, 'editor.rulers': { @@ -431,29 +431,29 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.minimap.enabled': { 'type': 'boolean', - 'default': EditorOption.minimap.defaultValue.enabled, + 'default': EditorOptions.minimap.defaultValue.enabled, 'description': nls.localize('minimap.enabled', "Controls whether the minimap is shown.") }, 'editor.minimap.side': { 'type': 'string', 'enum': ['left', 'right'], - 'default': EditorOption.minimap.defaultValue.side, + 'default': EditorOptions.minimap.defaultValue.side, 'description': nls.localize('minimap.side', "Controls the side where to render the minimap.") }, 'editor.minimap.showSlider': { 'type': 'string', 'enum': ['always', 'mouseover'], - 'default': EditorOption.minimap.defaultValue.showSlider, + 'default': EditorOptions.minimap.defaultValue.showSlider, 'description': nls.localize('minimap.showSlider', "Controls whether the minimap slider is automatically hidden.") }, 'editor.minimap.renderCharacters': { 'type': 'boolean', - 'default': EditorOption.minimap.defaultValue.renderCharacters, + 'default': EditorOptions.minimap.defaultValue.renderCharacters, 'description': nls.localize('minimap.renderCharacters', "Render the actual characters on a line as opposed to color blocks.") }, 'editor.minimap.maxColumn': { 'type': 'number', - 'default': EditorOption.minimap.defaultValue.maxColumn, + 'default': EditorOptions.minimap.defaultValue.maxColumn, 'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.") }, 'editor.hover.enabled': { @@ -512,7 +512,7 @@ const editorConfiguration: IConfigurationNode = { ] }, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."), ], - 'default': EditorOption.wordWrap.defaultValue, + 'default': EditorOptions.wordWrap.defaultValue, 'description': nls.localize({ key: 'wordWrap', comment: [ @@ -523,7 +523,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.wordWrapColumn': { 'type': 'integer', - 'default': EditorOption.wordWrapColumn.defaultValue, + 'default': EditorOptions.wordWrapColumn.defaultValue, 'minimum': 1, 'markdownDescription': nls.localize({ key: 'wordWrapColumn', @@ -547,12 +547,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.mouseWheelScrollSensitivity': { 'type': 'number', - 'default': EditorOption.mouseWheelScrollSensitivity.defaultValue, + 'default': EditorOptions.mouseWheelScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }, 'editor.fastScrollSensitivity': { 'type': 'number', - 'default': EditorOption.fastScrollSensitivity.defaultValue, + 'default': EditorOptions.fastScrollSensitivity.defaultValue, 'markdownDescription': nls.localize('fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`.") }, 'editor.multiCursorModifier': { @@ -1049,7 +1049,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.folding': { 'type': 'boolean', - 'default': EditorOption.folding.defaultValue, + 'default': EditorOptions.folding.defaultValue, 'description': nls.localize('folding', "Controls whether the editor has code folding enabled.") }, 'editor.foldingStrategy': { @@ -1102,7 +1102,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader."), nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."), ], - 'default': EditorOption.accessibilitySupport.defaultValue, + 'default': EditorOptions.accessibilitySupport.defaultValue, 'description': nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers.") }, 'editor.showUnused': { @@ -1155,7 +1155,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.selectionClipboard': { 'type': 'boolean', - 'default': EditorOption.selectionClipboard.defaultValue, + 'default': EditorOptions.selectionClipboard.defaultValue, 'description': nls.localize('selectionClipboard', "Controls whether the Linux primary clipboard should be supported."), 'included': platform.isLinux }, diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 8b81ce7e46425..98ce2974528ae 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -1162,7 +1162,7 @@ export class InternalEditorOptions { */ public createChangeEvent(newOpts: InternalEditorOptions, changeEvent: ChangedEditorOptions | null): IConfigurationChangedEvent { return { - hasChanged: (id: EditorOptionId) => { + hasChanged: (id: EditorOption) => { if (!changeEvent) { return false; } @@ -1346,7 +1346,7 @@ export class InternalEditorOptions { * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { - hasChanged(id: EditorOptionId): boolean; + hasChanged(id: EditorOption): boolean; readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; readonly editorClassName: boolean; @@ -1961,10 +1961,10 @@ export interface IRawEditorOptionsBag extends IEditorOptions { */ export class RawEditorOptions { private readonly _values: any[] = []; - public _read(id: EditorOptionId): T | undefined { + public _read(id: EditorOption): T | undefined { return this._values[id]; } - public _write(id: EditorOptionId, value: T | undefined): void { + public _write(id: EditorOption, value: T | undefined): void { this._values[id] = value; } } @@ -1974,16 +1974,16 @@ export class RawEditorOptions { */ export class ValidatedEditorOptions { private readonly _values: any[] = []; - public _read(option: EditorOptionId): T { + public _read(option: EditorOption): T { return this._values[option]; } - public _write(option: EditorOptionId, value: T): void { + public _write(option: EditorOption, value: T): void { this._values[option] = value; } } export interface IComputedEditorOptions { - get(id: T): FindComputedEditorOptionValueById; + get(id: T): FindComputedEditorOptionValueById; } /** @@ -1991,13 +1991,13 @@ export interface IComputedEditorOptions { */ export class ComputedEditorOptions implements IComputedEditorOptions { private readonly _values: any[] = []; - public _read(id: EditorOptionId): T { + public _read(id: EditorOption): T { return this._values[id]; } - public get(id: T): FindComputedEditorOptionValueById { + public get(id: T): FindComputedEditorOptionValueById { return this._values[id]; } - public _write(id: EditorOptionId, value: T): void { + public _write(id: EditorOption, value: T): void { this._values[id] = value; } } @@ -2007,17 +2007,17 @@ export class ComputedEditorOptions implements IComputedEditorOptions { */ export class ChangedEditorOptions { private readonly _values: boolean[] = []; - public get(id: EditorOptionId): boolean { + public get(id: EditorOption): boolean { return this._values[id]; } - public _write(id: EditorOptionId, value: boolean): void { + public _write(id: EditorOption, value: boolean): void { this._values[id] = value; } } export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; -export interface IEditorOption { +export interface IEditorOption { readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; @@ -2031,20 +2031,20 @@ export interface IEditorOption { /** * @internal */ -export const editorOptionsRegistry: IEditorOption[] = []; +export const editorOptionsRegistry: IEditorOption[] = []; -function registerEditorOption(option: IEditorOption): IEditorOption { +function registerEditorOption(option: IEditorOption): IEditorOption { editorOptionsRegistry[option.id] = option; return option; } -export abstract class BaseEditorOption implements IEditorOption { +export abstract class BaseEditorOption implements IEditorOption { public readonly id: K; public readonly name: PossibleKeyName; public readonly defaultValue: T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps: EditorOption[] = []) { this.id = id; this.name = name; this.defaultValue = defaultValue; @@ -2074,7 +2074,7 @@ export abstract class BaseEditorOption extends BaseEditorOption { +class EditorBooleanOption extends BaseEditorOption { public validate(input: boolean | undefined): boolean { return _boolean(input, this.defaultValue); } @@ -2083,10 +2083,10 @@ class EditorBooleanOption extends BaseEditorOption extends BaseEditorOption { +class EditorIntOption extends BaseEditorOption { public readonly minimum: number; public readonly maximum: number; - constructor(id: K, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.minimum = minimum; this.maximum = maximum; @@ -2099,9 +2099,9 @@ class EditorIntOption extends BaseEditorOption extends BaseEditorOption { +class EditorFloatOption extends BaseEditorOption { public readonly validationFn: (value: number) => number; - constructor(id: K, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.validationFn = validationFn; } @@ -2113,7 +2113,7 @@ class EditorFloatOption extends BaseEditorOption extends BaseEditorOption { +class EditorStringOption extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } @@ -2122,10 +2122,10 @@ class EditorStringOption extends BaseEditorOption extends BaseEditorOption { +class EditorEnumOption extends BaseEditorOption { public readonly allowedValues: T1[]; public readonly convert: (value: T1) => T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOptionId[] = []) { + constructor(id: K, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.allowedValues = allowedValues; this.convert = convert; @@ -2138,7 +2138,7 @@ class EditorEnumOption extends BaseEditor } } -class EditorPassthroughOption extends BaseEditorOption { +class EditorPassthroughOption extends BaseEditorOption { public validate(input: T | undefined): T { if (typeof input === 'undefined') { return this.defaultValue; @@ -2167,7 +2167,7 @@ export interface InternalEditorRenderLineNumbersOptions { readonly renderFn: ((lineNumber: number) => string) | null; } -class EditorRenderLineNumbersOption extends BaseEditorOption { +class EditorRenderLineNumbersOption extends BaseEditorOption { public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions { let renderType: RenderLineNumbersType = this.defaultValue.renderType; let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; @@ -2215,7 +2215,7 @@ export interface InternalEditorMinimapOptions { readonly maxColumn: number; } -class EditorMinimapOption extends BaseEditorOption { +class EditorMinimapOption extends BaseEditorOption { public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2246,7 +2246,7 @@ class EditorMinimapOption extends BaseEditorOption extends BaseEditorOption { +class EditorAccessibilitySupportOption extends BaseEditorOption { public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' { return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']); } @@ -2266,12 +2266,12 @@ class EditorAccessibilitySupportOption extends BaseEdi //#region ariaLabel -class EditorAriaLabel extends BaseEditorOption { +class EditorAriaLabel extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { - const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + const accessibilitySupport = options.get(EditorOption.accessibilitySupport); if (accessibilitySupport === AccessibilitySupport.Disabled) { return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options."); } @@ -2283,12 +2283,12 @@ class EditorAriaLabel extends BaseEditorOption extends BaseEditorOption { +class EditorTabFocusMode extends BaseEditorOption { public validate(input: undefined): undefined { return undefined; } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): boolean { - const readOnly = options.get(EditorOptionId.readOnly); + const readOnly = options.get(EditorOption.readOnly); return (readOnly ? true : env.tabFocusMode); } } @@ -2311,7 +2311,7 @@ export interface InternalEditorScrollbarOptions { readonly verticalSliderSize: number; } -class EditorScrollbarOption extends BaseEditorOption { +class EditorScrollbarOption extends BaseEditorOption { public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2481,18 +2481,18 @@ export interface EditorLayoutInfo { /** * @internal */ -export class EditorLayoutInfoComputer extends BaseEditorOption { +export class EditorLayoutInfoComputer extends BaseEditorOption { public validate(input: undefined): undefined { return undefined; } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorLayoutInfo { - const glyphMargin = options.get(EditorOptionId.glyphMargin); - const lineNumbersMinChars = options.get(EditorOptionId.lineNumbersMinChars); - const rawLineDecorationsWidth = options.get(EditorOptionId.lineDecorationsWidth); - const folding = options.get(EditorOptionId.folding); - const minimap = options.get(EditorOptionId.minimap); - const scrollbar = options.get(EditorOptionId.scrollbar); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const glyphMargin = options.get(EditorOption.glyphMargin); + const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars); + const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth); + const folding = options.get(EditorOption.folding); + const minimap = options.get(EditorOption.minimap); + const scrollbar = options.get(EditorOption.scrollbar); + const renderLineNumbers = options.get(EditorOption.renderLineNumbers); let lineDecorationsWidth: number; if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) { @@ -2706,7 +2706,7 @@ export interface EditorWrappingInfo { readonly wrappingColumn: number; } -class EditorWrappingInfoComputer extends BaseEditorOption { +class EditorWrappingInfoComputer extends BaseEditorOption { public mix(a: undefined, b: undefined): undefined { return undefined; } @@ -2714,11 +2714,11 @@ class EditorWrappingInfoComputer extends BaseEditorOpt return undefined; } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorWrappingInfo { - const wordWrap = options.get(EditorOptionId.wordWrap); - const wordWrapColumn = options.get(EditorOptionId.wordWrapColumn); - const wordWrapMinified = options.get(EditorOptionId.wordWrapMinified); - const layoutInfo = options.get(EditorOptionId.layoutInfo); - const accessibilitySupport = options.get(EditorOptionId.accessibilitySupport); + const wordWrap = options.get(EditorOption.wordWrap); + const wordWrapColumn = options.get(EditorOption.wordWrapColumn); + const wordWrapMinified = options.get(EditorOption.wordWrapMinified); + const layoutInfo = options.get(EditorOption.layoutInfo); + const accessibilitySupport = options.get(EditorOption.accessibilitySupport); let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null; { @@ -2785,7 +2785,7 @@ class EditorWrappingInfoComputer extends BaseEditorOpt //#endregion -export const enum EditorOptionId { +export const enum EditorOption { accessibilitySupport, ariaLabel, fastScrollSensitivity, @@ -2815,27 +2815,27 @@ export const enum EditorOptionId { wrappingInfo, } -export const EditorOption = { - accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOptionId.accessibilitySupport, 'accessibilitySupport', 'auto')), - ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOptionId.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOptionId.accessibilitySupport])), - fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOptionId.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))), - folding: registerEditorOption(new EditorBooleanOption(EditorOptionId.folding, 'folding', true)), - glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOptionId.glyphMargin, 'glyphMargin', true)), - inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOptionId.inDiffEditor, 'inDiffEditor', false)), - lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOptionId.lineDecorationsWidth, 'lineDecorationsWidth', 10)), - lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOptionId.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), - minimap: registerEditorOption(new EditorMinimapOption(EditorOptionId.minimap, 'minimap', { +export const EditorOptions = { + accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', 'auto')), + ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])), + fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))), + folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), + glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), + inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), + lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), + minimap: registerEditorOption(new EditorMinimapOption(EditorOption.minimap, 'minimap', { enabled: true, side: 'right', showSlider: 'mouseover', renderCharacters: true, maxColumn: 120, })), - mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOptionId.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), - readOnly: registerEditorOption(new EditorBooleanOption(EditorOptionId.readOnly, 'readOnly', false)), - renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOptionId.renderFinalNewline, 'renderFinalNewline', true)), - renderLineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOptionId.renderLineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), - scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOptionId.scrollbar, 'scrollbar', { + mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), + readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)), + renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOption.renderFinalNewline, 'renderFinalNewline', true)), + renderLineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.renderLineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), + scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOption.scrollbar, 'scrollbar', { vertical: ScrollbarVisibility.Auto, horizontal: ScrollbarVisibility.Auto, arrowSize: 11, @@ -2848,23 +2848,23 @@ export const EditorOption = { verticalSliderSize: 14, handleMouseWheel: true, })), - selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectionClipboard, 'selectionClipboard', true)), - selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOptionId.selectOnLineNumbers, 'selectOnLineNumbers', true)), - tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOptionId.tabFocusMode, 'tabFocusMode', undefined, [EditorOptionId.readOnly])), - wordWrap: registerEditorOption(new EditorEnumOption(EditorOptionId.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), - wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), - wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), - wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOptionId.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), - wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOptionId.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), - wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOptionId.wordWrapMinified, 'wordWrapMinified', true)), - wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOptionId.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), + selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), + selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), + tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), + wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), + wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), + wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), + wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), + wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), + wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)), + wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), // Leave these at the end! - layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOptionId.layoutInfo, 'layoutInfo', undefined, [EditorOptionId.glyphMargin, EditorOptionId.lineDecorationsWidth, EditorOptionId.folding, EditorOptionId.minimap, EditorOptionId.scrollbar, EditorOptionId.renderLineNumbers])), - wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOptionId.wrappingInfo, 'wrappingInfo', undefined, [EditorOptionId.wordWrap, EditorOptionId.wordWrapColumn, EditorOptionId.wordWrapMinified, EditorOptionId.layoutInfo, EditorOptionId.accessibilitySupport])), + layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.renderLineNumbers])), + wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), }; -export type EditorOptionType = typeof EditorOption; -export type FindEditorOptionKeyById = { [K in keyof EditorOptionType]: EditorOptionType[K]['id'] extends T ? K : never }[keyof EditorOptionType]; +export type EditorOptionsType = typeof EditorOptions; +export type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; -export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; +export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index fce316527de3c..180829a5ebbf0 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -20,7 +20,7 @@ import { RawContentChangedType } from 'vs/editor/common/model/textModelEvents'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { dispose } from 'vs/base/common/lifecycle'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; function containsLineMappingChanged(events: viewEvents.ViewEvent[]): boolean { for (let i = 0, len = events.length; i < len; i++) { @@ -674,7 +674,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._isDoingComposition = false; } - if (this._configuration.options.get(EditorOptionId.readOnly)) { + if (this._configuration.options.get(EditorOption.readOnly)) { // All the remaining handlers will try to edit the model, // but we cannot edit when read only... this._onDidAttemptReadOnlyEdit.fire(undefined); diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 8c9ecb6a3d764..e4de9b731c151 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -6,7 +6,7 @@ import { CharCode } from 'vs/base/common/charCode'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; -import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption } from 'vs/editor/common/config/editorOptions'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -112,7 +112,7 @@ export class CursorConfiguration { public static shouldRecreate(e: IConfigurationChangedEvent): boolean { return ( - e.hasChanged(EditorOptionId.layoutInfo) + e.hasChanged(EditorOption.layoutInfo) || e.wordSeparators || e.emptySelectionClipboard || e.multiCursorMergeOverlapping @@ -122,7 +122,7 @@ export class CursorConfiguration { || e.autoSurround || e.useTabStops || e.lineHeight - || e.hasChanged(EditorOptionId.readOnly) + || e.hasChanged(EditorOption.readOnly) ); } @@ -135,9 +135,9 @@ export class CursorConfiguration { const c = configuration.editor; const options = configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); - this.readOnly = options.get(EditorOptionId.readOnly); + this.readOnly = options.get(EditorOption.readOnly); this.tabSize = modelOptions.tabSize; this.indentSize = modelOptions.indentSize; this.insertSpaces = modelOptions.insertSpaces; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index b23d2a1b9b246..4027972d75e30 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -439,7 +439,7 @@ export enum RenderLineNumbersType { Custom = 4 } -export enum EditorOptionId { +export enum EditorOption { accessibilitySupport = 0, ariaLabel = 1, fastScrollSensitivity = 2, diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index ebb674197e099..a3da3dfa94cbc 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -6,7 +6,7 @@ import * as errors from 'vs/base/common/errors'; import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { ScrollEvent } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -56,7 +56,7 @@ export class ViewConfigurationChangedEvent { this.viewInfo = source.viewInfo; } - public hasChanged(id: EditorOptionId): boolean { + public hasChanged(id: EditorOption): boolean { return this._source.hasChanged(id); } } diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index 99cd7efff4362..6950cb302a8dd 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -6,7 +6,7 @@ import { Event } from 'vs/base/common/event'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout'; import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; @@ -28,7 +28,7 @@ export class ViewLayout extends Disposable implements IViewLayout { this._configuration = configuration; const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight); @@ -62,9 +62,9 @@ export class ViewLayout extends Disposable implements IViewLayout { if (e.lineHeight) { this._linesLayout.setLineHeight(this._configuration.editor.lineHeight); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { const options = this._configuration.options; - const layoutInfo = options.get(EditorOptionId.layoutInfo); + const layoutInfo = options.get(EditorOption.layoutInfo); this.scrollable.setScrollDimensions({ width: layoutInfo.contentWidth, height: layoutInfo.contentHeight @@ -89,7 +89,7 @@ export class ViewLayout extends Disposable implements IViewLayout { private _getHorizontalScrollbarHeight(scrollDimensions: IScrollDimensions): number { const options = this._configuration.options; - const scrollbar = options.get(EditorOptionId.scrollbar); + const scrollbar = options.get(EditorOption.scrollbar); if (scrollbar.horizontal === ScrollbarVisibility.Hidden) { // horizontal scrollbar not visible return 0; @@ -146,7 +146,7 @@ export class ViewLayout extends Disposable implements IViewLayout { private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number { const options = this._configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); let isViewportWrapping = wrappingInfo.isViewportWrapping; if (!isViewportWrapping) { const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; diff --git a/src/vs/editor/common/viewModel/viewModelDecorations.ts b/src/vs/editor/common/viewModel/viewModelDecorations.ts index bedcfb72b8318..b74baa8dd1cb7 100644 --- a/src/vs/editor/common/viewModel/viewModelDecorations.ts +++ b/src/vs/editor/common/viewModel/viewModelDecorations.ts @@ -10,7 +10,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import { IModelDecoration, ITextModel } from 'vs/editor/common/model'; import { IViewModelLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection'; import { ICoordinatesConverter, InlineDecoration, InlineDecorationType, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IDecorationsViewportData { /** @@ -104,7 +104,7 @@ export class ViewModelDecorations implements IDisposable { } private _getDecorationsViewportData(viewportRange: Range): IDecorationsViewportData { - const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.options.get(EditorOptionId.readOnly)); + const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.options.get(EditorOption.readOnly)); const startLineNumber = viewportRange.startLineNumber; const endLineNumber = viewportRange.endLineNumber; diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 8ccdd124225eb..055cf6ae0d1ea 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -6,7 +6,7 @@ import { Color } from 'vs/base/common/color'; import { IDisposable } from 'vs/base/common/lifecycle'; import * as strings from 'vs/base/common/strings'; -import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -61,11 +61,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } else { const conf = this.configuration.editor; const options = this.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = options.get(EditorOption.wrappingInfo); + const wordWrapBreakAfterCharacters = options.get(EditorOption.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = options.get(EditorOption.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = options.get(EditorOption.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = options.get(EditorOption.wrappingIndent); let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, @@ -154,8 +154,8 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel const conf = this.configuration.editor; const options = this.configuration.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); - const wrappingIndent = options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = options.get(EditorOption.wrappingInfo); + const wrappingIndent = options.get(EditorOption.wrappingIndent); if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) { eventsCollector.emit(new viewEvents.ViewFlushedEvent()); @@ -170,7 +170,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } } - if (e.hasChanged(EditorOptionId.readOnly)) { + if (e.hasChanged(EditorOption.readOnly)) { // Must read again all decorations due to readOnly filtering this.decorations.reset(); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent()); @@ -561,7 +561,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } public getAllOverviewRulerDecorations(theme: ITheme): IOverviewRulerDecorations { - return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.options.get(EditorOptionId.readOnly), theme); + return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.options.get(EditorOption.readOnly), theme); } public invalidateOverviewRulerColorCache(): void { diff --git a/src/vs/editor/contrib/codeAction/codeActionModel.ts b/src/vs/editor/contrib/codeAction/codeActionModel.ts index 3c8b4dacdd17c..2af98e865aa25 100644 --- a/src/vs/editor/contrib/codeAction/codeActionModel.ts +++ b/src/vs/editor/contrib/codeAction/codeActionModel.ts @@ -17,7 +17,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers'; import { IEditorProgressService } from 'vs/platform/progress/common/progress'; import { getCodeActions, CodeActionSet } from './codeAction'; import { CodeActionTrigger } from './codeActionTrigger'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const SUPPORTED_CODE_ACTIONS = new RawContextKey('supportedCodeAction', ''); @@ -193,7 +193,7 @@ export class CodeActionModel extends Disposable { const model = this._editor.getModel(); if (model && CodeActionProviderRegistry.has(model) - && !this._editor.getOption(EditorOptionId.readOnly) + && !this._editor.getOption(EditorOption.readOnly) ) { const supportedActions: string[] = []; for (const provider of CodeActionProviderRegistry.all(model)) { diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index 253052dace32e..631d9041902ab 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -26,7 +26,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const SEARCH_STRING_MAX_LENGTH = 524288; @@ -699,7 +699,7 @@ export class StartFindReplaceAction extends EditorAction { } public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void { - if (!editor.hasModel() || editor.getOption(EditorOptionId.readOnly)) { + if (!editor.hasModel() || editor.getOption(EditorOption.readOnly)) { return; } diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index c62ff1190bfee..232502b5ba894 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -23,7 +23,7 @@ import { toDisposable } from 'vs/base/common/lifecycle'; import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { CONTEXT_FIND_INPUT_FOCUSED, CONTEXT_REPLACE_INPUT_FOCUSED, FIND_IDS, MATCHES_LIMIT } from 'vs/editor/contrib/find/findModel'; import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState'; @@ -176,18 +176,18 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._findInput.inputBox.layout(); this._register(this._codeEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.hasChanged(EditorOptionId.readOnly)) { - if (this._codeEditor.getOption(EditorOptionId.readOnly)) { + if (e.hasChanged(EditorOption.readOnly)) { + if (this._codeEditor.getOption(EditorOption.readOnly)) { // Hide replace part if editor becomes read only this._state.change({ isReplaceRevealed: false }, false); } this._updateButtons(); } - if (e.hasChanged(EditorOptionId.layoutInfo)) { + if (e.hasChanged(EditorOption.layoutInfo)) { this._tryUpdateWidgetWidth(); } - if (e.hasChanged(EditorOptionId.accessibilitySupport)) { + if (e.hasChanged(EditorOption.accessibilitySupport)) { this.updateAccessibilitySupport(); } @@ -315,7 +315,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } if (e.isReplaceRevealed) { if (this._state.isReplaceRevealed) { - if (!this._codeEditor.getOption(EditorOptionId.readOnly) && !this._isReplaceVisible) { + if (!this._codeEditor.getOption(EditorOption.readOnly) && !this._isReplaceVisible) { this._isReplaceVisible = true; this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode); this._updateButtons(); @@ -456,7 +456,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._toggleReplaceBtn.toggleClass('expand', this._isReplaceVisible); this._toggleReplaceBtn.setExpanded(this._isReplaceVisible); - let canReplace = !this._codeEditor.getOption(EditorOptionId.readOnly); + let canReplace = !this._codeEditor.getOption(EditorOption.readOnly); this._toggleReplaceBtn.setEnabled(this._isVisible && canReplace); } @@ -1210,7 +1210,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private updateAccessibilitySupport(): void { - const value = this._codeEditor.getOption(EditorOptionId.accessibilitySupport); + const value = this._codeEditor.getOption(EditorOption.accessibilitySupport); this._findInput.setFocusInputOnOptionClick(value !== AccessibilitySupport.Enabled); } } diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 4c4c0f2adc776..648461cd08249 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -18,7 +18,7 @@ import { FoldingModel, setCollapseStateAtLevel, CollapseMemento, setCollapseStat import { FoldingDecorationProvider } from './foldingDecorations'; import { FoldingRegions, FoldingRegion } from './foldingRanges'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel'; import { IRange } from 'vs/editor/common/core/range'; @@ -88,7 +88,7 @@ export class FoldingController extends Disposable implements IEditorContribution super(); this.editor = editor; const options = this.editor.getOptions(); - this._isEnabled = options.get(EditorOptionId.folding); + this._isEnabled = options.get(EditorOption.folding); this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover'; this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation'; @@ -110,10 +110,10 @@ export class FoldingController extends Disposable implements IEditorContribution this._register(this.editor.onDidChangeModel(() => this.onModelChanged())); this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.contribInfo || e.hasChanged(EditorOptionId.folding)) { + if (e.contribInfo || e.hasChanged(EditorOption.folding)) { let oldIsEnabled = this._isEnabled; const options = this.editor.getOptions(); - this._isEnabled = options.get(EditorOptionId.folding); + this._isEnabled = options.get(EditorOption.folding); this.foldingEnabled.set(this._isEnabled); if (oldIsEnabled !== this._isEnabled) { this.onModelChanged(); diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index 36cd010daff5e..e03c5464e516f 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -11,7 +11,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution, IScrollEvent } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; @@ -265,7 +265,7 @@ class ShowHoverAction extends EditorAction { } const position = editor.getPosition(); const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column); - const focus = editor.getOption(EditorOptionId.accessibilitySupport) === AccessibilitySupport.Enabled; + const focus = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled; controller.showContentHover(range, HoverStartMode.Immediate, focus); } } diff --git a/src/vs/editor/contrib/suggest/suggestModel.ts b/src/vs/editor/contrib/suggest/suggestModel.ts index c82ea98b95b5a..174f87f6a0c47 100644 --- a/src/vs/editor/contrib/suggest/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/suggestModel.ts @@ -20,7 +20,7 @@ import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2 import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface ICancelEvent { readonly retrigger: boolean; @@ -184,7 +184,7 @@ export class SuggestModel implements IDisposable { dispose(this._triggerCharacterListener); - if (this._editor.getOption(EditorOptionId.readOnly) + if (this._editor.getOption(EditorOption.readOnly) || !this._editor.hasModel() || !this._editor.getConfiguration().contribInfo.suggestOnTriggerCharacters) { diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index a0afb73c16444..948a2b2ad8c30 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -31,7 +31,7 @@ import { contrastBorder, editorWidgetBackground, widgetShadow, editorWidgetForeg import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey('accessibilityHelpWidgetVisible', false); @@ -240,14 +240,14 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { let text = getSelectionLabel(selections, charactersSelected); - if (options.get(EditorOptionId.inDiffEditor)) { - if (options.get(EditorOptionId.readOnly)) { + if (options.get(EditorOption.inDiffEditor)) { + if (options.get(EditorOption.readOnly)) { text += AccessibilityHelpNLS.readonlyDiffEditor; } else { text += AccessibilityHelpNLS.editableDiffEditor; } } else { - if (options.get(EditorOptionId.readOnly)) { + if (options.get(EditorOption.readOnly)) { text += AccessibilityHelpNLS.readonlyEditor; } else { text += AccessibilityHelpNLS.editableEditor; @@ -259,7 +259,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { ? AccessibilityHelpNLS.changeConfigToOnMac : AccessibilityHelpNLS.changeConfigToOnWinLinux ); - switch (options.get(EditorOptionId.accessibilitySupport)) { + switch (options.get(EditorOption.accessibilitySupport)) { case AccessibilitySupport.Unknown: text += '\n\n - ' + turnOnMessage; break; @@ -273,7 +273,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } - if (options.get(EditorOptionId.tabFocusMode)) { + if (options.get(EditorOption.tabFocusMode)) { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, AccessibilityHelpNLS.tabFocusModeOnMsg, AccessibilityHelpNLS.tabFocusModeOnMsgNoKb); } else { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, AccessibilityHelpNLS.tabFocusModeOffMsg, AccessibilityHelpNLS.tabFocusModeOffMsgNoKb); diff --git a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts index 82c5fb1a312d9..82ccd6a63f74a 100644 --- a/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts +++ b/src/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.ts @@ -10,7 +10,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class IPadShowKeyboard extends Disposable implements IEditorContribution { @@ -30,7 +30,7 @@ export class IPadShowKeyboard extends Disposable implements IEditorContribution } private update(): void { - const shouldHaveWidget = (!this.editor.getOption(EditorOptionId.readOnly)); + const shouldHaveWidget = (!this.editor.getOption(EditorOption.readOnly)); if (!this.widget && shouldHaveWidget) { diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 70d17b7f81bd8..a910ffb2b7649 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -370,7 +370,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { RenderMinimap: standaloneEnums.RenderMinimap, ScrollType: standaloneEnums.ScrollType, RenderLineNumbersType: standaloneEnums.RenderLineNumbersType, - EditorOptionId: standaloneEnums.EditorOptionId, + EditorOption: standaloneEnums.EditorOption, // classes BaseEditorOption: editorOptions.BaseEditorOption, @@ -382,7 +382,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { // vars EditorType: editorCommon.EditorType, - EditorOption: editorOptions.EditorOption, + EditorOptions: editorOptions.EditorOptions, }; } diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index 9a0c8edad129a..a105d7b2c293b 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorHoverOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; @@ -68,7 +68,7 @@ suite('Common Editor Config', () => { function assertWrapping(config: TestConfiguration, isViewportWrapping: boolean, wrappingColumn: number): void { const options = config.options; - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); assert.equal(wrappingInfo.isViewportWrapping, isViewportWrapping); assert.equal(wrappingInfo.wrappingColumn, wrappingColumn); } diff --git a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts index faa9ac1409758..2ecf905ed3578 100644 --- a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts +++ b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts @@ -19,7 +19,7 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer' import { ILineMapping, ISimpleModel, SplitLine, SplitLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection'; import { ViewLineData } from 'vs/editor/common/viewModel/viewModel'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; suite('Editor ViewModel - SplitLinesCollection', () => { @@ -91,11 +91,11 @@ suite('Editor ViewModel - SplitLinesCollection', () => { function withSplitLinesCollection(text: string, callback: (model: TextModel, linesCollection: SplitLinesCollection) => void): void { const config = new TestConfiguration({}); - const wrappingInfo = config.options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = config.options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = config.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = config.options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = config.options.get(EditorOption.wrappingInfo); + const wordWrapBreakAfterCharacters = config.options.get(EditorOption.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = config.options.get(EditorOption.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOption.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = config.options.get(EditorOption.wrappingIndent); const hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, @@ -744,11 +744,11 @@ suite('SplitLinesCollection', () => { wordWrapColumn: wordWrapColumn, wrappingIndent: 'indent' }); - const wrappingInfo = configuration.options.get(EditorOptionId.wrappingInfo); - const wordWrapBreakAfterCharacters = configuration.options.get(EditorOptionId.wordWrapBreakAfterCharacters); - const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOptionId.wordWrapBreakBeforeCharacters); - const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOptionId.wordWrapBreakObtrusiveCharacters); - const wrappingIndent = configuration.options.get(EditorOptionId.wrappingIndent); + const wrappingInfo = configuration.options.get(EditorOption.wrappingInfo); + const wordWrapBreakAfterCharacters = configuration.options.get(EditorOption.wordWrapBreakAfterCharacters); + const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOption.wordWrapBreakBeforeCharacters); + const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOption.wordWrapBreakObtrusiveCharacters); + const wrappingIndent = configuration.options.get(EditorOption.wrappingIndent); const factory = new CharacterHardWrappingLineMapperFactory( wordWrapBreakBeforeCharacters, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index ab2061dd683ea..3e52cdbc9a3c3 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3365,7 +3365,7 @@ declare namespace monaco.editor { * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { - hasChanged(id: EditorOptionId): boolean; + hasChanged(id: EditorOption): boolean; readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; readonly editorClassName: boolean; @@ -3405,14 +3405,14 @@ declare namespace monaco.editor { } export interface IComputedEditorOptions { - get(id: T): FindComputedEditorOptionValueById; + get(id: T): FindComputedEditorOptionValueById; } export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never; }[keyof IEditorOptions]; - export interface IEditorOption { + export interface IEditorOption { readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; @@ -3423,11 +3423,11 @@ declare namespace monaco.editor { equals(a: T3, b: T3): boolean; } - export abstract class BaseEditorOption implements IEditorOption { + export abstract class BaseEditorOption implements IEditorOption { readonly id: K; readonly name: PossibleKeyName; readonly defaultValue: T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps?: EditorOptionId[]); + constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps?: EditorOption[]); read(options: IRawEditorOptionsBag): T1 | undefined; mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; abstract validate(input: T1 | undefined): T2; @@ -3591,7 +3591,7 @@ declare namespace monaco.editor { readonly wrappingColumn: number; } - export enum EditorOptionId { + export enum EditorOption { accessibilitySupport = 0, ariaLabel = 1, fastScrollSensitivity = 2, @@ -3620,44 +3620,44 @@ declare namespace monaco.editor { wrappingInfo = 25 } - export const EditorOption: { - accessibilitySupport: IEditorOption; - ariaLabel: IEditorOption; - fastScrollSensitivity: IEditorOption; - folding: IEditorOption; - glyphMargin: IEditorOption; - inDiffEditor: IEditorOption; - lineDecorationsWidth: IEditorOption; - lineNumbersMinChars: IEditorOption; - minimap: IEditorOption; - mouseWheelScrollSensitivity: IEditorOption; - readOnly: IEditorOption; - renderFinalNewline: IEditorOption; - renderLineNumbers: IEditorOption; - scrollbar: IEditorOption; - selectionClipboard: IEditorOption; - selectOnLineNumbers: IEditorOption; - tabFocusMode: IEditorOption; - wordWrap: IEditorOption; - wordWrapBreakAfterCharacters: IEditorOption; - wordWrapBreakBeforeCharacters: IEditorOption; - wordWrapBreakObtrusiveCharacters: IEditorOption; - wordWrapColumn: IEditorOption; - wordWrapMinified: IEditorOption; - wrappingIndent: IEditorOption; - layoutInfo: IEditorOption; - wrappingInfo: IEditorOption; + export const EditorOptions: { + accessibilitySupport: IEditorOption; + ariaLabel: IEditorOption; + fastScrollSensitivity: IEditorOption; + folding: IEditorOption; + glyphMargin: IEditorOption; + inDiffEditor: IEditorOption; + lineDecorationsWidth: IEditorOption; + lineNumbersMinChars: IEditorOption; + minimap: IEditorOption; + mouseWheelScrollSensitivity: IEditorOption; + readOnly: IEditorOption; + renderFinalNewline: IEditorOption; + renderLineNumbers: IEditorOption; + scrollbar: IEditorOption; + selectionClipboard: IEditorOption; + selectOnLineNumbers: IEditorOption; + tabFocusMode: IEditorOption; + wordWrap: IEditorOption; + wordWrapBreakAfterCharacters: IEditorOption; + wordWrapBreakBeforeCharacters: IEditorOption; + wordWrapBreakObtrusiveCharacters: IEditorOption; + wordWrapColumn: IEditorOption; + wordWrapMinified: IEditorOption; + wrappingIndent: IEditorOption; + layoutInfo: IEditorOption; + wrappingInfo: IEditorOption; }; - export type EditorOptionType = typeof EditorOption; + export type EditorOptionsType = typeof EditorOptions; - export type FindEditorOptionKeyById = { - [K in keyof EditorOptionType]: EditorOptionType[K]['id'] extends T ? K : never; - }[keyof EditorOptionType]; + export type FindEditorOptionsKeyById = { + [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never; + }[keyof EditorOptionsType]; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; - export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; + export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; /** * A view zone is a full horizontal rectangle that 'pushes' text down. @@ -4109,7 +4109,7 @@ declare namespace monaco.editor { */ getConfiguration(): InternalEditorOptions; getOptions(): IComputedEditorOptions; - getOption(id: T): FindComputedEditorOptionValueById; + getOption(id: T): FindComputedEditorOptionValueById; /** * Get value of the current model attached to this editor. * @see `ITextModel.getValue` diff --git a/src/vs/workbench/api/browser/mainThreadEditor.ts b/src/vs/workbench/api/browser/mainThreadEditor.ts index 7d1d2022fed4d..2d210bb3febce 100644 --- a/src/vs/workbench/api/browser/mainThreadEditor.ts +++ b/src/vs/workbench/api/browser/mainThreadEditor.ts @@ -6,7 +6,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { RenderLineNumbersType, TextEditorCursorStyle, cursorStyleToString, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -60,7 +60,7 @@ export class MainThreadTextEditorProperties { if (codeEditor) { const codeEditorOpts = codeEditor.getConfiguration(); const options = codeEditor.getOptions(); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOption.renderLineNumbers); cursorStyle = codeEditorOpts.viewInfo.cursorStyle; lineNumbers = renderLineNumbers.renderType; } else if (previousProperties) { diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 94e8258b4c130..b167f3ea8df68 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -35,7 +35,7 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ITextFileService, SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; -import { IConfigurationChangedEvent, IEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { deepClone } from 'vs/base/common/objects'; @@ -584,7 +584,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { // Hook Listener for Configuration changes this.activeEditorListeners.add(activeCodeEditor.onDidChangeConfiguration((event: IConfigurationChangedEvent) => { - if (event.hasChanged(EditorOptionId.accessibilitySupport)) { + if (event.hasChanged(EditorOption.accessibilitySupport)) { this.onScreenReaderModeChange(activeCodeEditor); } })); @@ -708,7 +708,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { } } - screenReaderMode = (editorWidget.getOption(EditorOptionId.accessibilitySupport) === AccessibilitySupport.Enabled); + screenReaderMode = (editorWidget.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled); } if (screenReaderMode === false && this.screenReaderNotification) { @@ -758,7 +758,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { private onEOLChange(editorWidget: ICodeEditor | undefined): void { const info: StateDelta = { EOL: undefined }; - if (editorWidget && !editorWidget.getOption(EditorOptionId.readOnly)) { + if (editorWidget && !editorWidget.getOption(EditorOption.readOnly)) { const codeEditorModel = editorWidget.getModel(); if (codeEditorModel) { info.EOL = codeEditorModel.getEOL(); @@ -819,7 +819,7 @@ function isWritableCodeEditor(codeEditor: ICodeEditor | undefined): boolean { if (!codeEditor) { return false; } - return !codeEditor.getOption(EditorOptionId.readOnly); + return !codeEditor.getOption(EditorOption.readOnly); } function isWritableBaseEditor(e: IBaseEditor): boolean { diff --git a/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts b/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts index 4f84e1dc2b488..4e2253b873198 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts @@ -17,7 +17,7 @@ import * as strings from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser'; import { EditorAction, EditorCommand, registerEditorAction, registerEditorCommand, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IEditorOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode'; @@ -191,7 +191,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { text += '\n\n' + nls.localize('status', "Status:"); const configuredValue = this._configurationService.getValue('editor').accessibilitySupport; - const actualValue = options.get(EditorOptionId.accessibilitySupport); + const actualValue = options.get(EditorOption.accessibilitySupport); const emergencyTurnOnMessage = ( platform.isMacintosh @@ -229,7 +229,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { const NLS_TAB_FOCUS_MODE_OFF = nls.localize('tabFocusModeOffMsg', "Pressing Tab in the current editor will insert the tab character. Toggle this behavior by pressing {0}."); const NLS_TAB_FOCUS_MODE_OFF_NO_KB = nls.localize('tabFocusModeOffMsgNoKb', "Pressing Tab in the current editor will insert the tab character. The command {0} is currently not triggerable by a keybinding."); - if (options.get(EditorOptionId.tabFocusMode)) { + if (options.get(EditorOption.tabFocusMode)) { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, NLS_TAB_FOCUS_MODE_ON, NLS_TAB_FOCUS_MODE_ON_NO_KB); } else { text += '\n\n - ' + this._descriptionForCommand(ToggleTabFocusModeAction.ID, NLS_TAB_FOCUS_MODE_OFF, NLS_TAB_FOCUS_MODE_OFF_NO_KB); diff --git a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts index da10b808d17b4..32133496349d9 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts @@ -9,7 +9,7 @@ import * as process from 'vs/base/common/process'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -24,11 +24,11 @@ export class SelectionClipboard extends Disposable implements IEditorContributio super(); if (platform.isLinux) { - let isEnabled = editor.getOption(EditorOptionId.selectionClipboard); + let isEnabled = editor.getOption(EditorOption.selectionClipboard); this._register(editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.hasChanged(EditorOptionId.selectionClipboard)) { - isEnabled = editor.getOption(EditorOptionId.selectionClipboard); + if (e.hasChanged(EditorOption.selectionClipboard)) { + isEnabled = editor.getOption(EditorOption.selectionClipboard); } })); diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts index 8d22a06dcba95..9032288864d54 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleWordWrap.ts @@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; -import { EditorOptionId, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; @@ -68,7 +68,7 @@ function readWordWrapState(model: ITextModel, configurationService: ITextResourc const _transientState = readTransientState(model, codeEditorService); return { configuredWordWrap: _configuredWordWrap, - configuredWordWrapMinified: (typeof _configuredWordWrapMinified === 'boolean' ? _configuredWordWrapMinified : EditorOption.wordWrapMinified.defaultValue), + configuredWordWrapMinified: (typeof _configuredWordWrapMinified === 'boolean' ? _configuredWordWrapMinified : EditorOptions.wordWrapMinified.defaultValue), transientState: _transientState }; } @@ -85,7 +85,7 @@ function toggleWordWrap(editor: ICodeEditor, state: IWordWrapState): IWordWrapSt let transientState: IWordWrapTransientState; - const actualWrappingInfo = editor.getOption(EditorOptionId.wrappingInfo); + const actualWrappingInfo = editor.getOption(EditorOption.wrappingInfo); if (actualWrappingInfo.isWordWrapMinified) { // => wrapping due to minified file transientState = { @@ -138,7 +138,7 @@ class ToggleWordWrapAction extends EditorAction { if (!editor.hasModel()) { return; } - if (editor.getOption(EditorOptionId.inDiffEditor)) { + if (editor.getOption(EditorOption.inDiffEditor)) { // Cannot change wrapping settings inside the diff editor const notificationService = accessor.get(INotificationService); notificationService.info(nls.localize('wordWrap.notInDiffEditor', "Cannot toggle word wrap in a diff editor.")); @@ -176,21 +176,21 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution super(); const options = this.editor.getOptions(); - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); const isWordWrapMinified = this.contextKeyService.createKey(isWordWrapMinifiedKey, wrappingInfo.isWordWrapMinified); const isDominatedByLongLines = this.contextKeyService.createKey(isDominatedByLongLinesKey, wrappingInfo.isDominatedByLongLines); - const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOptionId.inDiffEditor)); + const inDiffEditor = this.contextKeyService.createKey(inDiffEditorKey, options.get(EditorOption.inDiffEditor)); let currentlyApplyingEditorConfig = false; this._register(editor.onDidChangeConfiguration((e) => { - if (!e.hasChanged(EditorOptionId.wrappingInfo) || !e.hasChanged(EditorOptionId.inDiffEditor)) { + if (!e.hasChanged(EditorOption.wrappingInfo) || !e.hasChanged(EditorOption.inDiffEditor)) { return; } const options = this.editor.getOptions(); - const wrappingInfo = options.get(EditorOptionId.wrappingInfo); + const wrappingInfo = options.get(EditorOption.wrappingInfo); isWordWrapMinified.set(wrappingInfo.isWordWrapMinified); isDominatedByLongLines.set(wrappingInfo.isDominatedByLongLines); - inDiffEditor.set(options.get(EditorOptionId.inDiffEditor)); + inDiffEditor.set(options.get(EditorOption.inDiffEditor)); if (!currentlyApplyingEditorConfig) { // I am not the cause of the word wrap getting changed ensureWordWrapSettings(); @@ -216,7 +216,7 @@ class ToggleWordWrapController extends Disposable implements IEditorContribution return; } - if (this.editor.getOption(EditorOptionId.inDiffEditor)) { + if (this.editor.getOption(EditorOption.inDiffEditor)) { return; } diff --git a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts index 52068f454fcaa..c6f45b8d91223 100644 --- a/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts +++ b/src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts @@ -37,7 +37,7 @@ import { COMMENTEDITOR_DECORATION_KEY, ReviewZoneWidget } from 'vs/workbench/con import { ctxCommentEditorFocused, SimpleCommentEditor } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const ID = 'editor.contrib.review'; @@ -603,7 +603,7 @@ export class ReviewController implements IEditorContribution { } const options = this.editor.getOptions(); - if (options.get(EditorOptionId.folding)) { + if (options.get(EditorOption.folding)) { lineDecorationsWidth -= 16; } lineDecorationsWidth += 9; diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts index d0d7906907c90..0758b523ae348 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts @@ -41,7 +41,7 @@ import { ContextSubMenu } from 'vs/base/browser/contextmenu'; import { memoize } from 'vs/base/common/decorators'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { getHover } from 'vs/editor/contrib/hover/getHover'; -import { IEditorHoverOptions, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { CancellationToken } from 'vs/base/common/cancellation'; import { BreakpointWidget } from 'vs/workbench/contrib/debug/browser/breakpointWidget'; import { DebugHoverWidget } from 'vs/workbench/contrib/debug/browser/debugHover'; @@ -540,7 +540,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { if (this.configurationWidget) { this.configurationWidget.dispose(); } - if (model && LAUNCH_JSON_REGEX.test(model.uri.toString()) && !this.editor.getOption(EditorOptionId.readOnly)) { + if (model && LAUNCH_JSON_REGEX.test(model.uri.toString()) && !this.editor.getOption(EditorOption.readOnly)) { this.configurationWidget = this.instantiationService.createInstance(FloatingClickWidget, this.editor, nls.localize('addConfiguration', "Add Configuration..."), null); this.configurationWidget.render(); this.toDispose.push(this.configurationWidget.onClick(() => this.addLaunchConfiguration())); diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts index f3e4b3ca25559..9b45e34dee4ce 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts @@ -30,7 +30,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { KeybindingParser } from 'vs/base/common/keybindingParser'; import Severity from 'vs/base/common/severity'; import { SeverityIcon } from 'vs/platform/severityIcon/common/severityIcon'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding"); const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout."); @@ -83,7 +83,7 @@ export class DefineKeybindingController extends Disposable implements editorComm this._createKeybindingDecorationRenderer(); // The button to define keybindings is shown only for the user keybindings.json - if (!this._editor.getOption(EditorOptionId.readOnly)) { + if (!this._editor.getOption(EditorOption.readOnly)) { this._createKeybindingWidgetRenderer(); } else { this._disposeKeybindingWidgetRenderer(); @@ -378,7 +378,7 @@ class DefineKeybindingCommand extends EditorCommand { } runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void { - if (!isInterestingEditorModel(editor) || editor.getOption(EditorOptionId.readOnly)) { + if (!isInterestingEditorModel(editor) || editor.getOption(EditorOption.readOnly)) { return; } const controller = DefineKeybindingController.get(editor); diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 6f4eb6a5551fe..7f66cba3d6278 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -33,7 +33,7 @@ import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/p import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class SettingsHeaderWidget extends Widget implements IViewZone { @@ -88,7 +88,7 @@ export class SettingsHeaderWidget extends Widget implements IViewZone { const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; - if (!options.get(EditorOptionId.folding)) { + if (!options.get(EditorOption.folding)) { this.titleContainer.style.paddingLeft = '6px'; } } diff --git a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts index 418aafc01303c..5a0e888e93186 100644 --- a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts @@ -16,7 +16,7 @@ import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IRange } from 'vs/editor/common/core/range'; import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; -import { IEditorOptions, RenderLineNumbersType, EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RenderLineNumbersType, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; @@ -51,7 +51,7 @@ export class GotoLineAction extends QuickOpenAction { if (isCodeEditor(activeTextEditorWidget)) { const options = activeTextEditorWidget.getOptions(); - const renderLineNumbers = options.get(EditorOptionId.renderLineNumbers); + const renderLineNumbers = options.get(EditorOption.renderLineNumbers); if (renderLineNumbers.renderType === RenderLineNumbersType.Relative) { activeTextEditorWidget.updateOptions({ lineNumbers: 'on' diff --git a/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts b/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts index 4571d5e6ef85c..5708eef553f1c 100644 --- a/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts +++ b/src/vs/workbench/services/bulkEdit/browser/bulkEditService.ts @@ -23,7 +23,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ILabelService } from 'vs/platform/label/common/label'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { EditorOptionId } from 'vs/editor/common/config/editorOptions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; abstract class Recording { @@ -415,7 +415,7 @@ export class BulkEditService implements IBulkEditService { } } - if (codeEditor && codeEditor.getOption(EditorOptionId.readOnly)) { + if (codeEditor && codeEditor.getOption(EditorOption.readOnly)) { // If the code editor is readonly still allow bulk edits to be applied #68549 codeEditor = undefined; } From 844c90a6ca8ee8354349d503fd960262dd83d5a6 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Sep 2019 01:19:42 +0200 Subject: [PATCH 008/204] Lift editor options key name to a generic --- src/vs/editor/common/config/editorOptions.ts | 84 ++++++++++---------- src/vs/monaco.d.ts | 84 ++++++++++---------- 2 files changed, 85 insertions(+), 83 deletions(-) diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 98ce2974528ae..653d28714e3db 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -2014,16 +2014,16 @@ export class ChangedEditorOptions { this._values[id] = value; } } +type PossibleKeyName0 = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; +type PossibleKeyName = NonNullable>; -export type PossibleKeyName = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; - -export interface IEditorOption { - readonly id: K; - readonly name: PossibleKeyName; +export interface IEditorOption, T3 = T2> { + readonly id: K1; + readonly name: K2; readonly defaultValue: T2; - read(options: IRawEditorOptionsBag): T1 | undefined; - mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; - validate(input: T1 | undefined): T2; + read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined; + mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined; + validate(input: IEditorOptions[K2] | undefined): T2; compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; equals(a: T3, b: T3): boolean; } @@ -2033,18 +2033,18 @@ export interface IEditorOption { */ export const editorOptionsRegistry: IEditorOption[] = []; -function registerEditorOption(option: IEditorOption): IEditorOption { +function registerEditorOption(option: IEditorOption): IEditorOption { editorOptionsRegistry[option.id] = option; return option; } -export abstract class BaseEditorOption implements IEditorOption { +export abstract class BaseEditorOption implements IEditorOption { - public readonly id: K; - public readonly name: PossibleKeyName; + public readonly id: K1; + public readonly name: K2; public readonly defaultValue: T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps: EditorOption[] = []) { + constructor(id: K1, name: K2, defaultValue: T2, deps: EditorOption[] = []) { this.id = id; this.name = name; this.defaultValue = defaultValue; @@ -2052,10 +2052,10 @@ export abstract class BaseEditorOptionthis.name]; } - public mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined { + public mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined { switch (typeof b) { case 'bigint': return b; case 'boolean': return b; @@ -2067,14 +2067,14 @@ export abstract class BaseEditorOption extends BaseEditorOption { +class EditorBooleanOption> extends BaseEditorOption { public validate(input: boolean | undefined): boolean { return _boolean(input, this.defaultValue); } @@ -2083,10 +2083,10 @@ class EditorBooleanOption extends BaseEditorOption extends BaseEditorOption { +class EditorIntOption> extends BaseEditorOption { public readonly minimum: number; public readonly maximum: number; - constructor(id: K, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number, deps: EditorOption[] = []) { + constructor(id: K1, name: K2, defaultValue: number, minimum: number, maximum: number, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.minimum = minimum; this.maximum = maximum; @@ -2099,9 +2099,9 @@ class EditorIntOption extends BaseEditorOption extends BaseEditorOption { +class EditorFloatOption> extends BaseEditorOption { public readonly validationFn: (value: number) => number; - constructor(id: K, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number, deps: EditorOption[] = []) { + constructor(id: K1, name: K2, defaultValue: number, validationFn: (value: number) => number, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.validationFn = validationFn; } @@ -2113,7 +2113,7 @@ class EditorFloatOption extends BaseEditorOption extends BaseEditorOption { +class EditorStringOption> extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } @@ -2122,30 +2122,30 @@ class EditorStringOption extends BaseEditorOption extends BaseEditorOption { +class EditorEnumOption, T1 extends string, T2 = T1> extends BaseEditorOption { public readonly allowedValues: T1[]; public readonly convert: (value: T1) => T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOption[] = []) { + constructor(id: K1, name: K2, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOption[] = []) { super(id, name, defaultValue, deps); this.allowedValues = allowedValues; this.convert = convert; } - public validate(input: T1 | undefined): T1 { - return _stringSet(input, this.defaultValue, this.allowedValues); + public validate(input: IEditorOptions[K2] | undefined): T1 { + return _stringSet(input, this.defaultValue, this.allowedValues); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T1): T2 { return this.convert(value); } } -class EditorPassthroughOption extends BaseEditorOption { - public validate(input: T | undefined): T { +class EditorPassthroughOption extends BaseEditorOption { + public validate(input: IEditorOptions[K2] | undefined): IEditorOptions[K2] { if (typeof input === 'undefined') { return this.defaultValue; } return input; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T): T { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: IEditorOptions[K2]): IEditorOptions[K2] { return value; } } @@ -2167,7 +2167,7 @@ export interface InternalEditorRenderLineNumbersOptions { readonly renderFn: ((lineNumber: number) => string) | null; } -class EditorRenderLineNumbersOption extends BaseEditorOption { +class EditorRenderLineNumbersOption> extends BaseEditorOption { public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions { let renderType: RenderLineNumbersType = this.defaultValue.renderType; let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; @@ -2215,7 +2215,7 @@ export interface InternalEditorMinimapOptions { readonly maxColumn: number; } -class EditorMinimapOption extends BaseEditorOption { +class EditorMinimapOption> extends BaseEditorOption { public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2246,7 +2246,7 @@ class EditorMinimapOption extends BaseEditorOption extends BaseEditorOption { +class EditorAccessibilitySupportOption> extends BaseEditorOption { public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' { return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']); } @@ -2266,7 +2266,7 @@ class EditorAccessibilitySupportOption extends BaseEdito //#region ariaLabel -class EditorAriaLabel extends BaseEditorOption { +class EditorAriaLabel> extends BaseEditorOption { public validate(input: string | undefined): string { return _string(input, this.defaultValue); } @@ -2283,7 +2283,7 @@ class EditorAriaLabel extends BaseEditorOption extends BaseEditorOption { +class EditorTabFocusMode> extends BaseEditorOption { public validate(input: undefined): undefined { return undefined; } @@ -2311,7 +2311,7 @@ export interface InternalEditorScrollbarOptions { readonly verticalSliderSize: number; } -class EditorScrollbarOption extends BaseEditorOption { +class EditorScrollbarOption> extends BaseEditorOption { public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2481,7 +2481,7 @@ export interface EditorLayoutInfo { /** * @internal */ -export class EditorLayoutInfoComputer extends BaseEditorOption { +export class EditorLayoutInfoComputer> extends BaseEditorOption { public validate(input: undefined): undefined { return undefined; } @@ -2706,7 +2706,7 @@ export interface EditorWrappingInfo { readonly wrappingColumn: number; } -class EditorWrappingInfoComputer extends BaseEditorOption { +class EditorWrappingInfoComputer> extends BaseEditorOption { public mix(a: undefined, b: undefined): undefined { return undefined; } @@ -2822,7 +2822,7 @@ export const EditorOptions = { folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), - lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), minimap: registerEditorOption(new EditorMinimapOption(EditorOption.minimap, 'minimap', { enabled: true, @@ -2851,13 +2851,13 @@ export const EditorOptions = { selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), - wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), + wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), - wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), + wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'tabFocusMode', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)), - wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), + wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), // Leave these at the end! layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.renderLineNumbers])), @@ -2867,4 +2867,4 @@ export const EditorOptions = { export type EditorOptionsType = typeof EditorOptions; export type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; -export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; +export type FindComputedEditorOptionValueById = NonNullable]>>; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 3e52cdbc9a3c3..304261d93421f 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3408,29 +3408,31 @@ declare namespace monaco.editor { get(id: T): FindComputedEditorOptionValueById; } - export type PossibleKeyName = { + type PossibleKeyName0 = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never; }[keyof IEditorOptions]; - export interface IEditorOption { - readonly id: K; - readonly name: PossibleKeyName; + type PossibleKeyName = NonNullable>; + + export interface IEditorOption, T3 = T2> { + readonly id: K1; + readonly name: K2; readonly defaultValue: T2; - read(options: IRawEditorOptionsBag): T1 | undefined; - mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; - validate(input: T1 | undefined): T2; + read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined; + mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined; + validate(input: IEditorOptions[K2] | undefined): T2; compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; equals(a: T3, b: T3): boolean; } - export abstract class BaseEditorOption implements IEditorOption { - readonly id: K; - readonly name: PossibleKeyName; + export abstract class BaseEditorOption implements IEditorOption { + readonly id: K1; + readonly name: K2; readonly defaultValue: T2; - constructor(id: K, name: PossibleKeyName, defaultValue: T2, deps?: EditorOption[]); - read(options: IRawEditorOptionsBag): T1 | undefined; - mix(a: T1 | undefined, b: T1 | undefined): T1 | undefined; - abstract validate(input: T1 | undefined): T2; + constructor(id: K1, name: K2, defaultValue: T2, deps?: EditorOption[]); + read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined; + mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined; + abstract validate(input: IEditorOptions[K2] | undefined): T2; abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; equals(a: T3, b: T3): boolean; } @@ -3621,32 +3623,32 @@ declare namespace monaco.editor { } export const EditorOptions: { - accessibilitySupport: IEditorOption; - ariaLabel: IEditorOption; - fastScrollSensitivity: IEditorOption; - folding: IEditorOption; - glyphMargin: IEditorOption; - inDiffEditor: IEditorOption; - lineDecorationsWidth: IEditorOption; - lineNumbersMinChars: IEditorOption; - minimap: IEditorOption; - mouseWheelScrollSensitivity: IEditorOption; - readOnly: IEditorOption; - renderFinalNewline: IEditorOption; - renderLineNumbers: IEditorOption; - scrollbar: IEditorOption; - selectionClipboard: IEditorOption; - selectOnLineNumbers: IEditorOption; - tabFocusMode: IEditorOption; - wordWrap: IEditorOption; - wordWrapBreakAfterCharacters: IEditorOption; - wordWrapBreakBeforeCharacters: IEditorOption; - wordWrapBreakObtrusiveCharacters: IEditorOption; - wordWrapColumn: IEditorOption; - wordWrapMinified: IEditorOption; - wrappingIndent: IEditorOption; - layoutInfo: IEditorOption; - wrappingInfo: IEditorOption; + accessibilitySupport: any; + ariaLabel: any; + fastScrollSensitivity: any; + folding: any; + glyphMargin: any; + inDiffEditor: any; + lineDecorationsWidth: IEditorOption; + lineNumbersMinChars: any; + minimap: any; + mouseWheelScrollSensitivity: any; + readOnly: any; + renderFinalNewline: any; + renderLineNumbers: any; + scrollbar: any; + selectionClipboard: any; + selectOnLineNumbers: any; + tabFocusMode: any; + wordWrap: any; + wordWrapBreakAfterCharacters: any; + wordWrapBreakBeforeCharacters: any; + wordWrapBreakObtrusiveCharacters: any; + wordWrapColumn: any; + wordWrapMinified: any; + wrappingIndent: any; + layoutInfo: any; + wrappingInfo: any; }; export type EditorOptionsType = typeof EditorOptions; @@ -3657,7 +3659,7 @@ declare namespace monaco.editor { export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; - export type FindComputedEditorOptionValueById = ComputedEditorOptionValue]>; + export type FindComputedEditorOptionValueById = NonNullable]>>; /** * A view zone is a full horizontal rectangle that 'pushes' text down. From e07eaeb90da32764a11f31d0e117394e9a71a19a Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Mon, 2 Sep 2019 19:12:26 -0500 Subject: [PATCH 009/204] Reset SearchView tree focus when there is a single result. Fixes #76475 --- src/vs/workbench/contrib/search/browser/searchView.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 4399e11c6fadc..e82b176acd01e 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -738,6 +738,9 @@ export class SearchView extends ViewletPanel { // Reveal the newly selected element if (next) { + if (next === selected) { + this.tree.setFocus([]); + } this.tree.setFocus([next], getSelectionKeyboardEvent(undefined, false)); this.tree.reveal(next); } @@ -777,6 +780,9 @@ export class SearchView extends ViewletPanel { // Reveal the newly selected element if (prev) { + if (prev === selected) { + this.tree.setFocus([]); + } this.tree.setFocus([prev], getSelectionKeyboardEvent(undefined, false)); this.tree.reveal(prev); } From 3445fcb5eb1b6ec37f424239474afc34dd51afe8 Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Mon, 2 Sep 2019 20:31:03 -0500 Subject: [PATCH 010/204] Fix #80238 --- .../contrib/search/browser/searchView.ts | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 4399e11c6fadc..435ad281ae37d 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -711,7 +711,7 @@ export class SearchView extends ViewletPanel { const [selected] = this.tree.getSelection(); // Expand the initial selected node, if needed - if (selected instanceof FileMatch) { + if (selected && !(selected instanceof Match)) { if (this.tree.isCollapsed(selected)) { this.tree.expand(selected); } @@ -721,18 +721,16 @@ export class SearchView extends ViewletPanel { let next = navigator.next(); if (!next) { - // Reached the end - get a new navigator from the root. - navigator = this.tree.navigate(); next = navigator.first(); } - // Expand and go past FileMatch nodes + // Expand until first child is a Match while (!(next instanceof Match)) { if (this.tree.isCollapsed(next)) { this.tree.expand(next); } - // Select the FileMatch's first child + // Select the first child next = navigator.next(); } @@ -749,30 +747,17 @@ export class SearchView extends ViewletPanel { let prev = navigator.previous(); - // Expand and go past FileMatch nodes - if (!(prev instanceof Match)) { - prev = navigator.previous(); - if (!prev) { - // Wrap around - prev = navigator.last(); - - // This is complicated because .last will set the navigator to the last FileMatch, - // so expand it and FF to its last child - this.tree.expand(prev); - let tmp: RenderableMatch | null; - while (tmp = navigator.next()) { - prev = tmp; - } - } + // Select previous until find a Match or a collapsed item + while (!prev || (!(prev instanceof Match) && !this.tree.isCollapsed(prev))) { + prev = prev ? navigator.previous() : navigator.last(); + } - if (!(prev instanceof Match)) { - // There is a second non-Match result, which must be a collapsed FileMatch. - // Expand it then select its last child. - const nextItem = navigator.next(); - this.tree.expand(prev); - navigator = this.tree.navigate(nextItem); // recreate navigator because modifying the tree can invalidate it - prev = navigator.previous(); - } + // Expand until last child is a Match + while (!(prev instanceof Match)) { + const nextItem = navigator.next(); + this.tree.expand(prev); + navigator = this.tree.navigate(nextItem); // recreate navigator because modifying the tree can invalidate it + prev = nextItem ? navigator.previous() : navigator.last(); // select last child } // Reveal the newly selected element From 709d1ed9c2ecf7667bca0e52c0f0ccffe6a6fb35 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Tue, 3 Sep 2019 14:12:32 +0200 Subject: [PATCH 011/204] fix markers contribution --- .../contrib/markers/browser/markersWidget.ts | 1050 +++++++++++++++++ 1 file changed, 1050 insertions(+) create mode 100644 src/vs/workbench/contrib/markers/browser/markersWidget.ts diff --git a/src/vs/workbench/contrib/markers/browser/markersWidget.ts b/src/vs/workbench/contrib/markers/browser/markersWidget.ts new file mode 100644 index 0000000000000..8508bffd29ed2 --- /dev/null +++ b/src/vs/workbench/contrib/markers/browser/markersWidget.ts @@ -0,0 +1,1050 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import 'vs/css!./media/markers'; + +import { URI } from 'vs/base/common/uri'; +import * as dom from 'vs/base/browser/dom'; +import { IAction, IActionViewItem, Action } from 'vs/base/common/actions'; +import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; +import Constants from 'vs/workbench/contrib/markers/browser/constants'; +import { Marker, ResourceMarkers, RelatedInformation, MarkersModel, MarkerChangesEvent } from 'vs/workbench/contrib/markers/browser/markersModel'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { MarkersFilterActionViewItem, MarkersFilterAction, IMarkersFilterActionChangeEvent } from 'vs/workbench/contrib/markers/browser/markersPanelActions'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import Messages from 'vs/workbench/contrib/markers/browser/messages'; +import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; +import { IMarkersWorkbenchService } from 'vs/workbench/contrib/markers/browser/markers'; +import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { localize } from 'vs/nls'; +import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { Iterator } from 'vs/base/common/iterator'; +import { ITreeElement, ITreeNode, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree'; +import { Relay, Event, Emitter } from 'vs/base/common/event'; +import { WorkbenchObjectTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService'; +import { FilterOptions } from 'vs/workbench/contrib/markers/browser/markersFilterOptions'; +import { IExpression } from 'vs/base/common/glob'; +import { deepClone } from 'vs/base/common/objects'; +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { FilterData, Filter, VirtualDelegate, ResourceMarkersRenderer, MarkerRenderer, RelatedInformationRenderer, TreeElement, MarkersTreeAccessibilityProvider, MarkersViewModel, ResourceDragAndDrop } from 'vs/workbench/contrib/markers/browser/markersTreeViewer'; +import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; +import { Separator, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; +import { IMenuService, MenuId } from 'vs/platform/actions/common/actions'; +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; +import { KeyCode } from 'vs/base/common/keyCodes'; +import { domEvent } from 'vs/base/browser/event'; +import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle'; +import { ResourceLabels } from 'vs/workbench/browser/labels'; +import { IMarker } from 'vs/platform/markers/common/markers'; +import { withUndefinedAsNull } from 'vs/base/common/types'; +import { MementoObject } from 'vs/workbench/common/memento'; +import { Widget } from 'vs/base/browser/ui/widget'; +import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; + +function createModelIterator(model: MarkersModel): Iterator> { + const resourcesIt = Iterator.fromArray(model.resourceMarkers); + + return Iterator.map(resourcesIt, m => ({ element: m, children: createResourceMarkersIterator(m) })); +} + +function createResourceMarkersIterator(resourceMarkers: ResourceMarkers): Iterator> { + const markersIt = Iterator.fromArray(resourceMarkers.markers); + + return Iterator.map(markersIt, m => { + const relatedInformationIt = Iterator.from(m.relatedInformation); + const children = Iterator.map(relatedInformationIt, r => ({ element: r })); + + return { element: m, children }; + }); + +} + +class MarkersWidgetActions extends Disposable { + + readonly actions: IAction[]; + readonly collapseAllAction: IAction; + readonly filterAction: MarkersFilterAction; + + constructor( + tree: WorkbenchObjectTree, + panelState: MementoObject, + @IInstantiationService instantiationService: IInstantiationService + ) { + super(); + this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { + tree.collapseAll(); + tree.setSelection([]); + tree.setFocus([]); + tree.getHTMLElement().focus(); + tree.focusFirst(); + }); + + this.filterAction = instantiationService.createInstance(MarkersFilterAction, { filterText: panelState['filter'] || '', filterHistory: panelState['filterHistory'] || [], useFilesExclude: !!panelState['useFilesExclude'] }); + this.actions = [this.filterAction, this.collapseAllAction]; + } + +} + +class MarkersTreeWidget extends Disposable { + + private readonly treeContainer: HTMLElement; + private readonly tree: WorkbenchObjectTree; + + constructor( + parent: HTMLElement, + markersViewModel: MarkersViewModel, + @IInstantiationService private readonly instantiationService: IInstantiationService, + @IEditorService private readonly editorService: IEditorService, + @IConfigurationService private readonly configurationService: IConfigurationService, + @ITelemetryService private readonly telemetryService: ITelemetryService, + @IThemeService themeService: IThemeService, + @IMarkersWorkbenchService private readonly markersWorkbenchService: IMarkersWorkbenchService, + @IStorageService storageService: IStorageService, + @IContextKeyService contextKeyService: IContextKeyService, + @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, + @IContextMenuService private readonly contextMenuService: IContextMenuService, + @IMenuService private readonly menuService: IMenuService, + @IKeybindingService private readonly keybindingService: IKeybindingService, + ) { + super(); + + this.treeContainer = dom.append(parent, dom.$('.tree-container.show-file-icons')); + + const onDidChangeRenderNodeCount = new Relay>(); + + const virtualDelegate = new VirtualDelegate(markersViewModel); + const renderers = [ + this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), + this.instantiationService.createInstance(MarkerRenderer, markersViewModel), + this.instantiationService.createInstance(RelatedInformationRenderer) + ]; + this.filter = new Filter(new FilterOptions()); + const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); + + const identityProvider = { + getId(element: TreeElement) { + return element.id; + } + }; + + this.tree = this._register(this.instantiationService.createInstance(WorkbenchObjectTree, + 'MarkersPanel', + this.treeContainer, + virtualDelegate, + renderers, + { + filter: this.filter, + accessibilityProvider, + identityProvider, + dnd: new ResourceDragAndDrop(this.instantiationService), + expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0 + } + )); + + onDidChangeRenderNodeCount.input = this.tree.onDidChangeRenderNodeCount; + + const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService); + const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(this.tree.contextKeyService); + this._register(this.tree.onDidChangeFocus(focus => { + markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker)); + relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation)); + })); + const focusTracker = this._register(dom.trackFocus(this.tree.getHTMLElement())); + this._register(focusTracker.onDidBlur(() => { + markerFocusContextKey.set(false); + relatedInformationFocusContextKey.set(false); + })); + + const markersNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true })); + this._register(Event.debounce(markersNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => { + this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned); + })); + this._register(this.tree.onDidChangeCollapseState(({ node }) => { + const { element } = node; + if (element instanceof RelatedInformation && !node.collapsed) { + /* __GDPR__ + "problems.expandRelatedInformation" : { + "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, + "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } + } + */ + this.telemetryService.publicLog('problems.expandRelatedInformation', this.getTelemetryData(element.marker)); + } + })); + + this._register(this.tree.onContextMenu(this.onContextMenu, this)); + + this._register(this.configurationService.onDidChangeConfiguration(e => { + if (this.filterAction.useFilesExclude && e.affectsConfiguration('files.exclude')) { + this.updateFilter(); + } + })); + + // move focus to input, whenever a key is pressed in the panel container + this._register(domEvent(parent, 'keydown')(e => { + if (this.filterInputActionViewItem && this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) { + this.filterInputActionViewItem.focus(); + } + })); + + this._register(Event.any(this.tree.onDidChangeSelection, this.tree.onDidChangeFocus)(() => { + const elements = [...this.tree.getSelection(), ...this.tree.getFocus()]; + for (const element of elements) { + if (element instanceof Marker) { + const viewModel = markersViewModel.getViewModel(element); + if (viewModel) { + viewModel.showLightBulb(); + } + } + } + })); + + this._register(this.tree.onDidChangeSelection(() => { + let selection = this.tree.getSelection(); + if (selection && selection.length > 0) { + this.lastSelectedRelativeTop = this.tree.getRelativeTop(selection[0]) || 0; + } + })); + } + + public layout(dimension: dom.Dimension): void { + this.treeContainer.style.height = `${dimension.height}px`; + this.tree.layout(dimension.height, dimension.width); + } + + public isFoucsed(): boolean { + return this.tree.getHTMLElement() === document.activeElement; + } + + public focus(): void { + this.tree.getHTMLElement().focus(); + } + + refreshTree(markerOrChange?: Marker | MarkerChangesEvent): void { + if (markerOrChange) { + if (markerOrChange instanceof Marker) { + this.tree.rerender(markerOrChange); + } else { + if (markerOrChange.added.length || markerOrChange.removed.length) { + // Reset complete tree + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + } else { + // Update resource + for (const updated of markerOrChange.updated) { + this.tree.setChildren(updated, createResourceMarkersIterator(updated)); + } + } + } + } else { + // Reset complete tree + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + } + } + + toggleVisibility(show: boolean): void { + dom.toggleClass(this.treeContainer, 'hidden', !show); + } + + refilter(): void { + this.tree.refilter(); + } + + private isEmpty(): boolean { + const { total, filtered } = this.getFilterStats(); + return total === 0 || filtered === 0; + } + + private render(): void { + this.cachedFilterStats = undefined; + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + dom.toggleClass(this.treeContainer, 'hidden', this.isEmpty()); + this.renderMessage(); + } + + private revealMarkersForCurrentActiveEditor(focus: boolean = false): void { + let currentActiveResource = this.getResourceForCurrentActiveResource(); + if (currentActiveResource) { + if (!this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) { + this.tree.reveal(this.tree.getSelection()[0], this.lastSelectedRelativeTop); + if (focus) { + this.tree.setFocus(this.tree.getSelection()); + } + } else { + this.tree.expand(currentActiveResource); + this.tree.reveal(currentActiveResource, 0); + + if (focus) { + this.tree.setFocus([currentActiveResource]); + this.tree.setSelection([currentActiveResource]); + } + } + } else if (focus) { + this.tree.setSelection([]); + this.tree.focusFirst(); + } + } + + private hasSelectedMarkerFor(resource: ResourceMarkers): boolean { + let selectedElement = this.tree.getSelection(); + if (selectedElement && selectedElement.length > 0) { + if (selectedElement[0] instanceof Marker) { + if (resource.resource.toString() === (selectedElement[0]).marker.resource.toString()) { + return true; + } + } + } + return false; + } + + private highlightCurrentSelectedMarkerRange() { + const selections = this.tree.getSelection(); + + if (selections.length !== 1) { + return; + } + + const selection = selections[0]; + + if (!(selection instanceof Marker)) { + return; + } + + this.rangeHighlightDecorations.highlightRange(selection); + } + + private onContextMenu(e: ITreeContextMenuEvent): void { + const element = e.element; + if (!element) { + return; + } + + e.browserEvent.preventDefault(); + e.browserEvent.stopPropagation(); + + this.contextMenuService.showContextMenu({ + getAnchor: () => e.anchor!, + getActions: () => this.getMenuActions(element), + getActionViewItem: (action) => { + const keybinding = this.keybindingService.lookupKeybinding(action.id); + if (keybinding) { + return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() }); + } + return undefined; + }, + onHide: (wasCancelled?: boolean) => { + if (wasCancelled) { + this.tree.domFocus(); + } + } + }); + } + + private getMenuActions(element: TreeElement): IAction[] { + const result: IAction[] = []; + + if (element instanceof Marker) { + const viewModel = this.markersViewModel.getViewModel(element); + if (viewModel) { + const quickFixActions = viewModel.quickFixAction.quickFixes; + if (quickFixActions.length) { + result.push(...quickFixActions); + result.push(new Separator()); + } + } + } + + const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree.contextKeyService); + const groups = menu.getActions(); + menu.dispose(); + + for (let group of groups) { + const [, actions] = group; + result.push(...actions); + result.push(new Separator()); + } + + result.pop(); // remove last separator + return result; + } + + public getFocusElement() { + return this.tree.getFocus()[0]; + } + + public dispose(): void { + super.dispose(); + this.tree.dispose(); + this.markersViewModel.dispose(); + this.disposables = dispose(this.disposables); + } +} + + +export class MarkersWidget extends Widget { + + private lastSelectedRelativeTop: number = 0; + private currentActiveResource: URI | null = null; + + private readonly tree: WorkbenchObjectTree; + private readonly treeLabels: ResourceLabels; + private readonly rangeHighlightDecorations: RangeHighlightDecorations; + + private treeContainer: HTMLElement; + private messageBoxContainer: HTMLElement; + private ariaLabelElement: HTMLElement; + private readonly panelState: MementoObject; + private panelFoucusContextKey: IContextKey; + + private filter: Filter; + private filterInputActionViewItem: MarkersFilterActionViewItem | null = null; + + private _onDidFilter = this._register(new Emitter()); + readonly onDidFilter: Event = this._onDidFilter.event; + private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined; + + private currentResourceGotAddedToMarkersData: boolean = false; + readonly markersViewModel: MarkersViewModel; + private disposables: IDisposable[] = []; + + constructor( + parent: HTMLElement, + @IInstantiationService private readonly instantiationService: IInstantiationService, + @IEditorService private readonly editorService: IEditorService, + @IConfigurationService private readonly configurationService: IConfigurationService, + @ITelemetryService private readonly telemetryService: ITelemetryService, + @IThemeService themeService: IThemeService, + @IMarkersWorkbenchService private readonly markersWorkbenchService: IMarkersWorkbenchService, + @IStorageService storageService: IStorageService, + @IContextKeyService contextKeyService: IContextKeyService, + @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, + @IContextMenuService private readonly contextMenuService: IContextMenuService, + @IMenuService private readonly menuService: IMenuService, + @IKeybindingService private readonly keybindingService: IKeybindingService, + ) { + super(); + + this.panelFoucusContextKey = Constants.MarkerPanelFocusContextKey.bindTo(contextKeyService); + this.panelState = this.getMemento(StorageScope.WORKSPACE); + this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']); + this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables); + this.setCurrentActiveEditor(); + + this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations)); + this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); + + this.createArialLabelElement(parent); + this.createMessageBox(parent); + this.tree = this.createTree(parent); + this.actions = this.createActions(); + this.createListeners(); + + this.updateFilter(); + + this._register(this.onDidFocus(() => this.panelFoucusContextKey.set(true))); + this._register(this.onDidBlur(() => this.panelFoucusContextKey.set(false))); + + this._register(this.onDidChangeVisibility(visible => { + if (visible) { + this.refreshPanel(); + } else { + this.rangeHighlightDecorations.removeHighlightRange(); + } + })); + + this.render(); + } + + public layout(dimension: dom.Dimension): void { + this.treeContainer.style.height = `${dimension.height}px`; + this.tree.layout(dimension.height, dimension.width); + if (this.filterInputActionViewItem) { + this.filterInputActionViewItem.toggleLayout(dimension.width < 1200); + } + } + + public focus(): void { + if (this.tree.getHTMLElement() === document.activeElement) { + return; + } + + if (this.isEmpty()) { + this.messageBoxContainer.focus(); + } else { + this.tree.getHTMLElement().focus(); + } + } + + public focusFilter(): void { + if (this.filterInputActionViewItem) { + this.filterInputActionViewItem.focus(); + } + } + + public getActions(): IAction[] { + return this.actions; + } + + public showQuickFixes(marker: Marker): void { + const viewModel = this.markersViewModel.getViewModel(marker); + if (viewModel) { + viewModel.quickFixAction.run(); + } + } + + public openFileAtElement(element: any, preserveFocus: boolean, sideByside: boolean, pinned: boolean): boolean { + const { resource, selection, event, data } = element instanceof Marker ? { resource: element.resource, selection: element.range, event: 'problems.selectDiagnostic', data: this.getTelemetryData(element.marker) } : + element instanceof RelatedInformation ? { resource: element.raw.resource, selection: element.raw, event: 'problems.selectRelatedInformation', data: this.getTelemetryData(element.marker) } : { resource: null, selection: null, event: null, data: null }; + if (resource && selection && event) { + /* __GDPR__ + "problems.selectDiagnostic" : { + "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, + "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } + } + */ + /* __GDPR__ + "problems.selectRelatedInformation" : { + "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, + "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } + } + */ + this.telemetryService.publicLog(event, data); + this.editorService.openEditor({ + resource, + options: { + selection, + preserveFocus, + pinned, + revealIfVisible: true + }, + }, sideByside ? SIDE_GROUP : ACTIVE_GROUP).then(editor => { + if (editor && preserveFocus) { + this.rangeHighlightDecorations.highlightRange({ resource, range: selection }, editor.getControl()); + } else { + this.rangeHighlightDecorations.removeHighlightRange(); + } + }); + return true; + } else { + this.rangeHighlightDecorations.removeHighlightRange(); + } + return false; + } + + private refreshPanel(markerOrChange?: Marker | MarkerChangesEvent): void { + if (this.isVisible()) { + this.cachedFilterStats = undefined; + + if (markerOrChange) { + if (markerOrChange instanceof Marker) { + this.tree.rerender(markerOrChange); + } else { + if (markerOrChange.added.length || markerOrChange.removed.length) { + // Reset complete tree + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + } else { + // Update resource + for (const updated of markerOrChange.updated) { + this.tree.setChildren(updated, createResourceMarkersIterator(updated)); + } + } + } + } else { + // Reset complete tree + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + } + + const { total, filtered } = this.getFilterStats(); + dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); + this.renderMessage(); + this._onDidFilter.fire(); + } + } + + private onDidChangeViewState(marker?: Marker): void { + this.refreshPanel(marker); + } + + private updateFilter() { + this.cachedFilterStats = undefined; + this.filter.options = new FilterOptions(this.filterAction.filterText, this.getFilesExcludeExpressions()); + this.tree.refilter(); + this._onDidFilter.fire(); + + const { total, filtered } = this.getFilterStats(); + dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); + this.renderMessage(); + } + + private getFilesExcludeExpressions(): { root: URI, expression: IExpression }[] | IExpression { + if (!this.filterAction.useFilesExclude) { + return []; + } + + const workspaceFolders = this.workspaceContextService.getWorkspace().folders; + return workspaceFolders.length + ? workspaceFolders.map(workspaceFolder => ({ root: workspaceFolder.uri, expression: this.getFilesExclude(workspaceFolder.uri) })) + : this.getFilesExclude(); + } + + private getFilesExclude(resource?: URI): IExpression { + return deepClone(this.configurationService.getValue('files.exclude', { resource })) || {}; + } + + private createMessageBox(parent: HTMLElement): void { + this.messageBoxContainer = dom.append(parent, dom.$('.message-box-container')); + this.messageBoxContainer.setAttribute('aria-labelledby', 'markers-panel-arialabel'); + } + + private createArialLabelElement(parent: HTMLElement): void { + this.ariaLabelElement = dom.append(parent, dom.$('')); + this.ariaLabelElement.setAttribute('id', 'markers-panel-arialabel'); + this.ariaLabelElement.setAttribute('aria-live', 'polite'); + } + + private createTree(parent: HTMLElement): WorkbenchObjectTree { + this.treeContainer = dom.append(parent, dom.$('.tree-container.show-file-icons')); + + const onDidChangeRenderNodeCount = new Relay>(); + + const virtualDelegate = new VirtualDelegate(this.markersViewModel); + const renderers = [ + this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), + this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel), + this.instantiationService.createInstance(RelatedInformationRenderer) + ]; + this.filter = new Filter(new FilterOptions()); + const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); + + const identityProvider = { + getId(element: TreeElement) { + return element.id; + } + }; + + const tree = this.instantiationService.createInstance(WorkbenchObjectTree, + 'MarkersPanel', + this.treeContainer, + virtualDelegate, + renderers, + { + filter: this.filter, + accessibilityProvider, + identityProvider, + dnd: new ResourceDragAndDrop(this.instantiationService), + expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0 + } + ); + + onDidChangeRenderNodeCount.input = tree.onDidChangeRenderNodeCount; + + const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(tree.contextKeyService); + const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(tree.contextKeyService); + this._register(tree.onDidChangeFocus(focus => { + markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker)); + relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation)); + })); + const focusTracker = this._register(dom.trackFocus(tree.getHTMLElement())); + this._register(focusTracker.onDidBlur(() => { + markerFocusContextKey.set(false); + relatedInformationFocusContextKey.set(false); + })); + + const markersNavigator = this._register(new TreeResourceNavigator2(tree, { openOnFocus: true })); + this._register(Event.debounce(markersNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => { + this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned); + })); + this._register(tree.onDidChangeCollapseState(({ node }) => { + const { element } = node; + if (element instanceof RelatedInformation && !node.collapsed) { + /* __GDPR__ + "problems.expandRelatedInformation" : { + "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, + "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } + } + */ + this.telemetryService.publicLog('problems.expandRelatedInformation', this.getTelemetryData(element.marker)); + } + })); + + this._register(tree.onContextMenu(this.onContextMenu, this)); + + this._register(this.configurationService.onDidChangeConfiguration(e => { + if (this.filterAction.useFilesExclude && e.affectsConfiguration('files.exclude')) { + this.updateFilter(); + } + })); + + // move focus to input, whenever a key is pressed in the panel container + this._register(domEvent(parent, 'keydown')(e => { + if (this.filterInputActionViewItem && this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) { + this.filterInputActionViewItem.focus(); + } + })); + + this._register(Event.any(tree.onDidChangeSelection, tree.onDidChangeFocus)(() => { + const elements = [...tree.getSelection(), ...tree.getFocus()]; + for (const element of elements) { + if (element instanceof Marker) { + const viewModel = this.markersViewModel.getViewModel(element); + if (viewModel) { + viewModel.showLightBulb(); + } + } + } + })); + + return tree; + } + + private createActions(): IAction[] { + this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { + this.tree.collapseAll(); + this.tree.setSelection([]); + this.tree.setFocus([]); + this.tree.getHTMLElement().focus(); + this.tree.focusFirst(); + }); + + this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] }); + return [this.filterAction, this.collapseAllAction]; + } + + private createListeners(): void { + this._register(Event.any(this.markersWorkbenchService.markersModel.onDidChange, this.editorService.onDidActiveEditorChange)(changes => { + if (changes) { + this.onDidChangeModel(changes); + } else { + this.onActiveEditorChanged(); + } + })); + this._register(this.tree.onDidChangeSelection(() => this.onSelected())); + this._register(this.filterAction.onDidChange((event: IMarkersFilterActionChangeEvent) => { + if (event.filterText || event.useFilesExclude) { + this.updateFilter(); + } + })); + this.actions.forEach(a => this._register(a)); + } + + private onDidChangeModel(change: MarkerChangesEvent) { + const resourceMarkers = [...change.added, ...change.removed, ...change.updated]; + const resources: URI[] = []; + for (const { resource } of resourceMarkers) { + this.markersViewModel.remove(resource); + const resourceMarkers = this.markersWorkbenchService.markersModel.getResourceMarkers(resource); + if (resourceMarkers) { + for (const marker of resourceMarkers.markers) { + this.markersViewModel.add(marker); + } + } + resources.push(resource); + } + this.currentResourceGotAddedToMarkersData = this.currentResourceGotAddedToMarkersData || this.isCurrentResourceGotAddedToMarkersData(resources); + this.refreshPanel(change); + this.updateRangeHighlights(); + if (this.currentResourceGotAddedToMarkersData) { + this.autoReveal(); + this.currentResourceGotAddedToMarkersData = false; + } + } + + private isCurrentResourceGotAddedToMarkersData(changedResources: URI[]) { + const currentlyActiveResource = this.currentActiveResource; + if (!currentlyActiveResource) { + return false; + } + const resourceForCurrentActiveResource = this.getResourceForCurrentActiveResource(); + if (resourceForCurrentActiveResource) { + return false; + } + return changedResources.some(r => r.toString() === currentlyActiveResource.toString()); + } + + private onActiveEditorChanged(): void { + this.setCurrentActiveEditor(); + this.autoReveal(); + } + + private setCurrentActiveEditor(): void { + const activeEditor = this.editorService.activeEditor; + this.currentActiveResource = activeEditor ? withUndefinedAsNull(activeEditor.getResource()) : null; + } + + private onSelected(): void { + let selection = this.tree.getSelection(); + if (selection && selection.length > 0) { + this.lastSelectedRelativeTop = this.tree.getRelativeTop(selection[0]) || 0; + } + } + + private isEmpty(): boolean { + const { total, filtered } = this.getFilterStats(); + return total === 0 || filtered === 0; + } + + private render(): void { + this.cachedFilterStats = undefined; + this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); + dom.toggleClass(this.treeContainer, 'hidden', this.isEmpty()); + this.renderMessage(); + } + + private renderMessage(): void { + dom.clearNode(this.messageBoxContainer); + const { total, filtered } = this.getFilterStats(); + + if (filtered === 0) { + this.messageBoxContainer.style.display = 'block'; + this.messageBoxContainer.setAttribute('tabIndex', '0'); + if (total > 0) { + if (this.filter.options.filter) { + this.renderFilteredByFilterMessage(this.messageBoxContainer); + } else { + this.renderFilteredByFilesExcludeMessage(this.messageBoxContainer); + } + } else { + this.renderNoProblemsMessage(this.messageBoxContainer); + } + } else { + this.messageBoxContainer.style.display = 'none'; + if (filtered === total) { + this.ariaLabelElement.setAttribute('aria-label', localize('No problems filtered', "Showing {0} problems", total)); + } else { + this.ariaLabelElement.setAttribute('aria-label', localize('problems filtered', "Showing {0} of {1} problems", filtered, total)); + } + this.messageBoxContainer.removeAttribute('tabIndex'); + } + } + + private renderFilteredByFilesExcludeMessage(container: HTMLElement) { + const span1 = dom.append(container, dom.$('span')); + span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILE_EXCLUSIONS_FILTER; + const link = dom.append(container, dom.$('a.messageAction')); + link.textContent = localize('disableFilesExclude', "Disable Files Exclude Filter."); + link.setAttribute('tabIndex', '0'); + dom.addStandardDisposableListener(link, dom.EventType.CLICK, () => this.filterAction.useFilesExclude = false); + dom.addStandardDisposableListener(link, dom.EventType.KEY_DOWN, (e: IKeyboardEvent) => { + if (e.equals(KeyCode.Enter) || e.equals(KeyCode.Space)) { + this.filterAction.useFilesExclude = false; + e.stopPropagation(); + } + }); + this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_FILE_EXCLUSIONS_FILTER); + } + + private renderFilteredByFilterMessage(container: HTMLElement) { + const span1 = dom.append(container, dom.$('span')); + span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS; + const link = dom.append(container, dom.$('a.messageAction')); + link.textContent = localize('clearFilter', "Clear Filter"); + link.setAttribute('tabIndex', '0'); + const span2 = dom.append(container, dom.$('span')); + span2.textContent = '.'; + dom.addStandardDisposableListener(link, dom.EventType.CLICK, () => this.filterAction.filterText = ''); + dom.addStandardDisposableListener(link, dom.EventType.KEY_DOWN, (e: IKeyboardEvent) => { + if (e.equals(KeyCode.Enter) || e.equals(KeyCode.Space)) { + this.filterAction.filterText = ''; + e.stopPropagation(); + } + }); + this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS); + } + + private renderNoProblemsMessage(container: HTMLElement) { + const span = dom.append(container, dom.$('span')); + span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT; + this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT); + } + + private autoReveal(focus: boolean = false): void { + let autoReveal = this.configurationService.getValue('problems.autoReveal'); + if (typeof autoReveal === 'boolean' && autoReveal) { + this.revealMarkersForCurrentActiveEditor(focus); + } + } + + private revealMarkersForCurrentActiveEditor(focus: boolean = false): void { + let currentActiveResource = this.getResourceForCurrentActiveResource(); + if (currentActiveResource) { + if (!this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) { + this.tree.reveal(this.tree.getSelection()[0], this.lastSelectedRelativeTop); + if (focus) { + this.tree.setFocus(this.tree.getSelection()); + } + } else { + this.tree.expand(currentActiveResource); + this.tree.reveal(currentActiveResource, 0); + + if (focus) { + this.tree.setFocus([currentActiveResource]); + this.tree.setSelection([currentActiveResource]); + } + } + } else if (focus) { + this.tree.setSelection([]); + this.tree.focusFirst(); + } + } + + private getResourceForCurrentActiveResource(): ResourceMarkers | null { + return this.currentActiveResource ? this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource) : null; + } + + private hasSelectedMarkerFor(resource: ResourceMarkers): boolean { + let selectedElement = this.tree.getSelection(); + if (selectedElement && selectedElement.length > 0) { + if (selectedElement[0] instanceof Marker) { + if (resource.resource.toString() === (selectedElement[0]).marker.resource.toString()) { + return true; + } + } + } + return false; + } + + private updateRangeHighlights() { + this.rangeHighlightDecorations.removeHighlightRange(); + if (this.tree.getHTMLElement() === document.activeElement) { + this.highlightCurrentSelectedMarkerRange(); + } + } + + private highlightCurrentSelectedMarkerRange() { + const selections = this.tree.getSelection(); + + if (selections.length !== 1) { + return; + } + + const selection = selections[0]; + + if (!(selection instanceof Marker)) { + return; + } + + this.rangeHighlightDecorations.highlightRange(selection); + } + + private onContextMenu(e: ITreeContextMenuEvent): void { + const element = e.element; + if (!element) { + return; + } + + e.browserEvent.preventDefault(); + e.browserEvent.stopPropagation(); + + this.contextMenuService.showContextMenu({ + getAnchor: () => e.anchor!, + getActions: () => this.getMenuActions(element), + getActionViewItem: (action) => { + const keybinding = this.keybindingService.lookupKeybinding(action.id); + if (keybinding) { + return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() }); + } + return undefined; + }, + onHide: (wasCancelled?: boolean) => { + if (wasCancelled) { + this.tree.domFocus(); + } + } + }); + } + + private getMenuActions(element: TreeElement): IAction[] { + const result: IAction[] = []; + + if (element instanceof Marker) { + const viewModel = this.markersViewModel.getViewModel(element); + if (viewModel) { + const quickFixActions = viewModel.quickFixAction.quickFixes; + if (quickFixActions.length) { + result.push(...quickFixActions); + result.push(new Separator()); + } + } + } + + const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree.contextKeyService); + const groups = menu.getActions(); + menu.dispose(); + + for (let group of groups) { + const [, actions] = group; + result.push(...actions); + result.push(new Separator()); + } + + result.pop(); // remove last separator + return result; + } + + public getFocusElement() { + return this.tree.getFocus()[0]; + } + + public getActionViewItem(action: IAction): IActionViewItem | undefined { + if (action.id === MarkersFilterAction.ID) { + this.filterInputActionViewItem = this.instantiationService.createInstance(MarkersFilterActionViewItem, this.filterAction, this); + return this.filterInputActionViewItem; + } + return super.getActionViewItem(action); + } + + getFilterOptions(): FilterOptions { + return this.filter.options; + } + + getFilterStats(): { total: number; filtered: number; } { + if (!this.cachedFilterStats) { + this.cachedFilterStats = this.computeFilterStats(); + } + + return this.cachedFilterStats; + } + + private computeFilterStats(): { total: number; filtered: number; } { + const root = this.tree.getNode(); + let total = 0; + let filtered = 0; + + for (const resourceMarkerNode of root.children) { + for (const markerNode of resourceMarkerNode.children) { + total++; + + if (resourceMarkerNode.visible && markerNode.visible) { + filtered++; + } + } + } + + return { total, filtered }; + } + + private getTelemetryData({ source, code }: IMarker): any { + return { source, code }; + } + + protected saveState(): void { + this.panelState['filter'] = this.filterAction.filterText; + this.panelState['filterHistory'] = this.filterAction.filterHistory; + this.panelState['useFilesExclude'] = this.filterAction.useFilesExclude; + this.panelState['multiline'] = this.markersViewModel.multiline; + + super.saveState(); + } + + public dispose(): void { + super.dispose(); + this.tree.dispose(); + this.markersViewModel.dispose(); + this.disposables = dispose(this.disposables); + } +} From c6c88cbbfb4a240137a0ecfcea9994db5fd21aa5 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 3 Sep 2019 15:31:23 +0200 Subject: [PATCH 012/204] debt - remote integration tests (#80265) * fix * :up: distro --- .../azure-pipelines/darwin/product-build-darwin.yml | 1 + build/azure-pipelines/linux/product-build-linux.yml | 1 + build/azure-pipelines/win32/product-build-win32.yml | 2 +- extensions/vscode-test-resolver/src/extension.ts | 12 ++++++++---- package.json | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index 6bcd29db94a42..4595281f50864 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -106,6 +106,7 @@ steps: APP_ROOT=$(agent.builddirectory)/VSCode-darwin APP_NAME="`ls $APP_ROOT | head -n 1`" INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \ + VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-darwin" \ ./scripts/test-integration.sh --build --tfs "Integration Tests" displayName: Run integration tests condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 83e40784649a4..32ff5710091b4 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -109,6 +109,7 @@ steps: APP_ROOT=$(agent.builddirectory)/VSCode-linux-x64 APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ + VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-linux-x64" \ DISPLAY=:10 ./scripts/test-integration.sh --build --tfs "Integration Tests" # yarn smoketest -- --build "$(agent.builddirectory)/VSCode-linux-x64" displayName: Run integration tests diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index 2c40ee3113d8b..2785923c587f6 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -118,7 +118,7 @@ steps: $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)" $AppProductJson = Get-Content -Raw -Path "$AppRoot\resources\app\product.json" | ConvertFrom-Json $AppNameShort = $AppProductJson.nameShort - exec { $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe"; .\scripts\test-integration.bat --build --tfs "Integration Tests" } + exec { $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe"; $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\vscode-reh-win32-$(VSCODE_ARCH)"; .\scripts\test-integration.bat --build --tfs "Integration Tests" } displayName: Run integration tests condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) diff --git a/extensions/vscode-test-resolver/src/extension.ts b/extensions/vscode-test-resolver/src/extension.ts index 6ac9f34c18686..5d0abdfff2bd3 100644 --- a/extensions/vscode-test-resolver/src/extension.ts +++ b/extensions/vscode-test-resolver/src/extension.ts @@ -85,14 +85,18 @@ export function activate(context: vscode.ExtensionContext) { env['VSCODE_AGENT_FOLDER'] = remoteDataDir; outputChannel.appendLine(`Using data folder at ${remoteDataDir}`); - if (!commit || env['TEST_RESOLVER_USE_SERVER_FROM_SOURCES']) { // dev mode + if (!commit) { // dev mode const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..')); const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand); extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath }); } else { - const serverBin = path.join(remoteDataDir, 'bin'); - progress.report({ message: 'Installing VSCode Server' }); - const serverLocation = await downloadAndUnzipVSCodeServer(updateUrl, commit, quality, serverBin); + let serverLocation = env['VSCODE_REMOTE_SERVER_PATH']; // support environment + if (!serverLocation) { + const serverBin = path.join(remoteDataDir, 'bin'); + progress.report({ message: 'Installing VSCode Server' }); + serverLocation = await downloadAndUnzipVSCodeServer(updateUrl, commit, quality, serverBin); + } + outputChannel.appendLine(`Using server build at ${serverLocation}`); extHostProcess = cp.spawn(path.join(serverLocation, serverCommand), commandArgs, { env, cwd: serverLocation }); diff --git a/package.json b/package.json index 36e90f66160d4..f54f92e992e55 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.39.0", - "distro": "323c0a11187dcde94de3a5d913cd44437e85369a", + "distro": "d6e23d8c3f26a3421fd1f6821c88d5dbe2ee0831", "author": { "name": "Microsoft Corporation" }, From 0a02067a872fd5756090ef7e5eb9d6138b234b08 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Tue, 3 Sep 2019 15:36:34 +0200 Subject: [PATCH 013/204] workaround for terser issue (#80202) --- src/vs/base/common/json.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index da0535be422f4..4c0e983324145 100644 --- a/src/vs/base/common/json.ts +++ b/src/vs/base/common/json.ts @@ -291,7 +291,7 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON scanError = ScanError.UnexpectedEndOfString; break; } - let ch = text.charCodeAt(pos); + const ch = text.charCodeAt(pos); if (ch === CharacterCodes.doubleQuote) { result += text.substring(start, pos); pos++; @@ -304,8 +304,8 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON scanError = ScanError.UnexpectedEndOfString; break; } - ch = text.charCodeAt(pos++); - switch (ch) { + const ch2 = text.charCodeAt(pos++); + switch (ch2) { case CharacterCodes.doubleQuote: result += '\"'; break; @@ -331,9 +331,9 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON result += '\t'; break; case CharacterCodes.u: - const ch = scanHexDigits(4); - if (ch >= 0) { - result += String.fromCharCode(ch); + const ch3 = scanHexDigits(4); + if (ch3 >= 0) { + result += String.fromCharCode(ch3); } else { scanError = ScanError.InvalidUnicode; } @@ -1340,4 +1340,4 @@ function getLiteralNodeType(value: any): NodeType { case 'string': return 'string'; default: return 'null'; } -} \ No newline at end of file +} From e34c6c18e620adb09e1e154933e14e86f7cde4f7 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 3 Sep 2019 16:08:55 +0200 Subject: [PATCH 014/204] remote - server.bat => server.cmd --- extensions/vscode-test-resolver/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode-test-resolver/src/extension.ts b/extensions/vscode-test-resolver/src/extension.ts index 5d0abdfff2bd3..d6c0351990d95 100644 --- a/extensions/vscode-test-resolver/src/extension.ts +++ b/extensions/vscode-test-resolver/src/extension.ts @@ -78,7 +78,7 @@ export function activate(context: vscode.ExtensionContext) { } const { updateUrl, commit, quality, serverDataFolderName, dataFolderName } = getProductConfiguration(); - const serverCommand = process.platform === 'win32' ? 'server.bat' : 'server.sh'; + const serverCommand = process.platform === 'win32' ? 'server.cmd' : 'server.sh'; const commandArgs = ['--port=0', '--disable-telemetry']; const env = getNewEnv(); const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), serverDataFolderName || `${dataFolderName}-testresolver`); From e65562414537f6ca13307ef8720039128f6f4bd8 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 3 Sep 2019 16:11:10 +0200 Subject: [PATCH 015/204] remote - it is still server.bat locally --- extensions/vscode-test-resolver/src/extension.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/vscode-test-resolver/src/extension.ts b/extensions/vscode-test-resolver/src/extension.ts index d6c0351990d95..cb562bf3896b3 100644 --- a/extensions/vscode-test-resolver/src/extension.ts +++ b/extensions/vscode-test-resolver/src/extension.ts @@ -78,7 +78,6 @@ export function activate(context: vscode.ExtensionContext) { } const { updateUrl, commit, quality, serverDataFolderName, dataFolderName } = getProductConfiguration(); - const serverCommand = process.platform === 'win32' ? 'server.cmd' : 'server.sh'; const commandArgs = ['--port=0', '--disable-telemetry']; const env = getNewEnv(); const remoteDataDir = process.env['TESTRESOLVER_DATA_FOLDER'] || path.join(os.homedir(), serverDataFolderName || `${dataFolderName}-testresolver`); @@ -86,10 +85,12 @@ export function activate(context: vscode.ExtensionContext) { outputChannel.appendLine(`Using data folder at ${remoteDataDir}`); if (!commit) { // dev mode + const serverCommand = process.platform === 'win32' ? 'server.bat' : 'server.sh'; const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..')); const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand); extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath }); } else { + const serverCommand = process.platform === 'win32' ? 'server.cmd' : 'server.sh'; let serverLocation = env['VSCODE_REMOTE_SERVER_PATH']; // support environment if (!serverLocation) { const serverBin = path.join(remoteDataDir, 'bin'); From a5a8a28953e4efe0e05b1410ed1fc90e1ce92d77 Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 3 Sep 2019 16:15:11 +0200 Subject: [PATCH 016/204] label service: workspace suffix has to be explicitly set --- .../workbench/contrib/remote/common/remote.contribution.ts | 5 +++-- src/vs/workbench/services/label/common/labelService.ts | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/remote/common/remote.contribution.ts b/src/vs/workbench/contrib/remote/common/remote.contribution.ts index 404f5a2a78d0f..8ec38b3795e24 100644 --- a/src/vs/workbench/contrib/remote/common/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/common/remote.contribution.ts @@ -7,7 +7,7 @@ import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as import { Registry } from 'vs/platform/registry/common/platform'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { ILabelService } from 'vs/platform/label/common/label'; -import { OperatingSystem } from 'vs/base/common/platform'; +import { OperatingSystem, isWeb } from 'vs/base/common/platform'; import { Schemas } from 'vs/base/common/network'; import { IRemoteAgentService, RemoteExtensionLogFileName } from 'vs/workbench/services/remote/common/remoteAgentService'; import { ILogService } from 'vs/platform/log/common/log'; @@ -61,7 +61,8 @@ export class LabelContribution implements IWorkbenchContribution { label: '${path}', separator: remoteEnvironment.os === OperatingSystem.Windows ? '\\' : '/', tildify: remoteEnvironment.os !== OperatingSystem.Windows, - normalizeDriveLetter: remoteEnvironment.os === OperatingSystem.Windows + normalizeDriveLetter: remoteEnvironment.os === OperatingSystem.Windows, + workspaceSuffix: isWeb ? undefined : Schemas.vscodeRemote } }); } diff --git a/src/vs/workbench/services/label/common/labelService.ts b/src/vs/workbench/services/label/common/labelService.ts index 4f13891475028..a5934abc85d27 100644 --- a/src/vs/workbench/services/label/common/labelService.ts +++ b/src/vs/workbench/services/label/common/labelService.ts @@ -17,7 +17,6 @@ import { isWindows } from 'vs/base/common/platform'; import { tildify, getPathLabel } from 'vs/base/common/labels'; import { ltrim, endsWith } from 'vs/base/common/strings'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; -import { Schemas } from 'vs/base/common/network'; import { ILabelService, ResourceLabelFormatter, ResourceLabelFormatting } from 'vs/platform/label/common/label'; import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry'; import { match } from 'vs/base/common/glob'; @@ -283,12 +282,8 @@ export class LabelService implements ILabelService { } private appendWorkspaceSuffix(label: string, uri: URI): string { - if (uri.scheme === Schemas.file) { - return label; - } - const formatting = this.findFormatting(uri); - const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : uri.scheme; + const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : undefined; return suffix ? `${label} [${suffix}]` : label; } } From 0ef42df593f43886a78807b2a199922fa1c8ce6b Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 3 Sep 2019 16:38:57 +0200 Subject: [PATCH 017/204] breakpoints: polish titles fixes #80003 --- .../contrib/debug/browser/breakpointsView.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts index ff177c079d332..d0723c3bcfa83 100644 --- a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts @@ -445,7 +445,7 @@ class FunctionBreakpointsRenderer implements IListRenderer Date: Tue, 3 Sep 2019 17:20:29 +0200 Subject: [PATCH 018/204] debt - wrap things inside functions --- .../api/worker/extHostExtensionService.ts | 112 +++--------------- 1 file changed, 19 insertions(+), 93 deletions(-) diff --git a/src/vs/workbench/api/worker/extHostExtensionService.ts b/src/vs/workbench/api/worker/extHostExtensionService.ts index 4fcb6db76f824..afd82468c06c4 100644 --- a/src/vs/workbench/api/worker/extHostExtensionService.ts +++ b/src/vs/workbench/api/worker/extHostExtensionService.ts @@ -6,74 +6,10 @@ import { createApiFactoryAndRegisterActors } from 'vs/workbench/api/common/extHost.api.impl'; import { ExtensionActivationTimesBuilder } from 'vs/workbench/api/common/extHostExtensionActivator'; import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService'; -import { endsWith, startsWith } from 'vs/base/common/strings'; +import { endsWith } from 'vs/base/common/strings'; import { URI } from 'vs/base/common/uri'; -import { joinPath } from 'vs/base/common/resources'; import { RequireInterceptor } from 'vs/workbench/api/common/extHostRequireInterceptor'; -class ExportsTrap { - - static readonly Instance = new ExportsTrap(); - - private readonly _names: string[] = []; - private readonly _exports = new Map(); - - private constructor() { - - const exportsProxy = new Proxy({}, { - set: (target: any, p: PropertyKey, value: any) => { - // store in target - target[p] = value; - // store in named-bucket - const name = this._names[this._names.length - 1]; - this._exports.get(name)![p] = value; - return true; - } - }); - - - const moduleProxy = new Proxy({}, { - - get: (target: any, p: PropertyKey) => { - if (p === 'exports') { - return exportsProxy; - } - - return target[p]; - }, - - set: (target: any, p: PropertyKey, value: any) => { - // store in target - target[p] = value; - - // override bucket - if (p === 'exports') { - const name = this._names[this._names.length - 1]; - this._exports.set(name, value); - } - return true; - } - }); - - (self).exports = exportsProxy; - (self).module = moduleProxy; - } - - add(name: string) { - this._exports.set(name, Object.create(null)); - this._names.push(name); - - return { - claim: () => { - const result = this._exports.get(name); - this._exports.delete(name); - this._names.pop(); - return result; - } - }; - } -} - class WorkerRequireInterceptor extends RequireInterceptor { _installInterceptor() { } @@ -105,43 +41,33 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService { await this._fakeModules.install(); } - protected _loadCommonJSModule(module: URI, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise { + protected async _loadCommonJSModule(module: URI, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise { - (self).window = self; // <- that's improper but might help extensions that aren't authored correctly + module = module.with({ path: ensureSuffix(module.path, '.js') }); + const response = await fetch(module.toString(true)); - // FAKE require function that only works for the vscode-module - const moduleStack: URI[] = []; - (self).require = (mod: string) => { - - const parent = moduleStack[moduleStack.length - 1]; - const result = this._fakeModules.getModule(mod, parent); + if (response.status !== 200) { + throw new Error(response.statusText); + } - if (result !== undefined) { - return result; - } + // fetch JS sources as text and create a new function around it + const initFn = new Function('module', 'exports', 'require', 'window', await response.text()); - if (!startsWith(mod, '.')) { - throw new Error(`Cannot load module '${mod}'`); + // define commonjs globals: `module`, `exports`, and `require` + const _exports = {}; + const _module = { exports: _exports }; + const _require = (request: string) => { + const result = this._fakeModules.getModule(request, module); + if (result === undefined) { + throw new Error(`Cannot load module '${request}'`); } - - const next = joinPath(parent, '..', ensureSuffix(mod, '.js')); - moduleStack.push(next); - const trap = ExportsTrap.Instance.add(next.toString()); - importScripts(next.toString(true)); - moduleStack.pop(); - - return trap.claim(); + return result; }; try { activationTimesBuilder.codeLoadingStart(); - module = module.with({ path: ensureSuffix(module.path, '.js') }); - moduleStack.push(module); - const trap = ExportsTrap.Instance.add(module.toString()); - importScripts(module.toString(true)); - moduleStack.pop(); - return Promise.resolve(trap.claim()); - + initFn(_module, _exports, _require, self); + return (_module.exports !== _exports ? _module.exports : _exports); } finally { activationTimesBuilder.codeLoadingStop(); } From 587c673c7fb5d750f5015615d1fb6e711d412f13 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Tue, 3 Sep 2019 17:51:53 +0200 Subject: [PATCH 019/204] wsl2 workaround no longer necessary --- resources/win32/bin/code.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/win32/bin/code.sh b/resources/win32/bin/code.sh index 745f2adb7aafc..54da18c898c13 100644 --- a/resources/win32/bin/code.sh +++ b/resources/win32/bin/code.sh @@ -16,7 +16,7 @@ if grep -qi Microsoft /proc/version; then WSL_BUILD=0 fi - if [ $WSL_BUILD -ge 17063 ]; then + if [ $WSL_BUILD -ge 41955 -a $WSL_BUILD -lt 41959 ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 From 54eaeb75446395486c9e8665c638882af39bdae3 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 3 Sep 2019 17:55:05 +0200 Subject: [PATCH 020/204] :up: distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f54f92e992e55..44e5ecd868242 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.39.0", - "distro": "d6e23d8c3f26a3421fd1f6821c88d5dbe2ee0831", + "distro": "02850a424614d800c64b5b0a03ccc751b6383760", "author": { "name": "Microsoft Corporation" }, From 14a3819e74a562c4aa5c1c07b31bedf99060951d Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Tue, 3 Sep 2019 09:19:56 -0700 Subject: [PATCH 021/204] Fix #80269 --- extensions/css-language-features/package.json | 4 ++++ .../schemas/package.schema.json | 20 +++++++++++++++++++ .../html-language-features/package.json | 4 ++++ .../schemas/package.schema.json | 20 +++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 extensions/css-language-features/schemas/package.schema.json create mode 100644 extensions/html-language-features/schemas/package.schema.json diff --git a/extensions/css-language-features/package.json b/extensions/css-language-features/package.json index 3b68a1713edf7..a02d6c2be9332 100644 --- a/extensions/css-language-features/package.json +++ b/extensions/css-language-features/package.json @@ -745,6 +745,10 @@ { "fileMatch": "*.css-data.json", "url": "https://raw.githubusercontent.com/Microsoft/vscode-css-languageservice/master/docs/customData.schema.json" + }, + { + "fileMatch": "package.json", + "url": "./schemas/package.schema.json" } ] }, diff --git a/extensions/css-language-features/schemas/package.schema.json b/extensions/css-language-features/schemas/package.schema.json new file mode 100644 index 0000000000000..3aeca1e040a08 --- /dev/null +++ b/extensions/css-language-features/schemas/package.schema.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "CSS contributions to package.json", + "type": "object", + "properties": { + "contributes": { + "type": "object", + "properties": { + "css.customData": { + "type": "array", + "markdownDescription": "A list of relative file paths pointing to JSON files following the [custom data format](https://github.com/Microsoft/vscode-css-languageservice/blob/master/docs/customData.md).\n\nVS Code loads custom data on startup to enhance its CSS support for the custom CSS properties, at directives, pseudo classes and pseudo elements you specify in the JSON files.\n\nThe file paths are relative to workspace and only workspace folder settings are considered.", + "items": { + "type": "string", + "description": "Relative path to a CSS custom data file" + } + } + } + } + } +} diff --git a/extensions/html-language-features/package.json b/extensions/html-language-features/package.json index c19eec0cf345e..557fe83ca86df 100644 --- a/extensions/html-language-features/package.json +++ b/extensions/html-language-features/package.json @@ -188,6 +188,10 @@ { "fileMatch": "*.html-data.json", "url": "https://raw.githubusercontent.com/Microsoft/vscode-html-languageservice/master/docs/customData.schema.json" + }, + { + "fileMatch": "package.json", + "url": "./schemas/package.schema.json" } ] }, diff --git a/extensions/html-language-features/schemas/package.schema.json b/extensions/html-language-features/schemas/package.schema.json new file mode 100644 index 0000000000000..aaf9588221e41 --- /dev/null +++ b/extensions/html-language-features/schemas/package.schema.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "HTML contributions to package.json", + "type": "object", + "properties": { + "contributes": { + "type": "object", + "properties": { + "html.customData": { + "type": "array", + "markdownDescription": "A list of relative file paths pointing to JSON files following the [custom data format](https://github.com/Microsoft/vscode-html-languageservice/blob/master/docs/customData.md).\n\nVS Code loads custom data on startup to enhance its HTML support for the custom HTML tags, attributes and attribute values you specify in the JSON files.\n\nThe file paths are relative to workspace and only workspace folder settings are considered.", + "items": { + "type": "string", + "description": "Relative path to a HTML custom data file" + } + } + } + } + } +} From b038107d7692e8baeeb6a9ea426f4f8b4eb2db80 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Tue, 3 Sep 2019 09:46:53 -0700 Subject: [PATCH 022/204] Fix #75639 --- .../publish-types/publish-types.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build/azure-pipelines/publish-types/publish-types.yml b/build/azure-pipelines/publish-types/publish-types.yml index d377226366a67..6808054b3f122 100644 --- a/build/azure-pipelines/publish-types/publish-types.yml +++ b/build/azure-pipelines/publish-types/publish-types.yml @@ -15,6 +15,22 @@ steps: inputs: versionSpec: "1.x" +- bash: | + TAG_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`) + CHANNEL="G1C14HJ2F" + + if [ "$TAG_VERSION" == "1.999.0" ]; then + MESSAGE=". Someone pushed 1.999.0 tag. Please delete it ASAP from remote and local." + + curl -X POST -H "Authorization: Bearer $(SLACK_TOKEN)" \ + -H 'Content-type: application/json; charset=utf-8' \ + --data '{"channel":"'"$CHANNEL"'", "link_names": true, "text":"'"$MESSAGE"'"}' \ + https://slack.com/api/chat.postMessage + + exit 1 + fi + displayName: Check 1.999.0 tag + - bash: | # Install build dependencies (cd build && yarn) From 223d9f9d2d5fde10243bfa69c0d6f5c0cad6eb96 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 3 Sep 2019 09:59:14 -0700 Subject: [PATCH 023/204] Correct kb validation for windows ctrl. --- src/vs/editor/contrib/find/findWidget.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index d35752a078dec..5191b61194ba0 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -67,6 +67,7 @@ let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COU const FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible. const ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask'; +const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd); export class FindWidgetViewZone implements IViewZone { public readonly afterLineNumber: number; public heightInPx: number; @@ -775,7 +776,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private _onFindInputKeyDown(e: IKeyboardEvent): void { - if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) { + if (e.equals(ctrlKeyMod | KeyCode.Enter)) { const inputElement = this._findInput.inputBox.inputElement; const start = inputElement.selectionStart; const end = inputElement.selectionEnd; @@ -817,7 +818,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private _onReplaceInputKeyDown(e: IKeyboardEvent): void { - if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) { + if (e.equals(ctrlKeyMod | KeyCode.Enter)) { if (platform.isWindows && platform.isNative && !this._ctrlEnterReplaceAllWarningPrompted) { // this is the first time when users press Ctrl + Enter to replace all this._notificationService.info( @@ -835,7 +836,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas const end = inputElement.selectionEnd; const content = inputElement.value; - if (start && end) { + if (start !== null && end !== null) { const value = content.substr(0, start) + '\n' + content.substr(end); this._replaceInput.inputBox.value = value; inputElement.setSelectionRange(start + 1, start + 1); From 2c4ea586881e30538c2d5328ec292eadb9be49a8 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 3 Sep 2019 09:59:14 -0700 Subject: [PATCH 024/204] Correct kb validation for windows ctrl. --- src/vs/editor/contrib/find/findWidget.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index 383f158c1dedc..b5b2afdff6977 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -67,6 +67,7 @@ let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COU const FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible. const ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask'; +const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd); export class FindWidgetViewZone implements IViewZone { public readonly afterLineNumber: number; public heightInPx: number; @@ -775,7 +776,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private _onFindInputKeyDown(e: IKeyboardEvent): void { - if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) { + if (e.equals(ctrlKeyMod | KeyCode.Enter)) { const inputElement = this._findInput.inputBox.inputElement; const start = inputElement.selectionStart; const end = inputElement.selectionEnd; @@ -817,7 +818,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private _onReplaceInputKeyDown(e: IKeyboardEvent): void { - if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) { + if (e.equals(ctrlKeyMod | KeyCode.Enter)) { if (platform.isWindows && platform.isNative && !this._ctrlEnterReplaceAllWarningPrompted) { // this is the first time when users press Ctrl + Enter to replace all this._notificationService.info( @@ -835,7 +836,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas const end = inputElement.selectionEnd; const content = inputElement.value; - if (start && end) { + if (start !== null && end !== null) { const value = content.substr(0, start) + '\n' + content.substr(end); this._replaceInput.inputBox.value = value; inputElement.setSelectionRange(start + 1, start + 1); From 6829b31625505fd87d6d96f9ac4425f1b412d217 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Tue, 3 Sep 2019 10:13:46 -0700 Subject: [PATCH 025/204] Fix #80274 --- extensions/css-language-features/server/src/cssServerMain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/css-language-features/server/src/cssServerMain.ts b/extensions/css-language-features/server/src/cssServerMain.ts index a5c50d515c7e4..a1dee46c5237b 100644 --- a/extensions/css-language-features/server/src/cssServerMain.ts +++ b/extensions/css-language-features/server/src/cssServerMain.ts @@ -128,7 +128,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => { const capabilities: ServerCapabilities = { // Tell the client that the server works in FULL text document sync mode textDocumentSync: documents.syncKind, - completionProvider: snippetSupport ? { resolveProvider: false, triggerCharacters: ['/'] } : undefined, + completionProvider: snippetSupport ? { resolveProvider: false, triggerCharacters: ['/', '-'] } : undefined, hoverProvider: true, documentSymbolProvider: true, referencesProvider: true, From 1c623c163d43754f33615c45a36e1eb876df617f Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Tue, 3 Sep 2019 10:54:02 -0700 Subject: [PATCH 026/204] Part of #71996 --- extensions/emmet/src/abbreviationActions.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/extensions/emmet/src/abbreviationActions.ts b/extensions/emmet/src/abbreviationActions.ts index 9508d3a6a0b15..058a8579e2a3f 100644 --- a/extensions/emmet/src/abbreviationActions.ts +++ b/extensions/emmet/src/abbreviationActions.ts @@ -231,6 +231,21 @@ export function expandEmmetAbbreviation(args: any): Thenable Date: Tue, 3 Sep 2019 11:14:32 -0700 Subject: [PATCH 027/204] Enable unicode mode for regex search in editor, and remap \u{1234} for rg Fix #62416, fix #61746 --- src/vs/base/common/strings.ts | 2 +- src/vs/editor/common/model/textModelSearch.ts | 3 +- src/vs/editor/contrib/find/findModel.ts | 2 +- .../test/common/model/textModelSearch.test.ts | 46 ++++++++++++------- .../services/search/common/replace.ts | 2 +- .../services/search/common/search.ts | 1 + .../search/node/ripgrepTextSearchEngine.ts | 29 +++++++----- .../test/node/ripgrepTextSearchEngine.test.ts | 7 ++- .../test/node/textSearch.integrationTest.ts | 20 ++++++++ 9 files changed, 78 insertions(+), 34 deletions(-) diff --git a/src/vs/base/common/strings.ts b/src/vs/base/common/strings.ts index 71185d0704613..1c4251e7803b8 100644 --- a/src/vs/base/common/strings.ts +++ b/src/vs/base/common/strings.ts @@ -70,7 +70,7 @@ export function escape(html: string): string { * Escapes regular expression characters in a given string */ export function escapeRegExpCharacters(value: string): string { - return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\[\]\(\)\#]/g, '\\$&'); + return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)\#]/g, '\\$&'); } /** diff --git a/src/vs/editor/common/model/textModelSearch.ts b/src/vs/editor/common/model/textModelSearch.ts index ec2bb71ec3072..f350079ee690a 100644 --- a/src/vs/editor/common/model/textModelSearch.ts +++ b/src/vs/editor/common/model/textModelSearch.ts @@ -45,7 +45,8 @@ export class SearchParams { matchCase: this.matchCase, wholeWord: false, multiline: multiline, - global: true + global: true, + unicode: true }); } catch (err) { return null; diff --git a/src/vs/editor/contrib/find/findModel.ts b/src/vs/editor/contrib/find/findModel.ts index faca23f0a556c..90932abefc65e 100644 --- a/src/vs/editor/contrib/find/findModel.ts +++ b/src/vs/editor/contrib/find/findModel.ts @@ -467,7 +467,7 @@ export class FindModelBoundToEditorModel { let searchRegex = searchData.regex; if (!searchRegex.multiline) { - let mod = 'm'; + let mod = 'mu'; if (searchRegex.ignoreCase) { mod += 'i'; } diff --git a/src/vs/editor/test/common/model/textModelSearch.test.ts b/src/vs/editor/test/common/model/textModelSearch.test.ts index 6476015cb5d89..aa90e1c0c3f5c 100644 --- a/src/vs/editor/test/common/model/textModelSearch.test.ts +++ b/src/vs/editor/test/common/model/textModelSearch.test.ts @@ -611,25 +611,25 @@ suite('TextModelSearch', () => { }); test('parseSearchRequest non regex', () => { - assertParseSearchResult('foo', false, false, null, new SearchData(/foo/gi, null, null)); - assertParseSearchResult('foo', false, false, USUAL_WORD_SEPARATORS, new SearchData(/foo/gi, usualWordSeparators, null)); - assertParseSearchResult('foo', false, true, null, new SearchData(/foo/g, null, 'foo')); - assertParseSearchResult('foo', false, true, USUAL_WORD_SEPARATORS, new SearchData(/foo/g, usualWordSeparators, 'foo')); - assertParseSearchResult('foo\\n', false, false, null, new SearchData(/foo\\n/gi, null, null)); - assertParseSearchResult('foo\\\\n', false, false, null, new SearchData(/foo\\\\n/gi, null, null)); - assertParseSearchResult('foo\\r', false, false, null, new SearchData(/foo\\r/gi, null, null)); - assertParseSearchResult('foo\\\\r', false, false, null, new SearchData(/foo\\\\r/gi, null, null)); + assertParseSearchResult('foo', false, false, null, new SearchData(/foo/giu, null, null)); + assertParseSearchResult('foo', false, false, USUAL_WORD_SEPARATORS, new SearchData(/foo/giu, usualWordSeparators, null)); + assertParseSearchResult('foo', false, true, null, new SearchData(/foo/gu, null, 'foo')); + assertParseSearchResult('foo', false, true, USUAL_WORD_SEPARATORS, new SearchData(/foo/gu, usualWordSeparators, 'foo')); + assertParseSearchResult('foo\\n', false, false, null, new SearchData(/foo\\n/giu, null, null)); + assertParseSearchResult('foo\\\\n', false, false, null, new SearchData(/foo\\\\n/giu, null, null)); + assertParseSearchResult('foo\\r', false, false, null, new SearchData(/foo\\r/giu, null, null)); + assertParseSearchResult('foo\\\\r', false, false, null, new SearchData(/foo\\\\r/giu, null, null)); }); test('parseSearchRequest regex', () => { - assertParseSearchResult('foo', true, false, null, new SearchData(/foo/gi, null, null)); - assertParseSearchResult('foo', true, false, USUAL_WORD_SEPARATORS, new SearchData(/foo/gi, usualWordSeparators, null)); - assertParseSearchResult('foo', true, true, null, new SearchData(/foo/g, null, null)); - assertParseSearchResult('foo', true, true, USUAL_WORD_SEPARATORS, new SearchData(/foo/g, usualWordSeparators, null)); - assertParseSearchResult('foo\\n', true, false, null, new SearchData(/foo\n/gim, null, null)); - assertParseSearchResult('foo\\\\n', true, false, null, new SearchData(/foo\\n/gi, null, null)); - assertParseSearchResult('foo\\r', true, false, null, new SearchData(/foo\r/gim, null, null)); - assertParseSearchResult('foo\\\\r', true, false, null, new SearchData(/foo\\r/gi, null, null)); + assertParseSearchResult('foo', true, false, null, new SearchData(/foo/giu, null, null)); + assertParseSearchResult('foo', true, false, USUAL_WORD_SEPARATORS, new SearchData(/foo/giu, usualWordSeparators, null)); + assertParseSearchResult('foo', true, true, null, new SearchData(/foo/gu, null, null)); + assertParseSearchResult('foo', true, true, USUAL_WORD_SEPARATORS, new SearchData(/foo/gu, usualWordSeparators, null)); + assertParseSearchResult('foo\\n', true, false, null, new SearchData(/foo\n/gimu, null, null)); + assertParseSearchResult('foo\\\\n', true, false, null, new SearchData(/foo\\n/giu, null, null)); + assertParseSearchResult('foo\\r', true, false, null, new SearchData(/foo\r/gimu, null, null)); + assertParseSearchResult('foo\\\\r', true, false, null, new SearchData(/foo\\r/giu, null, null)); }); test('issue #53415. \W should match line break.', () => { @@ -721,6 +721,20 @@ suite('TextModelSearch', () => { ); }); + test('Simple find using unicode escape sequences', () => { + assertFindMatches( + regularText.join('\n'), + '\\u{0066}\\u006f\\u006F', true, false, null, + [ + [1, 14, 1, 17], + [1, 44, 1, 47], + [2, 22, 2, 25], + [2, 48, 2, 51], + [4, 59, 4, 62] + ] + ); + }); + test('isMultilineRegexSource', () => { assert(!isMultilineRegexSource('foo')); assert(!isMultilineRegexSource('')); diff --git a/src/vs/workbench/services/search/common/replace.ts b/src/vs/workbench/services/search/common/replace.ts index 99f610bbcf5ce..764873d247ab7 100644 --- a/src/vs/workbench/services/search/common/replace.ts +++ b/src/vs/workbench/services/search/common/replace.ts @@ -27,7 +27,7 @@ export class ReplacePattern { } else { searchPatternInfo = arg2; parseParameters = !!searchPatternInfo.isRegExp; - this._regExp = strings.createRegExp(searchPatternInfo.pattern, !!searchPatternInfo.isRegExp, { matchCase: searchPatternInfo.isCaseSensitive, wholeWord: searchPatternInfo.isWordMatch, multiline: searchPatternInfo.isMultiline, global: false }); + this._regExp = strings.createRegExp(searchPatternInfo.pattern, !!searchPatternInfo.isRegExp, { matchCase: searchPatternInfo.isCaseSensitive, wholeWord: searchPatternInfo.isWordMatch, multiline: searchPatternInfo.isMultiline, global: false, unicode: true }); } if (parseParameters) { diff --git a/src/vs/workbench/services/search/common/search.ts b/src/vs/workbench/services/search/common/search.ts index bb47b117377e3..30e38c2c7686d 100644 --- a/src/vs/workbench/services/search/common/search.ts +++ b/src/vs/workbench/services/search/common/search.ts @@ -132,6 +132,7 @@ export interface IPatternInfo { isWordMatch?: boolean; wordSeparators?: string; isMultiline?: boolean; + isUnicode?: boolean; isCaseSensitive?: boolean; } diff --git a/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts b/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts index ee39b55b8e857..84d73b811cc52 100644 --- a/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts +++ b/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts @@ -394,13 +394,11 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[] args.push('--encoding', options.encoding); } - let pattern = query.pattern; - // Ripgrep handles -- as a -- arg separator. Only --. // - is ok, --- is ok, --some-flag is also ok. Need to special case. - if (pattern === '--') { + if (query.pattern === '--') { query.isRegExp = true; - pattern = '\\-\\-'; + query.pattern = '\\-\\-'; } if (query.isMultiline && !query.isRegExp) { @@ -413,7 +411,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[] } if (query.isRegExp) { - pattern = unicodeEscapesToPCRE2(pattern); + query.pattern = unicodeEscapesToPCRE2(query.pattern); } // Allow $ to match /r/n @@ -421,7 +419,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[] let searchPatternAfterDoubleDashes: Maybe; if (query.isWordMatch) { - const regexp = createRegExp(pattern, !!query.isRegExp, { wholeWord: query.isWordMatch }); + const regexp = createRegExp(query.pattern, !!query.isRegExp, { wholeWord: query.isWordMatch }); const regexpStr = regexp.source.replace(/\\\//g, '/'); // RegExp.source arbitrarily returns escaped slashes. Search and destroy. args.push('--regexp', regexpStr); } else if (query.isRegExp) { @@ -430,7 +428,7 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[] args.push('--regexp', fixedRegexpQuery); args.push('--auto-hybrid-regex'); } else { - searchPatternAfterDoubleDashes = pattern; + searchPatternAfterDoubleDashes = query.pattern; args.push('--fixed-strings'); } @@ -479,11 +477,18 @@ export function spreadGlobComponents(globArg: string): string[] { } export function unicodeEscapesToPCRE2(pattern: string): string { - const reg = /((?:[^\\]|^)(?:\\\\)*)\\u([a-z0-9]{4})(?!\d)/g; - // Replace an unescaped $ at the end of the pattern with \r?$ - // Match $ preceeded by none or even number of literal \ - while (pattern.match(reg)) { - pattern = pattern.replace(reg, `$1\\x{$2}`); + // Match \u1234 + const unicodePattern = /((?:[^\\]|^)(?:\\\\)*)\\u([a-z0-9]{4})/g; + + while (pattern.match(unicodePattern)) { + pattern = pattern.replace(unicodePattern, `$1\\x{$2}`); + } + + // Match \u{1234} + // \u with 5-6 characters will be left alone because \x only takes 4 characters. + const unicodePatternWithBraces = /((?:[^\\]|^)(?:\\\\)*)\\u\{([a-z0-9]{4})\}/g; + while (pattern.match(unicodePatternWithBraces)) { + pattern = pattern.replace(unicodePatternWithBraces, `$1\\x{$2}`); } return pattern; diff --git a/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngine.test.ts b/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngine.test.ts index fb307c68bfde0..d1b0f31042f00 100644 --- a/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngine.test.ts +++ b/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngine.test.ts @@ -17,9 +17,12 @@ suite('RipgrepTextSearchEngine', () => { assert.equal(unicodeEscapesToPCRE2('\\\\\\u1234'), '\\\\\\x{1234}'); assert.equal(unicodeEscapesToPCRE2('foo\\\\\\u1234'), 'foo\\\\\\x{1234}'); + assert.equal(unicodeEscapesToPCRE2('\\u{1234}'), '\\x{1234}'); + assert.equal(unicodeEscapesToPCRE2('\\u{1234}\\u{0001}'), '\\x{1234}\\x{0001}'); + assert.equal(unicodeEscapesToPCRE2('foo\\u{1234}bar'), 'foo\\x{1234}bar'); + + assert.equal(unicodeEscapesToPCRE2('foo\\u{123456}7bar'), 'foo\\u{123456}7bar'); assert.equal(unicodeEscapesToPCRE2('\\u123'), '\\u123'); - assert.equal(unicodeEscapesToPCRE2('\\u12345'), '\\u12345'); - assert.equal(unicodeEscapesToPCRE2('\\\\u12345'), '\\\\u12345'); assert.equal(unicodeEscapesToPCRE2('foo'), 'foo'); assert.equal(unicodeEscapesToPCRE2(''), ''); }); diff --git a/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts b/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts index 6f39df7725048..ce38358933eea 100644 --- a/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts +++ b/src/vs/workbench/services/search/test/node/textSearch.integrationTest.ts @@ -69,6 +69,26 @@ suite('Search-integration', function () { return doSearchTest(config, 4); }); + test('Text: GameOfLife (unicode escape sequences)', () => { + const config: ITextQuery = { + type: QueryType.Text, + folderQueries: ROOT_FOLDER_QUERY, + contentPattern: { pattern: 'G\\u{0061}m\\u0065OfLife', isRegExp: true } + }; + + return doSearchTest(config, 4); + }); + + test('Text: GameOfLife (unicode escape sequences, force PCRE2)', () => { + const config: ITextQuery = { + type: QueryType.Text, + folderQueries: ROOT_FOLDER_QUERY, + contentPattern: { pattern: '(? { const config: ITextQuery = { type: QueryType.Text, From 730f47da21d26733734b9d3d1d361638379d9404 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 3 Sep 2019 11:26:58 -0700 Subject: [PATCH 028/204] Add missing comma in Pseudoterminal types --- src/vs/vscode.proposed.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 3eca5ca02c263..aea830a6a9fc4 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -883,7 +883,7 @@ declare module 'vscode' { * onDidWrite: writeEmitter.event, * onDidClose: closeEmitter.event, * open: () => writeEmitter.fire('Press y to exit successfully'), - * close: () => {} + * close: () => {}, * handleInput: data => { * if (data !== 'y') { * vscode.window.showInformationMessage('Something went wrong'); From 1de69415070dad9722cb60dcd5f521f61bec52e9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 3 Sep 2019 11:28:38 -0700 Subject: [PATCH 029/204] Move xterm type customizations into contrib/terminal Part of #80074 --- src/tsconfig.json | 5 +++- .../terminal/browser/terminalConfigHelper.ts | 12 ++++---- .../terminal/browser/terminalInstance.ts | 25 +++++++++------- .../terminal/browser/xterm-private.d.ts | 29 +++++++++++++++++++ .../terminalCommandTracker.test.ts | 5 ++-- 5 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts diff --git a/src/tsconfig.json b/src/tsconfig.json index dcff5cff53f27..8917d57336d6a 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -24,6 +24,9 @@ "./vs" ], "exclude": [ - "./typings/require-monaco.d.ts" + "./typings/require-monaco.d.ts", + "./typings/xterm.d.ts", + "./typings/xterm-addon-search.d.ts", + "./typings/xterm-addon-web-links.d.ts" ] } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts index 79138f8545a7a..3e0b3e13d4d2c 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts @@ -10,7 +10,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { ITerminalConfiguration, ITerminalFont, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING, LinuxDistro, IShellLaunchConfig } from 'vs/workbench/contrib/terminal/common/terminal'; import Severity from 'vs/base/common/severity'; -import { Terminal as XTermTerminal } from 'xterm'; import { INotificationService, NeverShowAgainScope } from 'vs/platform/notification/common/notification'; import { IBrowserTerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminal'; import { Emitter, Event } from 'vs/base/common/event'; @@ -21,6 +20,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { InstallRecommendedExtensionAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions'; import { IProductService } from 'vs/platform/product/common/product'; +import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; const MINIMUM_FONT_SIZE = 6; const MAXIMUM_FONT_SIZE = 25; @@ -129,7 +129,7 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper { * Gets the font information based on the terminal.integrated.fontFamily * terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties */ - public getFont(xterm?: XTermTerminal, excludeDimensions?: boolean): ITerminalFont { + public getFont(xtermCore?: XTermCore, excludeDimensions?: boolean): ITerminalFont { const editorConfig = this._configurationService.getValue('editor'); let fontFamily = this.config.fontFamily || editorConfig.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily; @@ -161,15 +161,15 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper { } // Get the character dimensions from xterm if it's available - if (xterm) { - if (xterm._core._charSizeService && xterm._core._charSizeService.width && xterm._core._charSizeService.height) { + if (xtermCore) { + if (xtermCore._charSizeService && xtermCore._charSizeService.width && xtermCore._charSizeService.height) { return { fontFamily, fontSize, letterSpacing, lineHeight, - charHeight: xterm._core._charSizeService.height, - charWidth: xterm._core._charSizeService.width + charHeight: xtermCore._charSizeService.height, + charWidth: xtermCore._charSizeService.width }; } } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index c210bb9d05dc8..2cc1f6ed4919a 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -38,6 +38,7 @@ import { Terminal as XTermTerminal, IBuffer, ITerminalAddon } from 'xterm'; import { SearchAddon, ISearchOptions } from 'xterm-addon-search'; import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon'; import { NavigationModeAddon } from 'vs/workbench/contrib/terminal/browser/addons/navigationModeAddon'; +import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; // How long in milliseconds should an average frame take to render for a notification to appear // which suggests the fallback DOM-based renderer @@ -184,6 +185,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _title: string = ''; private _wrapperElement: (HTMLElement & { xterm?: XTermTerminal }) | undefined; private _xterm: XTermTerminal | undefined; + private _xtermCore: XTermCore | undefined; private _xtermSearch: SearchAddon | undefined; private _xtermElement: HTMLDivElement | undefined; private _terminalHasTextContextKey: IContextKey; @@ -351,7 +353,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { return null; } - const font = this._configHelper.getFont(this._xterm); + const font = this._configHelper.getFont(this._xtermCore); if (!font.charWidth || !font.charHeight) { this._setLastKnownColsAndRows(); return null; @@ -399,7 +401,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _getDimension(width: number, height: number): ICanvasDimensions | undefined { // The font needs to have been initialized - const font = this._configHelper.getFont(this._xterm); + const font = this._configHelper.getFont(this._xtermCore); if (!font || !font.charWidth || !font.charHeight) { return undefined; } @@ -412,8 +414,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // needs to happen otherwise its scrollTop value is invalid when the panel is toggled as // it gets removed and then added back to the DOM (resetting scrollTop to 0). // Upstream issue: https://github.com/sourcelair/xterm.js/issues/291 - if (this._xterm) { - this._xterm._core._onScroll.fire(this._xterm.buffer.viewportY); + if (this._xterm && this._xtermCore) { + this._xtermCore._onScroll.fire(this._xterm.buffer.viewportY); } } @@ -472,6 +474,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { rendererType: config.rendererType === 'auto' ? 'canvas' : config.rendererType }); this._xterm = xterm; + this._xtermCore = (xterm as any)._core as XTermCore; this.updateAccessibilitySupport(); this._terminalInstanceService.getXtermSearchConstructor().then(Addon => { this._xtermSearch = new Addon(); @@ -674,9 +677,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } private async _measureRenderTime(): Promise { - const xterm = await this._xtermReadyPromise; + await this._xtermReadyPromise; const frameTimes: number[] = []; - const textRenderLayer = xterm._core._renderService._renderer._renderLayers[0]; + const textRenderLayer = this._xtermCore!._renderService._renderer._renderLayers[0]; const originalOnGridChanged = textRenderLayer.onGridChanged; const evaluateCanvasRenderer = () => { @@ -893,12 +896,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { if (this._wrapperElement) { dom.toggleClass(this._wrapperElement, 'active', visible); } - if (visible && this._xterm) { + if (visible && this._xterm && this._xtermCore) { // Trigger a manual scroll event which will sync the viewport and scroll bar. This is // necessary if the number of rows in the terminal has decreased while it was in the // background since scrollTop changes take no effect but the terminal's position does // change since the number of visible rows decreases. - this._xterm._core._onScroll.fire(this._xterm.buffer.viewportY); + this._xtermCore._onScroll.fire(this._xterm.buffer.viewportY); if (this._container && this._container.parentElement) { // Force a layout when the instance becomes invisible. This is particularly important // for ensuring that terminals that are created in the background by an extension will @@ -1322,11 +1325,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { let cols = this.cols; let rows = this.rows; - if (this._xterm) { + if (this._xterm && this._xtermCore) { // Only apply these settings when the terminal is visible so that // the characters are measured correctly. if (this._isVisible) { - const font = this._configHelper.getFont(this._xterm); + const font = this._configHelper.getFont(this._xtermCore); const config = this._configHelper.config; this._safeSetOption('letterSpacing', font.letterSpacing); this._safeSetOption('lineHeight', font.lineHeight); @@ -1354,7 +1357,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // maximize on Windows/Linux would fire an event saying that the terminal was not // visible. if (this._xterm.getOption('rendererType') === 'canvas') { - this._xterm._core._renderService._onIntersectionChange({ intersectionRatio: 1 }); + this._xtermCore._renderService._onIntersectionChange({ intersectionRatio: 1 }); // HACK: Force a refresh of the screen to ensure links are refresh corrected. // This can probably be removed when the above hack is fixed in Chromium. this._xterm.refresh(0, this._xterm.rows - 1); diff --git a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts new file mode 100644 index 0000000000000..9ebf15d3032cc --- /dev/null +++ b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts @@ -0,0 +1,29 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +export interface XTermCore { + _onScroll: IEventEmitter; + _onKey: IEventEmitter<{ key: string }>; + + _charSizeService: { + width: number; + height: number; + }; + + _coreService: { + triggerDataEvent(data: string, wasUserInput?: boolean): void; + } + + _renderService: { + _renderer: { + _renderLayers: any[]; + }; + _onIntersectionChange: any; + }; +} + +export interface IEventEmitter { + fire(e: T): void; +} diff --git a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts index 2c74cd5468289..e8d3fd143ee3f 100644 --- a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts +++ b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts @@ -4,11 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import { Terminal, TerminalCore } from 'xterm'; +import { Terminal } from 'xterm'; import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon'; import { isWindows } from 'vs/base/common/platform'; +import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; -interface TestTerminalCore extends TerminalCore { +interface TestTerminalCore extends XTermCore { writeBuffer: string[]; _innerWrite(): void; } From 38d85b98badca67d3bfedb27889bc99cb799fee0 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 3 Sep 2019 11:36:48 -0700 Subject: [PATCH 030/204] Declare writeBuffer/_innerWrite access in .d.ts --- .../workbench/contrib/terminal/browser/xterm-private.d.ts | 5 +++++ .../test/electron-browser/terminalCommandTracker.test.ts | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts index 9ebf15d3032cc..6e41c9c5eee15 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts @@ -22,6 +22,11 @@ export interface XTermCore { }; _onIntersectionChange: any; }; + + // TODO: Remove below once a synchronous write API is added + // The below are only used in tests + writeBuffer: string[]; + _innerWrite(): void; } export interface IEventEmitter { diff --git a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts index e8d3fd143ee3f..f6198e4428c62 100644 --- a/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts +++ b/src/vs/workbench/contrib/terminal/test/electron-browser/terminalCommandTracker.test.ts @@ -9,13 +9,8 @@ import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addon import { isWindows } from 'vs/base/common/platform'; import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; -interface TestTerminalCore extends XTermCore { - writeBuffer: string[]; - _innerWrite(): void; -} - interface TestTerminal extends Terminal { - _core: TestTerminalCore; + _core: XTermCore; } function syncWrite(term: TestTerminal, data: string): void { From 1a404522c7d9f0095047faa0789518257787da77 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 3 Sep 2019 11:37:48 -0700 Subject: [PATCH 031/204] scrollOff ignoring single mouse clicking --- .../editor/browser/controller/coreCommands.ts | 30 +++++++++---------- .../browser/controller/textAreaHandler.ts | 1 + .../browser/viewParts/lines/viewLines.ts | 21 +++++++++---- .../browser/viewParts/minimap/minimap.ts | 1 + .../editor/browser/widget/codeEditorWidget.ts | 2 +- src/vs/editor/common/controller/cursor.ts | 20 ++++++------- .../editor/common/controller/cursorCommon.ts | 4 +-- src/vs/editor/common/view/viewEvents.ts | 8 ++++- .../editor/contrib/multicursor/multicursor.ts | 6 ++-- 9 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/vs/editor/browser/controller/coreCommands.ts b/src/vs/editor/browser/controller/coreCommands.ts index 193ff840ac4b0..bbef333e01099 100644 --- a/src/vs/editor/browser/controller/coreCommands.ts +++ b/src/vs/editor/browser/controller/coreCommands.ts @@ -294,7 +294,7 @@ export namespace CoreNavigationCommands { CursorMoveCommands.moveTo(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition) ] ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -322,7 +322,7 @@ export namespace CoreNavigationCommands { toViewLineNumber: result.toLineNumber, toViewVisualColumn: result.toVisualColumn }); - cursors.reveal(true, (result.reversed ? RevealTarget.TopMost : RevealTarget.BottomMost), ScrollType.Smooth); + cursors.reveal(args.source, true, (result.reversed ? RevealTarget.TopMost : RevealTarget.BottomMost), ScrollType.Smooth); } protected abstract _getColumnSelectResult(context: CursorContext, primary: CursorState, prevColumnSelectData: IColumnSelectData, args: any): IColumnSelectResult; @@ -492,7 +492,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.move(cursors.context, cursors.getAll(), args) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -831,7 +831,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.moveToBeginningOfLine(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -880,7 +880,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, this._exec(cursors.context, cursors.getAll()) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] { @@ -910,7 +910,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.moveToEndOfLine(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -959,7 +959,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, this._exec(cursors.context, cursors.getAll()) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] { @@ -990,7 +990,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.moveToBeginningOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -1034,7 +1034,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.moveToEndOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -1253,7 +1253,7 @@ export namespace CoreNavigationCommands { CursorMoveCommands.word(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position) ] ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } } @@ -1313,7 +1313,7 @@ export namespace CoreNavigationCommands { CursorMoveCommands.line(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition) ] ); - cursors.reveal(false, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, false, RevealTarget.Primary, ScrollType.Smooth); } } @@ -1385,7 +1385,7 @@ export namespace CoreNavigationCommands { CursorChangeReason.Explicit, CursorMoveCommands.expandLineSelection(cursors.context, cursors.getAll()) ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } }); @@ -1413,7 +1413,7 @@ export namespace CoreNavigationCommands { CursorMoveCommands.cancelSelection(cursors.context, cursors.getPrimaryCursor()) ] ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } }); @@ -1440,7 +1440,7 @@ export namespace CoreNavigationCommands { cursors.getPrimaryCursor() ] ); - cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); } }); @@ -1488,7 +1488,7 @@ export namespace CoreNavigationCommands { const viewRange = cursors.context.convertModelRangeToViewRange(range); - cursors.revealRange(false, viewRange, revealAt, ScrollType.Smooth); + cursors.revealRange(args.source, false, viewRange, revealAt, ScrollType.Smooth); } }); diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index c1a41a4981f49..97efaf60edacd 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -280,6 +280,7 @@ export class TextAreaHandler extends ViewPart { const column = this._selections[0].startColumn; this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent( + 'keyboard', new Range(lineNumber, column, lineNumber, column), viewEvents.VerticalRevealType.Simple, true, diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 580311d769117..64e82241b4d2f 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -12,6 +12,7 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v import { DomReadingContext, ViewLine, ViewLineOptions } from 'vs/editor/browser/viewParts/lines/viewLine'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; +import { Selection } from 'vs/editor/common/core/selection'; import { ScrollType } from 'vs/editor/common/editorCommon'; import { HorizontalRange, IViewLines, LineVisibleRanges } from 'vs/editor/common/view/renderingContext'; import { ViewContext } from 'vs/editor/common/view/viewContext'; @@ -71,6 +72,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, private _typicalHalfwidthCharacterWidth: number; private _isViewportWrapping: boolean; private _revealHorizontalRightPadding: number; + private _selections: Selection[]; private _scrollOff: number; private _canUseLayerHinting: boolean; private _viewLineOptions: ViewLineOptions; @@ -98,6 +100,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines; this._canUseLayerHinting = conf.editor.canUseLayerHinting; this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type); + this._selections = []; PartFingerprints.write(this.domNode, PartFingerprint.ViewLines); this.domNode.setClassName('view-lines'); @@ -188,6 +191,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, return false; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { + this._selections = e.selections; const rendStartLineNumber = this._visibleLines.getStartLineNumber(); const rendEndLineNumber = this._visibleLines.getEndLineNumber(); let r = false; @@ -223,7 +227,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, public onRevealRangeRequest(e: viewEvents.ViewRevealRangeRequestEvent): boolean { // Using the future viewport here in order to handle multiple // incoming reveal range requests that might all desire to be animated - const desiredScrollTop = this._computeScrollTopToRevealRange(this._context.viewLayout.getFutureViewport(), e.range, e.verticalType); + const desiredScrollTop = this._computeScrollTopToRevealRange(this._context.viewLayout.getFutureViewport(), e.source, e.range, e.verticalType); // validate the new desired scroll top let newScrollPosition = this._context.viewLayout.validateScrollPosition({ scrollTop: desiredScrollTop }); @@ -589,7 +593,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, } } - private _computeScrollTopToRevealRange(viewport: Viewport, range: Range, verticalType: viewEvents.VerticalRevealType): number { + private _computeScrollTopToRevealRange(viewport: Viewport, source: string, range: Range, verticalType: viewEvents.VerticalRevealType): number { const viewportStartY = viewport.top; const viewportHeight = viewport.height; const viewportEndY = viewportStartY + viewportHeight; @@ -600,9 +604,16 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, boxStartY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.startLineNumber); boxEndY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.endLineNumber) + this._lineHeight; - const context = Math.min((viewportHeight / this._lineHeight) / 2, this._scrollOff); - boxStartY -= context * this._lineHeight; - boxEndY += Math.max(0, (context - 1)) * this._lineHeight; + const shouldIgnoreScrollOff = source === 'mouse' && ( + this._selections.length > 1 // scroll off might trigger scrolling and mess up with multi cursor + || (this._selections.length > 0 && this._selections[0].isEmpty()) // we don't want to single click triggering selection + ); + + if (!shouldIgnoreScrollOff) { + const context = Math.min((viewportHeight / this._lineHeight) / 2, this._scrollOff); + boxStartY -= context * this._lineHeight; + boxEndY += Math.max(0, (context - 1)) * this._lineHeight; + } if (verticalType === viewEvents.VerticalRevealType.Simple || verticalType === viewEvents.VerticalRevealType.Bottom) { // Reveal one line more when the last line would be covered by the scrollbar - arrow down case or revealing a line explicitly at bottom diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 1182f2ee8ab98..1ef327eaee0fc 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -517,6 +517,7 @@ export class Minimap extends ViewPart { lineNumber = Math.min(lineNumber, this._context.model.getLineCount()); this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent( + 'mouse', new Range(lineNumber, 1, lineNumber, 1), viewEvents.VerticalRevealType.Center, false, diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 0ac879ee78a59..55a23e500c069 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -526,7 +526,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE const validatedModelRange = this._modelData.model.validateRange(modelRange); const viewRange = this._modelData.viewModel.coordinatesConverter.convertModelRangeToViewRange(validatedModelRange); - this._modelData.cursor.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType); + this._modelData.cursor.emitCursorRevealRange('api', viewRange, verticalType, revealHorizontal, scrollType); } public revealLine(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void { diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index b76218fe99bab..a49d3635759c5 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -295,12 +295,12 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._columnSelectData = columnSelectData; } - public reveal(horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void { - this._revealRange(target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType); + public reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void { + this._revealRange(source, target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType); } - public revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) { - this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType); + public revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) { + this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType); } public scrollTo(desiredScrollTop: number): void { @@ -371,7 +371,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { } this.setStates('restoreState', CursorChangeReason.NotSet, CursorState.fromModelSelections(desiredSelections)); - this.reveal(true, RevealTarget.Primary, editorCommon.ScrollType.Immediate); + this.reveal('restoreState', true, RevealTarget.Primary, editorCommon.ScrollType.Immediate); } private _onModelContentChanged(hadFlushEvent: boolean): void { @@ -543,7 +543,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return true; } - private _revealRange(revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void { + private _revealRange(source: string, revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void { const viewPositions = this._cursors.getViewPositions(); let viewPosition = viewPositions[0]; @@ -568,13 +568,13 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { } const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); - this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType); + this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType); } - public emitCursorRevealRange(viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) { + public emitCursorRevealRange(source: string, viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) { try { const eventsCollector = this._beginEmit(); - eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(viewRange, verticalType, revealHorizontal, scrollType)); + eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, verticalType, revealHorizontal, scrollType)); } finally { this._endEmit(); } @@ -748,7 +748,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._validateAutoClosedActions(); if (this._emitStateChangedIfNecessary(source, cursorChangeReason, oldState)) { - this._revealRange(RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); + this._revealRange(source, RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); } } diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 87c3878b61c31..8d95fadebcf4d 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -55,8 +55,8 @@ export interface ICursors { setColumnSelectData(columnSelectData: IColumnSelectData): void; setStates(source: string, reason: CursorChangeReason, states: PartialCursorState[] | null): void; - reveal(horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void; - revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void; + reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void; + revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void; scrollTo(desiredScrollTop: number): void; diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index 962579d3f0f62..67258c117e0e0 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -198,7 +198,13 @@ export class ViewRevealRangeRequestEvent { public readonly scrollType: ScrollType; - constructor(range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) { + /** + * Source of the call that caused the event. + */ + readonly source: string; + + constructor(source: string, range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) { + this.source = source; this.range = range; this.verticalType = verticalType; this.revealHorizontal = revealHorizontal; diff --git a/src/vs/editor/contrib/multicursor/multicursor.ts b/src/vs/editor/contrib/multicursor/multicursor.ts index ec0925af31ad2..aee06c601d9f3 100644 --- a/src/vs/editor/contrib/multicursor/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/multicursor.ts @@ -72,7 +72,7 @@ export class InsertCursorAbove extends EditorAction { CursorChangeReason.Explicit, CursorMoveCommands.addCursorUp(context, cursors.getAll(), useLogicalLine) ); - cursors.reveal(true, RevealTarget.TopMost, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.TopMost, ScrollType.Smooth); } } @@ -121,7 +121,7 @@ export class InsertCursorBelow extends EditorAction { CursorChangeReason.Explicit, CursorMoveCommands.addCursorDown(context, cursors.getAll(), useLogicalLine) ); - cursors.reveal(true, RevealTarget.BottomMost, ScrollType.Smooth); + cursors.reveal(args.source, true, RevealTarget.BottomMost, ScrollType.Smooth); } } @@ -1053,4 +1053,4 @@ registerEditorAction(MoveSelectionToPreviousFindMatchAction); registerEditorAction(SelectHighlightsAction); registerEditorAction(CompatChangeAll); registerEditorAction(InsertCursorAtEndOfLineSelected); -registerEditorAction(InsertCursorAtTopOfLineSelected); \ No newline at end of file +registerEditorAction(InsertCursorAtTopOfLineSelected); From 13b681eee0a78b8c3c393c764a8b37278b19285b Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Wed, 4 Sep 2019 03:44:19 +0900 Subject: [PATCH 032/204] HTTPS link to ux.stackexchange.com (#80255) saves a HTTP redirect --- src/vs/base/browser/ui/sash/sash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/base/browser/ui/sash/sash.ts b/src/vs/base/browser/ui/sash/sash.ts index ea4d43f5810f7..16279b74af908 100644 --- a/src/vs/base/browser/ui/sash/sash.ts +++ b/src/vs/base/browser/ui/sash/sash.ts @@ -143,7 +143,7 @@ export class Sash extends Disposable { this._register(domEvent(this.el, EventType.Start)(this.onTouchStart, this)); if (isIPad) { - // see also http://ux.stackexchange.com/questions/39023/what-is-the-optimum-button-size-of-touch-screen-applications + // see also https://ux.stackexchange.com/questions/39023/what-is-the-optimum-button-size-of-touch-screen-applications addClass(this.el, 'touch'); } From 051205018f9c254d4ba761014e03cefd57954756 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Sep 2019 20:55:26 +0200 Subject: [PATCH 033/204] Migrate more editor options --- src/vs/editor/browser/config/configuration.ts | 4 +- .../editor/browser/controller/mouseHandler.ts | 7 +- .../browser/controller/textAreaHandler.ts | 53 +- src/vs/editor/browser/view/viewController.ts | 5 +- src/vs/editor/browser/view/viewImpl.ts | 16 +- src/vs/editor/browser/view/viewOverlays.ts | 27 +- .../contentWidgets/contentWidgets.ts | 2 +- .../currentLineHighlight.ts | 24 +- .../currentLineMarginHighlight.ts | 25 +- .../viewParts/glyphMargin/glyphMargin.ts | 20 +- .../viewParts/indentGuides/indentGuides.ts | 33 +- .../viewParts/lineNumbers/lineNumbers.ts | 6 +- .../browser/viewParts/lines/viewLine.ts | 12 +- .../browser/viewParts/lines/viewLines.ts | 38 +- .../linesDecorations/linesDecorations.ts | 8 +- .../editor/browser/viewParts/margin/margin.ts | 17 +- .../browser/viewParts/minimap/minimap.ts | 3 +- .../overlayWidgets/overlayWidgets.ts | 17 +- .../overviewRuler/decorationsOverviewRuler.ts | 6 +- .../editor/browser/viewParts/rulers/rulers.ts | 16 +- .../scrollDecoration/scrollDecoration.ts | 29 +- .../viewParts/selections/selections.ts | 19 +- .../viewParts/viewCursors/viewCursor.ts | 25 +- .../viewParts/viewCursors/viewCursors.ts | 25 +- .../browser/viewParts/viewZones/viewZones.ts | 14 +- .../editor/browser/widget/codeEditorWidget.ts | 4 +- .../editor/browser/widget/diffEditorWidget.ts | 20 +- src/vs/editor/browser/widget/diffReview.ts | 26 +- .../common/config/commonEditorConfig.ts | 95 ++- src/vs/editor/common/config/editorOptions.ts | 666 ++++++------------ .../editor/common/controller/cursorCommon.ts | 36 +- .../common/standalone/standaloneEnums.ts | 92 ++- src/vs/editor/common/view/viewEvents.ts | 10 - src/vs/editor/common/viewLayout/viewLayout.ts | 8 +- src/vs/editor/contrib/clipboard/clipboard.ts | 7 +- src/vs/editor/contrib/dnd/dnd.ts | 5 +- src/vs/editor/contrib/find/findModel.ts | 13 +- .../goToDefinition/clickLinkGesture.ts | 7 +- .../editor/contrib/indentation/indentation.ts | 3 +- .../linesOperations/linesOperations.ts | 5 +- src/vs/editor/contrib/links/links.ts | 7 +- .../editor/contrib/multicursor/multicursor.ts | 13 +- .../wordHighlighter/wordHighlighter.ts | 3 +- .../contrib/wordOperations/wordOperations.ts | 16 +- src/vs/editor/editor.api.ts | 8 +- src/vs/monaco.d.ts | 204 +++--- .../workbench/api/browser/mainThreadEditor.ts | 7 +- .../browser/preferencesRenderers.ts | 5 +- .../quickopen/browser/gotoLineHandler.ts | 4 +- 49 files changed, 751 insertions(+), 964 deletions(-) diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts index cdb50af8be808..8e8a71d3345f5 100644 --- a/src/vs/editor/browser/config/configuration.ts +++ b/src/vs/editor/browser/config/configuration.ts @@ -11,7 +11,7 @@ import * as platform from 'vs/base/common/platform'; import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader'; import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver'; import { CommonEditorConfiguration, IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import { IDimension } from 'vs/editor/common/editorCommon'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; @@ -320,7 +320,7 @@ export class Configuration extends CommonEditorConfiguration { this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => this._onCSSBasedConfigurationChanged())); - if (this._validatedOptions.automaticLayout) { + if (this._validatedOptions2.get(EditorOption.automaticLayout)) { this._elementSizeObserver.startObserving(); } diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index f9b2f538465e2..dd8979daabc5f 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -113,7 +113,7 @@ export class MouseHandler extends ViewEventHandler { const onMouseWheel = (browserEvent: IMouseWheelEvent) => { this.viewController.emitMouseWheel(browserEvent); - if (!this._context.configuration.editor.viewInfo.mouseWheelZoom) { + if (!this._context.configuration.options.get(EditorOption.mouseWheelZoom)) { return; } const e = new StandardWheelEvent(browserEvent); @@ -354,10 +354,9 @@ class MouseDownOperation extends Disposable { e.detail = this._mouseState.count; const options = this._context.configuration.options; - const readOnly = options.get(EditorOption.readOnly); - if (!readOnly - && this._context.configuration.editor.dragAndDrop + if (!options.get(EditorOption.readOnly) + && options.get(EditorOption.dragAndDrop) && !this._mouseState.altKey // we don't support multiple mouse && e.detail < 2 // only single click on a selection can work && !this._isActive // the mouse is not down yet diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index 347cd523a817f..4919390e33b68 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -91,12 +91,13 @@ export class TextAreaHandler extends ViewPart { private readonly _viewController: ViewController; private readonly _viewHelper: ITextAreaHandlerHelper; + private _scrollLeft: number; + private _scrollTop: number; + private _accessibilitySupport: AccessibilitySupport; private _contentLeft: number; private _contentWidth: number; private _contentHeight: number; - private _scrollLeft: number; - private _scrollTop: number; private _fontInfo: BareFontInfo; private _lineHeight: number; private _emptySelectionClipboard: boolean; @@ -117,6 +118,8 @@ export class TextAreaHandler extends ViewPart { this._viewController = viewController; this._viewHelper = viewHelper; + this._scrollLeft = 0; + this._scrollTop = 0; const conf = this._context.configuration.editor; const options = this._context.configuration.options; @@ -126,12 +129,10 @@ export class TextAreaHandler extends ViewPart { this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; - this._scrollLeft = 0; - this._scrollTop = 0; this._fontInfo = conf.fontInfo; this._lineHeight = conf.lineHeight; - this._emptySelectionClipboard = conf.emptySelectionClipboard; - this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting; + this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); + this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); this._visibleTextArea = null; this._selections = [new Selection(1, 1, 1, 1)]; @@ -342,7 +343,7 @@ export class TextAreaHandler extends ViewPart { private _getWordBeforePosition(position: Position): string { const lineContent = this._context.model.getLineContent(position.lineNumber); - const wordSeparators = getMapForWordSeparators(this._context.configuration.editor.wordSeparators); + const wordSeparators = getMapForWordSeparators(this._context.configuration.options.get(EditorOption.wordSeparators)); let column = position.column; let distance = 0; @@ -374,32 +375,21 @@ export class TextAreaHandler extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const conf = this._context.configuration.editor; const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); + + this._accessibilitySupport = options.get(EditorOption.accessibilitySupport); + this._contentLeft = layoutInfo.contentLeft; + this._contentWidth = layoutInfo.contentWidth; + this._contentHeight = layoutInfo.contentHeight; + this._fontInfo = conf.fontInfo; + this._lineHeight = conf.lineHeight; + this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); + this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); + this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel)); - if (e.fontInfo) { - this._fontInfo = conf.fontInfo; - } - if (e.viewInfo) { - this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel)); - } - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentLeft = layoutInfo.contentLeft; - this._contentWidth = layoutInfo.contentWidth; - this._contentHeight = layoutInfo.contentHeight; - } - if (e.lineHeight) { - this._lineHeight = conf.lineHeight; - } if (e.hasChanged(EditorOption.accessibilitySupport)) { - this._accessibilitySupport = options.get(EditorOption.accessibilitySupport); this._textAreaInput.writeScreenReaderContent('strategy changed'); } - if (e.emptySelectionClipboard) { - this._emptySelectionClipboard = conf.emptySelectionClipboard; - } - if (e.copyWithSyntaxHighlighting) { - this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting; - } return true; } @@ -550,11 +540,10 @@ export class TextAreaHandler extends ViewPart { const options = this._context.configuration.options; - if (this._context.configuration.editor.viewInfo.glyphMargin) { + if (options.get(EditorOption.glyphMargin)) { tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME); } else { - const renderLineNumbers = options.get(EditorOption.renderLineNumbers); - if (renderLineNumbers.renderType !== RenderLineNumbersType.Off) { + if (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off) { tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME); } else { tac.setClassName('monaco-editor-background textAreaCover'); diff --git a/src/vs/editor/browser/view/viewController.ts b/src/vs/editor/browser/view/viewController.ts index 10fb2e1aa6b5c..610f54266f698 100644 --- a/src/vs/editor/browser/view/viewController.ts +++ b/src/vs/editor/browser/view/viewController.ts @@ -12,6 +12,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { IConfiguration } from 'vs/editor/common/editorCommon'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IMouseDispatchData { position: Position; @@ -107,7 +108,7 @@ export class ViewController { } private _hasMulticursorModifier(data: IMouseDispatchData): boolean { - switch (this.configuration.editor.multiCursorModifier) { + switch (this.configuration.options.get(EditorOption.multiCursorModifier)) { case 'altKey': return data.altKey; case 'ctrlKey': @@ -119,7 +120,7 @@ export class ViewController { } private _hasNonMulticursorModifier(data: IMouseDispatchData): boolean { - switch (this.configuration.editor.multiCursorModifier) { + switch (this.configuration.options.get(EditorOption.multiCursorModifier)) { case 'altKey': return data.ctrlKey || data.metaKey; case 'ctrlKey': diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 2a31441bc8641..9f2e96a1a38ac 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -220,7 +220,7 @@ export class View extends ViewEventHandler { this.domNode.appendChild(this.overflowGuardContainer); this.domNode.appendChild(this.contentWidgets.overflowingContentWidgetsDomNode); - this._setLayout(); + this._applyLayout(); // Pointer handler this.pointerHandler = this._register(new PointerHandler(this._context, viewController, this.createPointerHandlerHelper())); @@ -282,9 +282,10 @@ export class View extends ViewEventHandler { }; } - private _setLayout(): void { + private _applyLayout(): void { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); + this.domNode.setWidth(layoutInfo.width); this.domNode.setHeight(layoutInfo.height); @@ -293,23 +294,18 @@ export class View extends ViewEventHandler { this.linesContent.setWidth(1000000); this.linesContent.setHeight(1000000); - } private getEditorClassName() { const focused = this._textAreaHandler.isFocused() ? ' focused' : ''; - return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type) + focused; + return this._context.configuration.options.get(EditorOption.editorClassName) + ' ' + getThemeTypeSelector(this._context.theme.type) + focused; } // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.editorClassName) { - this.domNode.setClassName(this.getEditorClassName()); - } - if (e.hasChanged(EditorOption.layoutInfo)) { - this._setLayout(); - } + this.domNode.setClassName(this.getEditorClassName()); + this._applyLayout(); return false; } public onFocusChanged(e: viewEvents.ViewFocusChangedEvent): boolean { diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index bf7fed99d46a2..1145334be1775 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -227,12 +227,10 @@ export class ContentViewOverlays extends ViewOverlays { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentWidth = layoutInfo.contentWidth; - } - return super.onConfigurationChanged(e); + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); + this._contentWidth = layoutInfo.contentWidth; + return super.onConfigurationChanged(e) || true; } public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { return super.onScrollChanged(e) || e.scrollWidthChanged; @@ -265,18 +263,11 @@ export class MarginViewOverlays extends ViewOverlays { } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - let shouldRender = false; - if (e.fontInfo) { - Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); - shouldRender = true; - } - if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentLeft = layoutInfo.contentLeft; - shouldRender = true; - } - return super.onConfigurationChanged(e) || shouldRender; + Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); + this._contentLeft = layoutInfo.contentLeft; + return super.onConfigurationChanged(e) || true; } public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index 74ca7cbd66a6f..721a7ff2acb7a 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -212,7 +212,7 @@ class Widget { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets; + this._fixedOverflowWidgets = options.get(EditorOption.fixedOverflowWidgets); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; this._lineHeight = this._context.configuration.editor.lineHeight; diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index 41cb1c2080cd4..448aff03d52aa 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -17,25 +17,26 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; private _lineHeight: number; private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; + private _contentWidth: number; private _selectionIsEmpty: boolean; private _primaryCursorLineNumber: number; private _scrollWidth: number; - private _contentWidth: number; constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); this._lineHeight = this._context.configuration.editor.lineHeight; - this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; + this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); + this._contentWidth = layoutInfo.contentWidth; this._selectionIsEmpty = true; this._primaryCursorLineNumber = 1; this._scrollWidth = 0; - this._contentWidth = layoutInfo.contentWidth; this._context.addEventHandler(this); } @@ -48,17 +49,12 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.viewInfo) { - this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; - } - if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentWidth = layoutInfo.contentWidth; - } + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); + + this._lineHeight = this._context.configuration.editor.lineHeight; + this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); + this._contentWidth = layoutInfo.contentWidth; return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts index e6d01e2ebcf8e..17a473d86b4f8 100644 --- a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts @@ -17,21 +17,23 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { private readonly _context: ViewContext; private _lineHeight: number; private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; + private _contentLeft: number; private _selectionIsEmpty: boolean; private _primaryCursorLineNumber: number; - private _contentLeft: number; constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); + this._lineHeight = this._context.configuration.editor.lineHeight; - this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; + this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); + this._contentLeft = layoutInfo.contentLeft; this._selectionIsEmpty = true; this._primaryCursorLineNumber = 1; - this._contentLeft = layoutInfo.contentLeft; this._context.addEventHandler(this); } @@ -44,17 +46,12 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.viewInfo) { - this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight; - } - if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._context.configuration.options; - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentLeft = layoutInfo.contentLeft; - } + const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); + + this._lineHeight = this._context.configuration.editor.lineHeight; + this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); + this._contentLeft = layoutInfo.contentLeft; return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts index a402d430826db..7bc4e31bd2eb5 100644 --- a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts +++ b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts @@ -86,10 +86,12 @@ export class GlyphMarginOverlay extends DedupOverlay { constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); + this._lineHeight = this._context.configuration.editor.lineHeight; - this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; + this._glyphMargin = options.get(EditorOption.glyphMargin); this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; this._renderResult = null; @@ -106,18 +108,12 @@ export class GlyphMarginOverlay extends DedupOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.viewInfo) { - this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin; - } - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._glyphMarginLeft = layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = layoutInfo.glyphMarginWidth; - } + this._lineHeight = this._context.configuration.editor.lineHeight; + this._glyphMargin = options.get(EditorOption.glyphMargin); + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; return true; } public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index fb275d96ba3d2..705700fc6d6a5 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -29,14 +29,15 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { super(); this._context = context; this._primaryLineNumber = 0; + const options = this._context.configuration.options; + const wrappingInfo = options.get(EditorOption.wrappingInfo); + this._lineHeight = this._context.configuration.editor.lineHeight; this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; - this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; - this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; - const wrappingInfo = options.get(EditorOption.wrappingInfo); - const wrappingColumn = wrappingInfo.wrappingColumn; - this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); + this._enabled = options.get(EditorOption.renderIndentGuides); + this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); + this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); this._renderResult = null; @@ -53,21 +54,13 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.fontInfo) { - this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; - } - if (e.viewInfo) { - this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides; - this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide; - } - if (e.hasChanged(EditorOption.wrappingInfo) || e.fontInfo) { - const wrappingInfo = options.get(EditorOption.wrappingInfo); - const wrappingColumn = wrappingInfo.wrappingColumn; - this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); - } + const wrappingInfo = options.get(EditorOption.wrappingInfo); + + this._lineHeight = this._context.configuration.editor.lineHeight; + this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; + this._enabled = options.get(EditorOption.renderIndentGuides); + this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); + this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index 8673e31f1538b..1d5e650806252 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -44,9 +44,9 @@ export class LineNumbersOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const config = this._context.configuration.editor; this._lineHeight = config.lineHeight; - const renderLineNumbers = options.get(EditorOption.renderLineNumbers); - this._renderLineNumbers = renderLineNumbers.renderType; - this._renderCustomLineNumbers = renderLineNumbers.renderFn; + const lineNumbers = options.get(EditorOption.lineNumbers); + this._renderLineNumbers = lineNumbers.renderType; + this._renderCustomLineNumbers = lineNumbers.renderFn; this._renderFinalNewline = options.get(EditorOption.renderFinalNewline); const layoutInfo = options.get(EditorOption.layoutInfo); this._lineNumbersLeft = layoutInfo.lineNumbersLeft; diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index 00b684e7ef4b4..25e861bf9c685 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -16,6 +16,7 @@ import { CharacterMapping, ForeignElementType, RenderLineInput, renderViewLine, import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { InlineDecorationType } from 'vs/editor/common/viewModel/viewModel'; import { HIGH_CONTRAST, ThemeType } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const canUseFastRenderedViewLine = (function () { if (platform.isNative) { @@ -80,17 +81,18 @@ export class ViewLineOptions { constructor(config: IConfiguration, themeType: ThemeType) { this.themeType = themeType; - this.renderWhitespace = config.editor.viewInfo.renderWhitespace; - this.renderControlCharacters = config.editor.viewInfo.renderControlCharacters; + const options = config.options; + this.renderWhitespace = options.get(EditorOption.renderWhitespace); + this.renderControlCharacters = options.get(EditorOption.renderControlCharacters); this.spaceWidth = config.editor.fontInfo.spaceWidth; this.useMonospaceOptimizations = ( config.editor.fontInfo.isMonospace - && !config.editor.viewInfo.disableMonospaceOptimizations + && !options.get(EditorOption.disableMonospaceOptimizations) ); this.canUseHalfwidthRightwardsArrow = config.editor.fontInfo.canUseHalfwidthRightwardsArrow; this.lineHeight = config.editor.lineHeight; - this.stopRenderingLineAfter = config.editor.viewInfo.stopRenderingLineAfter; - this.fontLigatures = config.editor.viewInfo.fontLigatures; + this.stopRenderingLineAfter = options.get(EditorOption.stopRenderingLineAfter); + this.fontLigatures = options.get(EditorOption.fontLigatures); } public equals(other: ViewLineOptions): boolean { diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 7fff4453ba588..5eaf46c3eea23 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -72,7 +72,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, private _typicalHalfwidthCharacterWidth: number; private _isViewportWrapping: boolean; private _revealHorizontalRightPadding: number; - private _scrollOff: number; + private _cursorSurroundingLines: number; private _canUseLayerHinting: boolean; private _viewLineOptions: ViewLineOptions; @@ -97,9 +97,9 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._lineHeight = conf.editor.lineHeight; this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; this._isViewportWrapping = wrappingInfo.isViewportWrapping; - this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding; - this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines; - this._canUseLayerHinting = conf.editor.canUseLayerHinting; + this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); + this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines); + this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting); this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type); PartFingerprints.write(this.domNode, PartFingerprint.ViewLines); @@ -144,27 +144,15 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const conf = this._context.configuration; const options = this._context.configuration.options; + const wrappingInfo = options.get(EditorOption.wrappingInfo); - if (e.lineHeight) { - this._lineHeight = conf.editor.lineHeight; - } - if (e.fontInfo) { - this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; - } - if (e.hasChanged(EditorOption.wrappingInfo)) { - const wrappingInfo = options.get(EditorOption.wrappingInfo); - this._isViewportWrapping = wrappingInfo.isViewportWrapping; - } - if (e.viewInfo) { - this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding; - this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines; - } - if (e.canUseLayerHinting) { - this._canUseLayerHinting = conf.editor.canUseLayerHinting; - } - if (e.fontInfo) { - Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo); - } + this._lineHeight = conf.editor.lineHeight; + this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._isViewportWrapping = wrappingInfo.isViewportWrapping; + this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); + this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines); + this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting); + Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo); this._onOptionsMaybeChanged(); @@ -605,7 +593,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, boxStartY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.startLineNumber); boxEndY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.endLineNumber) + this._lineHeight; - const context = Math.min((viewportHeight / this._lineHeight) / 2, this._scrollOff); + const context = Math.min((viewportHeight / this._lineHeight) / 2, this._cursorSurroundingLines); boxStartY -= context * this._lineHeight; boxEndY += Math.max(0, (context - 1)) * this._lineHeight; diff --git a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts index c8ad48eb26f38..fc6a255eb8322 100644 --- a/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts +++ b/src/vs/editor/browser/viewParts/linesDecorations/linesDecorations.ts @@ -40,11 +40,9 @@ export class LinesDecorationsOverlay extends DedupOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._decorationsLeft = layoutInfo.decorationsLeft; - this._decorationsWidth = layoutInfo.decorationsWidth; - } + const layoutInfo = options.get(EditorOption.layoutInfo); + this._decorationsLeft = layoutInfo.decorationsLeft; + this._decorationsWidth = layoutInfo.decorationsWidth; return true; } public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/margin/margin.ts b/src/vs/editor/browser/viewParts/margin/margin.ts index 2710a194dd094..1208e3c56c9ab 100644 --- a/src/vs/editor/browser/viewParts/margin/margin.ts +++ b/src/vs/editor/browser/viewParts/margin/margin.ts @@ -28,7 +28,7 @@ export class Margin extends ViewPart { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; + this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting); this._contentLeft = layoutInfo.contentLeft; this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; @@ -57,17 +57,12 @@ export class Margin extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); - if (e.canUseLayerHinting) { - this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting; - } - - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentLeft = layoutInfo.contentLeft; - this._glyphMarginLeft = layoutInfo.glyphMarginLeft; - this._glyphMarginWidth = layoutInfo.glyphMarginWidth; - } + this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting); + this._contentLeft = layoutInfo.contentLeft; + this._glyphMarginLeft = layoutInfo.glyphMarginLeft; + this._glyphMarginWidth = layoutInfo.glyphMarginWidth; return true; } diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 7df0b183c3ca1..01d3721a1799f 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -110,11 +110,10 @@ class MinimapOptions { const options = configuration.options; const pixelRatio = configuration.editor.pixelRatio; const layoutInfo = options.get(EditorOption.layoutInfo); - const viewInfo = configuration.editor.viewInfo; const fontInfo = configuration.editor.fontInfo; this.renderMinimap = layoutInfo.renderMinimap | 0; - this.scrollBeyondLastLine = viewInfo.scrollBeyondLastLine; + this.scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine); const minimapOpts = options.get(EditorOption.minimap); this.showSlider = minimapOpts.showSlider; this.pixelRatio = pixelRatio; diff --git a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts index ba9128c06de90..925ed44d28ac1 100644 --- a/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts +++ b/src/vs/editor/browser/viewParts/overlayWidgets/overlayWidgets.ts @@ -65,17 +65,14 @@ export class ViewOverlayWidgets extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; - this._minimapWidth = layoutInfo.minimapWidth; - this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; - this._editorHeight = layoutInfo.height; - this._editorWidth = layoutInfo.width; - return true; - } - return false; + this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth; + this._minimapWidth = layoutInfo.minimapWidth; + this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight; + this._editorHeight = layoutInfo.height; + this._editorWidth = layoutInfo.width; + return true; } // ---- end view event handlers diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index 2f02db4df4350..7658dfbf33c95 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -46,13 +46,13 @@ class Settings { const options = config.options; this.lineHeight = config.editor.lineHeight; this.pixelRatio = config.editor.pixelRatio; - this.overviewRulerLanes = config.editor.viewInfo.overviewRulerLanes; + this.overviewRulerLanes = options.get(EditorOption.overviewRulerLanes); - this.renderBorder = config.editor.viewInfo.overviewRulerBorder; + this.renderBorder = options.get(EditorOption.overviewRulerBorder); const borderColor = theme.getColor(editorOverviewRulerBorder); this.borderColor = borderColor ? borderColor.toString() : null; - this.hideCursor = config.editor.viewInfo.hideCursorInOverviewRuler; + this.hideCursor = options.get(EditorOption.hideCursorInOverviewRuler); const cursorColor = theme.getColor(editorCursorForeground); this.cursorColor = cursorColor ? cursorColor.transparent(0.7).toString() : null; diff --git a/src/vs/editor/browser/viewParts/rulers/rulers.ts b/src/vs/editor/browser/viewParts/rulers/rulers.ts index 21981080a0ef5..3c9f9cf6bb543 100644 --- a/src/vs/editor/browser/viewParts/rulers/rulers.ts +++ b/src/vs/editor/browser/viewParts/rulers/rulers.ts @@ -27,7 +27,8 @@ export class Rulers extends ViewPart { this.domNode.setAttribute('aria-hidden', 'true'); this.domNode.setClassName('view-rulers'); this._renderedRulers = []; - this._rulers = this._context.configuration.editor.viewInfo.rulers; + const options = this._context.configuration.options; + this._rulers = options.get(EditorOption.rulers); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; } @@ -38,15 +39,10 @@ export class Rulers extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.viewInfo - || e.hasChanged(EditorOption.layoutInfo) - || e.fontInfo - ) { - this._rulers = this._context.configuration.editor.viewInfo.rulers; - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; - return true; - } - return false; + const options = this._context.configuration.options; + this._rulers = options.get(EditorOption.rulers); + this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + return true; } public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { return e.scrollHeightChanged; diff --git a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts index 7e516f8e221d9..8adefd837dd44 100644 --- a/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts +++ b/src/vs/editor/browser/viewParts/scrollDecoration/scrollDecoration.ts @@ -54,35 +54,26 @@ export class ScrollDecorationViewPart extends ViewPart { return this._domNode; } - private _updateWidth(): boolean { + private _updateWidth(): void { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - let newWidth = 0; + if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) { - newWidth = layoutInfo.width; + this._width = layoutInfo.width; } else { - newWidth = layoutInfo.width - layoutInfo.minimapWidth - layoutInfo.verticalScrollbarWidth; - } - if (this._width !== newWidth) { - this._width = newWidth; - return true; + this._width = layoutInfo.width - layoutInfo.minimapWidth - layoutInfo.verticalScrollbarWidth; } - return false; } // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - let shouldRender = false; - if (e.hasChanged(EditorOption.scrollbar)) { - const options = this._context.configuration.options; - const scrollbar = options.get(EditorOption.scrollbar); - this._useShadows = scrollbar.useShadows; - } - if (e.hasChanged(EditorOption.layoutInfo)) { - shouldRender = this._updateWidth(); - } - return this._updateShouldShow() || shouldRender; + const options = this._context.configuration.options; + const scrollbar = options.get(EditorOption.scrollbar); + this._useShadows = scrollbar.useShadows; + this._updateWidth(); + this._updateShouldShow(); + return true; } public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { this._scrollTop = e.scrollTop; diff --git a/src/vs/editor/browser/viewParts/selections/selections.ts b/src/vs/editor/browser/viewParts/selections/selections.ts index 3ee089a3d942b..1c1cd7fdd485c 100644 --- a/src/vs/editor/browser/viewParts/selections/selections.ts +++ b/src/vs/editor/browser/viewParts/selections/selections.ts @@ -12,6 +12,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { editorInactiveSelection, editorSelectionBackground, editorSelectionForeground } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const enum CornerStyle { EXTERN, @@ -83,8 +84,9 @@ export class SelectionsOverlay extends DynamicViewOverlay { constructor(context: ViewContext) { super(); this._context = context; + const options = this._context.configuration.options; this._lineHeight = this._context.configuration.editor.lineHeight; - this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection; + this._roundedSelection = options.get(EditorOption.roundedSelection); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this._selections = []; this._renderResult = null; @@ -100,15 +102,10 @@ export class SelectionsOverlay extends DynamicViewOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.viewInfo) { - this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection; - } - if (e.fontInfo) { - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; - } + const options = this._context.configuration.options; + this._lineHeight = this._context.configuration.editor.lineHeight; + this._roundedSelection = options.get(EditorOption.roundedSelection); + this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { @@ -420,4 +417,4 @@ registerThemingParticipant((theme, collector) => { function abs(n: number): number { return n < 0 ? -n : n; -} \ No newline at end of file +} diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index 3710527655756..491943b8fb68b 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -7,7 +7,7 @@ import * as dom from 'vs/base/browser/dom'; import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import * as strings from 'vs/base/common/strings'; import { Configuration } from 'vs/editor/browser/config/configuration'; -import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions'; +import { TextEditorCursorStyle, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; @@ -51,11 +51,12 @@ export class ViewCursor { constructor(context: ViewContext) { this._context = context; + const options = this._context.configuration.options; - this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; + this._cursorStyle = options.get(EditorOption.cursorStyle); this._lineHeight = this._context.configuration.editor.lineHeight; this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; - this._lineCursorWidth = Math.min(this._context.configuration.editor.viewInfo.cursorWidth, this._typicalHalfwidthCharacterWidth); + this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); this._isVisible = true; @@ -97,17 +98,13 @@ export class ViewCursor { } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } - if (e.fontInfo) { - Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; - } - if (e.viewInfo) { - this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; - this._lineCursorWidth = Math.min(this._context.configuration.editor.viewInfo.cursorWidth, this._typicalHalfwidthCharacterWidth); - } + const options = this._context.configuration.options; + + this._cursorStyle = options.get(EditorOption.cursorStyle); + this._lineHeight = this._context.configuration.editor.lineHeight; + this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); + Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); return true; } diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts index f9dc4932f760f..c60e020b56f07 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts @@ -45,9 +45,9 @@ export class ViewCursors extends ViewPart { const options = this._context.configuration.options; this._readOnly = options.get(EditorOption.readOnly); - this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; - this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; - this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation; + this._cursorBlinking = options.get(EditorOption.cursorBlinking); + this._cursorStyle = options.get(EditorOption.cursorStyle); + this._cursorSmoothCaretAnimation = options.get(EditorOption.cursorSmoothCaretAnimation); this._selectionIsEmpty = true; this._isVisible = false; @@ -87,20 +87,15 @@ export class ViewCursors extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - if (e.hasChanged(EditorOption.readOnly)) { - this._readOnly = options.get(EditorOption.readOnly); - } - if (e.viewInfo) { - this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking; - this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; - this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation; - } + this._readOnly = options.get(EditorOption.readOnly); + this._cursorBlinking = options.get(EditorOption.cursorBlinking); + this._cursorStyle = options.get(EditorOption.cursorStyle); + this._cursorSmoothCaretAnimation = options.get(EditorOption.cursorSmoothCaretAnimation); - this._primaryCursor.onConfigurationChanged(e); this._updateBlinking(); - if (e.viewInfo) { - this._updateDomClassName(); - } + this._updateDomClassName(); + + this._primaryCursor.onConfigurationChanged(e); for (let i = 0, len = this._secondaryCursors.length; i < len; i++) { this._secondaryCursors[i].onConfigurationChanged(e); } diff --git a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts index ed6976ba9fa53..8bac486f4bc94 100644 --- a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts +++ b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts @@ -90,16 +90,14 @@ export class ViewZones extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; + const layoutInfo = options.get(EditorOption.layoutInfo); - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - return this._recomputeWhitespacesProps(); - } + this._lineHeight = this._context.configuration.editor.lineHeight; + this._contentWidth = layoutInfo.contentWidth; + this._contentLeft = layoutInfo.contentLeft; - if (e.hasChanged(EditorOption.layoutInfo)) { - const layoutInfo = options.get(EditorOption.layoutInfo); - this._contentWidth = layoutInfo.contentWidth; - this._contentLeft = layoutInfo.contentLeft; + if (e.lineHeight) { + this._recomputeWhitespacesProps(); } return true; diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index cdc154e5521dd..65f10d2f316fd 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -259,12 +259,12 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._register(this._configuration.onDidChange((e) => { this._onDidChangeConfiguration.fire(e); + const options = this._configuration.options; if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); this._onDidLayoutChange.fire(layoutInfo); } - if (this._configuration.editor.showUnused) { + if (options.get(EditorOption.showUnused)) { this._domElement.classList.add(SHOW_UNUSED_ENABLED_CLASS); } else { this._domElement.classList.remove(SHOW_UNUSED_ENABLED_CLASS); diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index c07f9ec9552f9..fd704dbd5d2db 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -20,7 +20,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { DiffReview } from 'vs/editor/browser/widget/diffReview'; -import { IDiffEditorOptions, IEditorOptions, EDITOR_DEFAULTS, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { IDiffEditorOptions, IEditorOptions, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -996,7 +996,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE private _adjustOptionsForRightHandSide(options: IDiffEditorOptions): IEditorOptions { let result = this._adjustOptionsForSubEditor(options); - result.revealHorizontalRightPadding = EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH; + result.revealHorizontalRightPadding = EditorOptions.revealHorizontalRightPadding.defaultValue + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH; result.scrollbar!.verticalHasArrows = false; result.extraEditorClassName = 'modified-in-monaco-diff-editor'; return result; @@ -2003,7 +2003,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { let maxCharsPerLine = 0; const originalContent: string[] = []; for (let lineNumber = lineChange.originalStartLineNumber; lineNumber <= lineChange.originalEndLineNumber; lineNumber++) { - maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorConfiguration, this.modifiedEditorTabSize, lineNumber, decorations, sb)); + maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorConfiguration, this.modifiedEditorOptions, this.modifiedEditorTabSize, lineNumber, decorations, sb)); originalContent.push(this.originalModel.getLineContent(lineNumber)); if (this.renderIndicators) { @@ -2013,7 +2013,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { ]); } } - maxCharsPerLine += this.modifiedEditorConfiguration.viewInfo.scrollBeyondLastColumn; + maxCharsPerLine += this.modifiedEditorOptions.get(EditorOption.scrollBeyondLastColumn); let domNode = document.createElement('div'); domNode.className = 'view-lines line-delete'; @@ -2042,7 +2042,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { }; } - private _renderOriginalLine(count: number, originalModel: ITextModel, config: InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { + private _renderOriginalLine(count: number, originalModel: ITextModel, config: InternalEditorOptions, options: IComputedEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { const lineTokens = originalModel.getLineTokens(lineNumber); const lineContent = lineTokens.getLineContent(); @@ -2060,7 +2060,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, originalModel.mightContainNonBasicASCII()); const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, originalModel.mightContainRTL()); const output = renderViewLine(new RenderLineInput( - (config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations), + (config.fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), config.fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, @@ -2071,10 +2071,10 @@ class InlineViewZonesComputer extends ViewZonesComputer { actualDecorations, tabSize, config.fontInfo.spaceWidth, - config.viewInfo.stopRenderingLineAfter, - config.viewInfo.renderWhitespace, - config.viewInfo.renderControlCharacters, - config.viewInfo.fontLigatures, + options.get(EditorOption.stopRenderingLineAfter), + options.get(EditorOption.renderWhitespace), + options.get(EditorOption.renderControlCharacters), + options.get(EditorOption.fontLigatures), null // Send no selections, original line cannot be selected ), sb); diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index 63eba820ab8bf..c2b32e4c5ae65 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -17,7 +17,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { InternalEditorOptions, IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { LineTokens } from 'vs/editor/common/core/lineTokens'; import { Position } from 'vs/editor/common/core/position'; import { ILineChange, ScrollType } from 'vs/editor/common/editorCommon'; @@ -635,8 +635,8 @@ export class DiffReview extends Disposable { private static _renderSection( dest: HTMLElement, diffEntry: DiffEntry, modLine: number, width: number, - originalOpts: editorOptions.InternalEditorOptions, originalOptions: editorOptions.IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, - modifiedOpts: editorOptions.InternalEditorOptions, modifiedOptions: editorOptions.IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions + originalOpts: InternalEditorOptions, originalOptions: IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, + modifiedOpts: InternalEditorOptions, modifiedOptions: IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions ): void { const type = diffEntry.getType(); @@ -667,10 +667,10 @@ export class DiffReview extends Disposable { originalLineEnd - originalLineStart ); - const originalLayoutInfo = originalOptions.get(editorOptions.EditorOption.layoutInfo); + const originalLayoutInfo = originalOptions.get(EditorOption.layoutInfo); const originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth; - const modifiedLayoutInfo = modifiedOptions.get(editorOptions.EditorOption.layoutInfo); + const modifiedLayoutInfo = modifiedOptions.get(EditorOption.layoutInfo); const modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth; for (let i = 0; i <= cnt; i++) { @@ -721,12 +721,12 @@ export class DiffReview extends Disposable { let lineContent: string; if (modifiedLine !== 0) { cell.insertAdjacentHTML('beforeend', - this._renderLine(modifiedModel, modifiedOpts, modifiedModelOpts.tabSize, modifiedLine) + this._renderLine(modifiedModel, modifiedOpts, modifiedOptions, modifiedModelOpts.tabSize, modifiedLine) ); lineContent = modifiedModel.getLineContent(modifiedLine); } else { cell.insertAdjacentHTML('beforeend', - this._renderLine(originalModel, originalOpts, originalModelOpts.tabSize, originalLine) + this._renderLine(originalModel, originalOpts, originalOptions, originalModelOpts.tabSize, originalLine) ); lineContent = originalModel.getLineContent(originalLine); } @@ -753,7 +753,7 @@ export class DiffReview extends Disposable { } } - private static _renderLine(model: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number): string { + private static _renderLine(model: ITextModel, config: InternalEditorOptions, options: IComputedEditorOptions, tabSize: number, lineNumber: number): string { const lineContent = model.getLineContent(lineNumber); const defaultMetadata = ( @@ -771,7 +771,7 @@ export class DiffReview extends Disposable { const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, model.mightContainNonBasicASCII()); const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, model.mightContainRTL()); const r = renderViewLine(new RenderLineInput( - (config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations), + (config.fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), config.fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, @@ -782,10 +782,10 @@ export class DiffReview extends Disposable { [], tabSize, config.fontInfo.spaceWidth, - config.viewInfo.stopRenderingLineAfter, - config.viewInfo.renderWhitespace, - config.viewInfo.renderControlCharacters, - config.viewInfo.fontLigatures, + options.get(EditorOption.stopRenderingLineAfter), + options.get(EditorOption.renderWhitespace), + options.get(EditorOption.renderControlCharacters), + options.get(EditorOption.fontLigatures), null )); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 433788372bd8e..df3551bfebd98 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; -import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, blinkingStyleToString, cursorStyleToString } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -129,6 +129,32 @@ function migrateOptions(options: IEditorOptions): void { } else if (lineNumbers === false) { options.lineNumbers = 'off'; } + + let autoClosingBrackets = options.autoClosingBrackets; + if (autoClosingBrackets === false) { + options.autoClosingBrackets = 'never'; + options.autoClosingQuotes = 'never'; + options.autoSurround = 'never'; + } + + let cursorBlinking = options.cursorBlinking; + if (cursorBlinking === 'visible') { + options.cursorBlinking = 'solid'; + } + + let renderWhitespace = options.renderWhitespace; + if (renderWhitespace === true) { + options.renderWhitespace = 'boundary'; + } else if (renderWhitespace === false) { + options.renderWhitespace = 'none'; + } + + let renderLineHighlight = options.renderLineHighlight; + if (renderLineHighlight === true) { + options.renderLineHighlight = 'line'; + } else if (renderLineHighlight === false) { + options.renderLineHighlight = 'none'; + } } export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { @@ -144,7 +170,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed public readonly onDidChange: Event = this._onDidChange.event; private _rawOptions2: RawEditorOptions; - private _validatedOptions2: ValidatedEditorOptions; + protected _validatedOptions2: ValidatedEditorOptions; public options!: ComputedEditorOptions; constructor(isSimpleWidget: boolean, options: IEditorOptions) { @@ -358,7 +384,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.cursorSurroundingLines': { 'type': 'number', - 'default': EDITOR_DEFAULTS.viewInfo.cursorSurroundingLines, + 'default': EditorOptions.cursorSurroundingLines.defaultValue, 'description': nls.localize('cursorSurroundingLines', "Controls the minimal number of visible leading and trailing lines surrounding the cursor. Known as 'scrollOff' or `scrollOffset` in some other editors.") }, 'editor.renderFinalNewline': { @@ -371,12 +397,12 @@ const editorConfiguration: IConfigurationNode = { 'items': { 'type': 'number' }, - 'default': EDITOR_DEFAULTS.viewInfo.rulers, + 'default': EditorOptions.rulers.defaultValue, 'description': nls.localize('rulers', "Render vertical rulers after a certain number of monospace characters. Use multiple values for multiple rulers. No rulers are drawn if array is empty.") }, 'editor.wordSeparators': { 'type': 'string', - 'default': EDITOR_DEFAULTS.wordSeparators, + 'default': EditorOptions.wordSeparators.defaultValue, 'description': nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations.") }, 'editor.tabSize': { @@ -411,22 +437,22 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.roundedSelection': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.roundedSelection, + 'default': EditorOptions.roundedSelection.defaultValue, 'description': nls.localize('roundedSelection', "Controls whether selections should have rounded corners.") }, 'editor.scrollBeyondLastLine': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastLine, + 'default': EditorOptions.scrollBeyondLastLine.defaultValue, 'description': nls.localize('scrollBeyondLastLine', "Controls whether the editor will scroll beyond the last line.") }, 'editor.scrollBeyondLastColumn': { 'type': 'number', - 'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastColumn, + 'default': EditorOptions.scrollBeyondLastColumn.defaultValue, 'description': nls.localize('scrollBeyondLastColumn', "Controls the number of extra characters beyond which the editor will scroll horizontally.") }, 'editor.smoothScrolling': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.smoothScrolling, + 'default': EditorOptions.smoothScrolling.defaultValue, 'description': nls.localize('smoothScrolling', "Controls whether the editor will scroll using an animation.") }, 'editor.minimap.enabled': { @@ -573,7 +599,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.multiCursorMergeOverlapping': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.multiCursorMergeOverlapping, + 'default': EditorOptions.multiCursorMergeOverlapping.defaultValue, 'description': nls.localize('multiCursorMergeOverlapping', "Merge multiple cursors when they are overlapping.") }, 'editor.quickSuggestions': { @@ -629,9 +655,8 @@ const editorConfiguration: IConfigurationNode = { nls.localize('editor.autoClosingBrackets.languageDefined', "Use language configurations to determine when to autoclose brackets."), nls.localize('editor.autoClosingBrackets.beforeWhitespace', "Autoclose brackets only when the cursor is to the left of whitespace."), '', - ], - 'default': EDITOR_DEFAULTS.autoClosingBrackets, + 'default': EditorOptions.autoClosingBrackets.defaultValue, 'description': nls.localize('autoClosingBrackets', "Controls whether the editor should automatically close brackets after the user adds an opening bracket.") }, 'editor.autoClosingQuotes': { @@ -643,7 +668,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('editor.autoClosingQuotes.beforeWhitespace', "Autoclose quotes only when the cursor is to the left of whitespace."), '', ], - 'default': EDITOR_DEFAULTS.autoClosingQuotes, + 'default': EditorOptions.autoClosingQuotes.defaultValue, 'description': nls.localize('autoClosingQuotes', "Controls whether the editor should automatically close quotes after the user adds an opening quote.") }, 'editor.autoClosingOvertype': { @@ -654,7 +679,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('editor.autoClosingOvertype.auto', "Type over closing quotes or brackets only if they were automatically inserted."), nls.localize('editor.autoClosingOvertype.never', "Never type over closing quotes or brackets."), ], - 'default': EDITOR_DEFAULTS.autoClosingOvertype, + 'default': EditorOptions.autoClosingOvertype.defaultValue, 'description': nls.localize('autoClosingOvertype', "Controls whether the editor should type over closing quotes or brackets.") }, 'editor.autoSurround': { @@ -666,7 +691,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('editor.autoSurround.quotes', "Surround with quotes but not brackets."), '' ], - 'default': EDITOR_DEFAULTS.autoSurround, + 'default': EditorOptions.autoSurround.defaultValue, 'description': nls.localize('autoSurround', "Controls whether the editor should automatically surround selections.") }, 'editor.formatOnType': { @@ -681,7 +706,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.autoIndent': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.autoIndent, + 'default': EditorOptions.autoIndent.defaultValue, 'description': nls.localize('autoIndent', "Controls whether the editor should automatically adjust the indentation when users type, paste or move lines. Extensions with indentation rules of the language must be available.") }, 'editor.suggestOnTriggerCharacters': { @@ -719,12 +744,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.emptySelectionClipboard': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.emptySelectionClipboard, + 'default': EditorOptions.emptySelectionClipboard.defaultValue, 'description': nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.") }, 'editor.copyWithSyntaxHighlighting': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.copyWithSyntaxHighlighting, + 'default': EditorOptions.copyWithSyntaxHighlighting.defaultValue, 'description': nls.localize('copyWithSyntaxHighlighting', "Controls whether syntax highlighting should be copied into the clipboard.") }, 'editor.wordBasedSuggestions': { @@ -963,44 +988,44 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.overviewRulerBorder': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.overviewRulerBorder, + 'default': EditorOptions.overviewRulerBorder.defaultValue, 'description': nls.localize('overviewRulerBorder', "Controls whether a border should be drawn around the overview ruler.") }, 'editor.cursorBlinking': { 'type': 'string', 'enum': ['blink', 'smooth', 'phase', 'expand', 'solid'], - 'default': blinkingStyleToString(EDITOR_DEFAULTS.viewInfo.cursorBlinking), + 'default': EditorOptions.cursorBlinking.defaultValue, 'description': nls.localize('cursorBlinking', "Control the cursor animation style.") }, 'editor.mouseWheelZoom': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.mouseWheelZoom, + 'default': EditorOptions.mouseWheelZoom.defaultValue, 'markdownDescription': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding `Ctrl`.") }, 'editor.cursorSmoothCaretAnimation': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.cursorSmoothCaretAnimation, + 'default': EditorOptions.cursorSmoothCaretAnimation.defaultValue, 'description': nls.localize('cursorSmoothCaretAnimation', "Controls whether the smooth caret animation should be enabled.") }, 'editor.cursorStyle': { 'type': 'string', 'enum': ['block', 'block-outline', 'line', 'line-thin', 'underline', 'underline-thin'], - 'default': cursorStyleToString(EDITOR_DEFAULTS.viewInfo.cursorStyle), + 'default': EditorOptions.cursorStyle.defaultValue, 'description': nls.localize('cursorStyle', "Controls the cursor style.") }, 'editor.cursorWidth': { 'type': 'integer', - 'default': EDITOR_DEFAULTS.viewInfo.cursorWidth, + 'default': EditorOptions.cursorWidth.defaultValue, 'markdownDescription': nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.") }, 'editor.fontLigatures': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.fontLigatures, + 'default': EditorOptions.fontLigatures.defaultValue, 'description': nls.localize('fontLigatures', "Enables/Disables font ligatures.") }, 'editor.hideCursorInOverviewRuler': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.hideCursorInOverviewRuler, + 'default': EditorOptions.hideCursorInOverviewRuler.defaultValue, 'description': nls.localize('hideCursorInOverviewRuler', "Controls whether the cursor should be hidden in the overview ruler.") }, 'editor.renderWhitespace': { @@ -1012,22 +1037,22 @@ const editorConfiguration: IConfigurationNode = { nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."), '' ], - default: EDITOR_DEFAULTS.viewInfo.renderWhitespace, + default: EditorOptions.renderWhitespace.defaultValue, description: nls.localize('renderWhitespace', "Controls how the editor should render whitespace characters.") }, 'editor.renderControlCharacters': { 'type': 'boolean', - default: EDITOR_DEFAULTS.viewInfo.renderControlCharacters, + default: EditorOptions.renderControlCharacters.defaultValue, description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters.") }, 'editor.renderIndentGuides': { 'type': 'boolean', - default: EDITOR_DEFAULTS.viewInfo.renderIndentGuides, + default: EditorOptions.renderIndentGuides.defaultValue, description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides.") }, 'editor.highlightActiveIndentGuide': { 'type': 'boolean', - default: EDITOR_DEFAULTS.viewInfo.highlightActiveIndentGuide, + default: EditorOptions.highlightActiveIndentGuide.defaultValue, description: nls.localize('highlightActiveIndentGuide', "Controls whether the editor should highlight the active indent guide.") }, 'editor.renderLineHighlight': { @@ -1039,7 +1064,7 @@ const editorConfiguration: IConfigurationNode = { '', nls.localize('renderLineHighlight.all', "Highlights both the gutter and the current line."), ], - default: EDITOR_DEFAULTS.viewInfo.renderLineHighlight, + default: EditorOptions.renderLineHighlight.defaultValue, description: nls.localize('renderLineHighlight', "Controls how the editor should render the current line highlight.") }, 'editor.codeLens': { @@ -1071,12 +1096,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.glyphMargin': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.viewInfo.glyphMargin, + 'default': EditorOptions.glyphMargin.defaultValue, 'description': nls.localize('glyphMargin', "Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.") }, 'editor.useTabStops': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.useTabStops, + 'default': EditorOptions.useTabStops.defaultValue, 'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops.") }, 'editor.trimAutoWhitespace': { @@ -1091,7 +1116,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.dragAndDrop': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.dragAndDrop, + 'default': EditorOptions.dragAndDrop.defaultValue, 'description': nls.localize('dragAndDrop', "Controls whether the editor should allow moving selections via drag and drop.") }, 'editor.accessibilitySupport': { @@ -1107,7 +1132,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.showUnused': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.showUnused, + 'default': EditorOptions.showUnused.defaultValue, 'description': nls.localize('showUnused', "Controls fading out of unused code.") }, 'editor.links': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 653d28714e3db..d3eeb2ec5c2d1 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -357,7 +357,7 @@ export interface IEditorOptions { * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'. * Defaults to 'blink'. */ - cursorBlinking?: string; + cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'; /** * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. * Defaults to false. @@ -378,7 +378,7 @@ export interface IEditorOptions { * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. */ - cursorStyle?: string; + cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'; /** * Control the width of the cursor when cursorStyle is set to 'line' */ @@ -729,6 +729,11 @@ export interface IEditorOptions { */ showUnused?: boolean; + /** + * Do not use. + * @internal + */ + editorClassName?: undefined; /** * Do not use. * @internal @@ -836,24 +841,6 @@ export const enum TextEditorCursorBlinkingStyle { */ Solid = 5 } -/** - * @internal - */ -export function blinkingStyleToString(blinkingStyle: TextEditorCursorBlinkingStyle): string { - if (blinkingStyle === TextEditorCursorBlinkingStyle.Blink) { - return 'blink'; - } else if (blinkingStyle === TextEditorCursorBlinkingStyle.Expand) { - return 'expand'; - } else if (blinkingStyle === TextEditorCursorBlinkingStyle.Phase) { - return 'phase'; - } else if (blinkingStyle === TextEditorCursorBlinkingStyle.Smooth) { - return 'smooth'; - } else if (blinkingStyle === TextEditorCursorBlinkingStyle.Solid) { - return 'solid'; - } else { - throw new Error('blinkingStyleToString: Unknown blinkingStyle'); - } -} /** * The style in which the editor's cursor should be rendered. @@ -888,42 +875,38 @@ export enum TextEditorCursorStyle { /** * @internal */ -export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): string { - if (cursorStyle === TextEditorCursorStyle.Line) { - return 'line'; - } else if (cursorStyle === TextEditorCursorStyle.Block) { - return 'block'; - } else if (cursorStyle === TextEditorCursorStyle.Underline) { - return 'underline'; - } else if (cursorStyle === TextEditorCursorStyle.LineThin) { - return 'line-thin'; - } else if (cursorStyle === TextEditorCursorStyle.BlockOutline) { - return 'block-outline'; - } else if (cursorStyle === TextEditorCursorStyle.UnderlineThin) { - return 'underline-thin'; - } else { - throw new Error('cursorStyleToString: Unknown cursorStyle'); - } -} - -function _cursorStyleFromString(cursorStyle: string | undefined, defaultValue: TextEditorCursorStyle): TextEditorCursorStyle { - if (typeof cursorStyle !== 'string') { - return defaultValue; +export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' { + switch (cursorStyle) { + case TextEditorCursorStyle.Line: + return 'line'; + case TextEditorCursorStyle.Block: + return 'block'; + case TextEditorCursorStyle.Underline: + return 'underline'; + case TextEditorCursorStyle.LineThin: + return 'line-thin'; + case TextEditorCursorStyle.BlockOutline: + return 'block-outline'; + case TextEditorCursorStyle.UnderlineThin: + return 'underline-thin'; + } +} + +function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle { + switch (cursorStyle) { + case 'line': + return TextEditorCursorStyle.Line; + case 'block': + return TextEditorCursorStyle.Block; + case 'underline': + return TextEditorCursorStyle.Underline; + case 'line-thin': + return TextEditorCursorStyle.LineThin; + case 'block-outline': + return TextEditorCursorStyle.BlockOutline; + case 'underline-thin': + return TextEditorCursorStyle.UnderlineThin; } - if (cursorStyle === 'line') { - return TextEditorCursorStyle.Line; - } else if (cursorStyle === 'block') { - return TextEditorCursorStyle.Block; - } else if (cursorStyle === 'underline') { - return TextEditorCursorStyle.Underline; - } else if (cursorStyle === 'line-thin') { - return TextEditorCursorStyle.LineThin; - } else if (cursorStyle === 'block-outline') { - return TextEditorCursorStyle.BlockOutline; - } else if (cursorStyle === 'underline-thin') { - return TextEditorCursorStyle.UnderlineThin; - } - return TextEditorCursorStyle.Line; } export interface InternalEditorFindOptions { @@ -962,35 +945,6 @@ export interface InternalParameterHintOptions { readonly cycle: boolean; } -export interface InternalEditorViewOptions { - readonly extraEditorClassName: string; - readonly disableMonospaceOptimizations: boolean; - readonly rulers: number[]; - readonly cursorSurroundingLines: number; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: number; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: number; - readonly overviewRulerBorder: boolean; - readonly cursorBlinking: TextEditorCursorBlinkingStyle; - readonly mouseWheelZoom: boolean; - readonly cursorSmoothCaretAnimation: boolean; - readonly cursorStyle: TextEditorCursorStyle; - readonly cursorWidth: number; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly scrollBeyondLastColumn: number; - readonly smoothScrolling: boolean; - readonly stopRenderingLineAfter: number; - readonly renderWhitespace: 'none' | 'boundary' | 'selection' | 'all'; - readonly renderControlCharacters: boolean; - readonly fontLigatures: boolean; - readonly renderIndentGuides: boolean; - readonly highlightActiveIndentGuide: boolean; - readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly fixedOverflowWidgets: boolean; -} - export interface EditorContribOptions { readonly hover: InternalEditorHoverOptions; readonly links: boolean; @@ -1029,25 +983,6 @@ export interface EditorContribOptions { * @internal */ export interface IValidatedEditorOptions { - readonly wordSeparators: string; - readonly lineDecorationsWidth: number | string; - readonly mouseStyle: 'text' | 'default' | 'copy'; - readonly disableLayerHinting: boolean; - readonly automaticLayout: boolean; - readonly autoClosingBrackets: EditorAutoClosingStrategy; - readonly autoClosingQuotes: EditorAutoClosingStrategy; - readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy; - readonly autoSurround: EditorAutoSurroundStrategy; - readonly autoIndent: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; - readonly useTabStops: boolean; - readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; - readonly multiCursorMergeOverlapping: boolean; - readonly showUnused: boolean; - - readonly viewInfo: InternalEditorViewOptions; readonly contribInfo: EditorContribOptions; } @@ -1057,76 +992,26 @@ export interface IValidatedEditorOptions { export class InternalEditorOptions { readonly _internalEditorOptionsBrand: void; - readonly canUseLayerHinting: boolean; readonly pixelRatio: number; - readonly editorClassName: string; readonly lineHeight: number; - readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; - readonly multiCursorMergeOverlapping: boolean; - readonly showUnused: boolean; - - // ---- cursor options - readonly wordSeparators: string; - readonly autoClosingBrackets: EditorAutoClosingStrategy; - readonly autoClosingQuotes: EditorAutoClosingStrategy; - readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy; - readonly autoSurround: EditorAutoSurroundStrategy; - readonly autoIndent: boolean; - readonly useTabStops: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; // ---- grouped options readonly fontInfo: FontInfo; - readonly viewInfo: InternalEditorViewOptions; readonly contribInfo: EditorContribOptions; /** * @internal */ constructor(source: { - canUseLayerHinting: boolean; pixelRatio: number; - editorClassName: string; lineHeight: number; - multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; - multiCursorMergeOverlapping: boolean; - wordSeparators: string; - autoClosingBrackets: EditorAutoClosingStrategy; - autoClosingQuotes: EditorAutoClosingStrategy; - autoClosingOvertype: EditorAutoClosingOvertypeStrategy; - autoSurround: EditorAutoSurroundStrategy; - autoIndent: boolean; - useTabStops: boolean; - dragAndDrop: boolean; - emptySelectionClipboard: boolean; - copyWithSyntaxHighlighting: boolean; fontInfo: FontInfo; - viewInfo: InternalEditorViewOptions; contribInfo: EditorContribOptions; - showUnused: boolean; }) { - this.canUseLayerHinting = source.canUseLayerHinting; this.pixelRatio = source.pixelRatio; - this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight | 0; - this.multiCursorModifier = source.multiCursorModifier; - this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping; - this.wordSeparators = source.wordSeparators; - this.autoClosingBrackets = source.autoClosingBrackets; - this.autoClosingQuotes = source.autoClosingQuotes; - this.autoClosingOvertype = source.autoClosingOvertype; - this.autoSurround = source.autoSurround; - this.autoIndent = source.autoIndent; - this.useTabStops = source.useTabStops; - this.dragAndDrop = source.dragAndDrop; - this.emptySelectionClipboard = source.emptySelectionClipboard; - this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; this.fontInfo = source.fontInfo; - this.viewInfo = source.viewInfo; this.contribInfo = source.contribInfo; - this.showUnused = source.showUnused; } /** @@ -1134,25 +1019,9 @@ export class InternalEditorOptions { */ public equals(other: InternalEditorOptions): boolean { return ( - this.canUseLayerHinting === other.canUseLayerHinting - && this.pixelRatio === other.pixelRatio - && this.editorClassName === other.editorClassName + this.pixelRatio === other.pixelRatio && this.lineHeight === other.lineHeight - && this.multiCursorModifier === other.multiCursorModifier - && this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping - && this.wordSeparators === other.wordSeparators - && this.autoClosingBrackets === other.autoClosingBrackets - && this.autoClosingQuotes === other.autoClosingQuotes - && this.autoClosingOvertype === other.autoClosingOvertype - && this.autoSurround === other.autoSurround - && this.autoIndent === other.autoIndent - && this.useTabStops === other.useTabStops - && this.dragAndDrop === other.dragAndDrop - && this.showUnused === other.showUnused - && this.emptySelectionClipboard === other.emptySelectionClipboard - && this.copyWithSyntaxHighlighting === other.copyWithSyntaxHighlighting && this.fontInfo.equals(other.fontInfo) - && InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo) && InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo) ); } @@ -1168,62 +1037,13 @@ export class InternalEditorOptions { } return changeEvent.get(id); }, - canUseLayerHinting: (this.canUseLayerHinting !== newOpts.canUseLayerHinting), pixelRatio: (this.pixelRatio !== newOpts.pixelRatio), - editorClassName: (this.editorClassName !== newOpts.editorClassName), lineHeight: (this.lineHeight !== newOpts.lineHeight), - multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier), - multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping), - wordSeparators: (this.wordSeparators !== newOpts.wordSeparators), - autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets), - autoClosingQuotes: (this.autoClosingQuotes !== newOpts.autoClosingQuotes), - autoClosingOvertype: (this.autoClosingOvertype !== newOpts.autoClosingOvertype), - autoSurround: (this.autoSurround !== newOpts.autoSurround), - autoIndent: (this.autoIndent !== newOpts.autoIndent), - useTabStops: (this.useTabStops !== newOpts.useTabStops), - dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop), - emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard), - copyWithSyntaxHighlighting: (this.copyWithSyntaxHighlighting !== newOpts.copyWithSyntaxHighlighting), fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), - viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)), contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo)) }; } - /** - * @internal - */ - private static _equalsViewOptions(a: InternalEditorViewOptions, b: InternalEditorViewOptions): boolean { - return ( - a.extraEditorClassName === b.extraEditorClassName - && a.disableMonospaceOptimizations === b.disableMonospaceOptimizations - && arrays.equals(a.rulers, b.rulers) - && a.cursorSurroundingLines === b.cursorSurroundingLines - && a.glyphMargin === b.glyphMargin - && a.revealHorizontalRightPadding === b.revealHorizontalRightPadding - && a.roundedSelection === b.roundedSelection - && a.overviewRulerLanes === b.overviewRulerLanes - && a.overviewRulerBorder === b.overviewRulerBorder - && a.cursorBlinking === b.cursorBlinking - && a.mouseWheelZoom === b.mouseWheelZoom - && a.cursorSmoothCaretAnimation === b.cursorSmoothCaretAnimation - && a.cursorStyle === b.cursorStyle - && a.cursorWidth === b.cursorWidth - && a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler - && a.scrollBeyondLastLine === b.scrollBeyondLastLine - && a.scrollBeyondLastColumn === b.scrollBeyondLastColumn - && a.smoothScrolling === b.smoothScrolling - && a.stopRenderingLineAfter === b.stopRenderingLineAfter - && a.renderWhitespace === b.renderWhitespace - && a.renderControlCharacters === b.renderControlCharacters - && a.fontLigatures === b.fontLigatures - && a.renderIndentGuides === b.renderIndentGuides - && a.highlightActiveIndentGuide === b.highlightActiveIndentGuide - && a.renderLineHighlight === b.renderLineHighlight - && a.fixedOverflowWidgets === b.fixedOverflowWidgets - ); - } - /** * @internal */ @@ -1347,24 +1167,9 @@ export class InternalEditorOptions { */ export interface IConfigurationChangedEvent { hasChanged(id: EditorOption): boolean; - readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; - readonly editorClassName: boolean; readonly lineHeight: boolean; - readonly multiCursorModifier: boolean; - readonly multiCursorMergeOverlapping: boolean; - readonly wordSeparators: boolean; - readonly autoClosingBrackets: boolean; - readonly autoClosingQuotes: boolean; - readonly autoClosingOvertype: boolean; - readonly autoSurround: boolean; - readonly autoIndent: boolean; - readonly useTabStops: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; readonly fontInfo: boolean; - readonly viewInfo: boolean; readonly contribInfo: boolean; } @@ -1456,10 +1261,7 @@ function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | } } -function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string | undefined, defaultValue: TextEditorCursorBlinkingStyle): TextEditorCursorBlinkingStyle { - if (typeof cursorBlinkingStyle !== 'string') { - return defaultValue; - } +function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle { switch (cursorBlinkingStyle) { case 'blink': return TextEditorCursorBlinkingStyle.Blink; @@ -1469,11 +1271,9 @@ function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string | undefined, return TextEditorCursorBlinkingStyle.Phase; case 'expand': return TextEditorCursorBlinkingStyle.Expand; - case 'visible': // maintain compatibility case 'solid': return TextEditorCursorBlinkingStyle.Solid; } - return TextEditorCursorBlinkingStyle.Blink; } function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility { @@ -1500,52 +1300,8 @@ export class EditorOptionsValidator { * i.e. since they can be defined by the user, they might be invalid. */ public static validate(opts: IEditorOptions, defaults: IValidatedEditorOptions): IValidatedEditorOptions { - const viewInfo = this._sanitizeViewInfo(opts, defaults.viewInfo); const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo); - - let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey' | undefined = undefined; - if (typeof opts.multiCursorModifier === 'string') { - if (opts.multiCursorModifier === 'ctrlCmd') { - configuredMulticursorModifier = platform.isMacintosh ? 'metaKey' : 'ctrlKey'; - } else { - configuredMulticursorModifier = 'altKey'; - } - } - const multiCursorModifier = _stringSet<'altKey' | 'metaKey' | 'ctrlKey'>(configuredMulticursorModifier, defaults.multiCursorModifier, ['altKey', 'metaKey', 'ctrlKey']); - - let autoClosingBrackets: EditorAutoClosingStrategy; - let autoClosingQuotes: EditorAutoClosingStrategy; - let autoSurround: EditorAutoSurroundStrategy; - if (typeof opts.autoClosingBrackets === 'boolean' && opts.autoClosingBrackets === false) { - // backwards compatibility: disable all on boolean false - autoClosingBrackets = 'never'; - autoClosingQuotes = 'never'; - autoSurround = 'never'; - } else { - autoClosingBrackets = _stringSet(opts.autoClosingBrackets, defaults.autoClosingBrackets, ['always', 'languageDefined', 'beforeWhitespace', 'never']); - autoClosingQuotes = _stringSet(opts.autoClosingQuotes, defaults.autoClosingQuotes, ['always', 'languageDefined', 'beforeWhitespace', 'never']); - autoSurround = _stringSet(opts.autoSurround, defaults.autoSurround, ['languageDefined', 'brackets', 'quotes', 'never']); - } - return { - wordSeparators: _string(opts.wordSeparators, defaults.wordSeparators), - lineDecorationsWidth: (typeof opts.lineDecorationsWidth === 'undefined' ? defaults.lineDecorationsWidth : opts.lineDecorationsWidth), - mouseStyle: _stringSet<'text' | 'default' | 'copy'>(opts.mouseStyle, defaults.mouseStyle, ['text', 'default', 'copy']), - disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting), - automaticLayout: _boolean(opts.automaticLayout, defaults.automaticLayout), - autoClosingBrackets, - autoClosingQuotes, - autoClosingOvertype: _stringSet(opts.autoClosingOvertype, defaults.autoClosingOvertype, ['always', 'auto', 'never']), - autoSurround, - autoIndent: _boolean(opts.autoIndent, defaults.autoIndent), - dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop), - emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard), - copyWithSyntaxHighlighting: _boolean(opts.copyWithSyntaxHighlighting, defaults.copyWithSyntaxHighlighting), - useTabStops: _boolean(opts.useTabStops, defaults.useTabStops), - multiCursorModifier: multiCursorModifier, - multiCursorMergeOverlapping: _boolean(opts.multiCursorMergeOverlapping, defaults.multiCursorMergeOverlapping), - showUnused: _boolean(opts.showUnused, defaults.showUnused), - viewInfo: viewInfo, contribInfo: contribInfo, }; } @@ -1624,71 +1380,6 @@ export class EditorOptionsValidator { } } - private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions { - - let rulers: number[] = []; - if (Array.isArray(opts.rulers)) { - for (let i = 0, len = opts.rulers.length; i < len; i++) { - rulers.push(_clampedInt(opts.rulers[i], 0, 0, 10000)); - } - rulers.sort(); - } - - const fontLigatures = _boolean(opts.fontLigatures, defaults.fontLigatures); - const disableMonospaceOptimizations = _boolean(opts.disableMonospaceOptimizations, defaults.disableMonospaceOptimizations) || fontLigatures; - - let renderWhitespace = opts.renderWhitespace; - { - // Compatibility with old true or false values - if (renderWhitespace === true) { - renderWhitespace = 'boundary'; - } else if (renderWhitespace === false) { - renderWhitespace = 'none'; - } - renderWhitespace = _stringSet<'none' | 'boundary' | 'selection' | 'all'>(renderWhitespace, defaults.renderWhitespace, ['none', 'boundary', 'selection', 'all']); - } - - let renderLineHighlight = opts.renderLineHighlight; - { - // Compatibility with old true or false values - if (renderLineHighlight === true) { - renderLineHighlight = 'line'; - } else if (renderLineHighlight === false) { - renderLineHighlight = 'none'; - } - renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']); - } - - return { - extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName), - disableMonospaceOptimizations: disableMonospaceOptimizations, - rulers: rulers, - cursorSurroundingLines: _clampedInt(opts.cursorSurroundingLines, defaults.cursorWidth, 0, Number.MAX_VALUE), - glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin), - revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000), - roundedSelection: _boolean(opts.roundedSelection, defaults.roundedSelection), - overviewRulerLanes: _clampedInt(opts.overviewRulerLanes, defaults.overviewRulerLanes, 0, 3), - overviewRulerBorder: _boolean(opts.overviewRulerBorder, defaults.overviewRulerBorder), - cursorBlinking: _cursorBlinkingStyleFromString(opts.cursorBlinking, defaults.cursorBlinking), - mouseWheelZoom: _boolean(opts.mouseWheelZoom, defaults.mouseWheelZoom), - cursorSmoothCaretAnimation: _boolean(opts.cursorSmoothCaretAnimation, defaults.cursorSmoothCaretAnimation), - cursorStyle: _cursorStyleFromString(opts.cursorStyle, defaults.cursorStyle), - cursorWidth: _clampedInt(opts.cursorWidth, defaults.cursorWidth, 0, Number.MAX_VALUE), - hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler), - scrollBeyondLastLine: _boolean(opts.scrollBeyondLastLine, defaults.scrollBeyondLastLine), - scrollBeyondLastColumn: _clampedInt(opts.scrollBeyondLastColumn, defaults.scrollBeyondLastColumn, 0, Constants.MAX_SAFE_SMALL_INTEGER), - smoothScrolling: _boolean(opts.smoothScrolling, defaults.smoothScrolling), - stopRenderingLineAfter: _clampedInt(opts.stopRenderingLineAfter, defaults.stopRenderingLineAfter, -1, Constants.MAX_SAFE_SMALL_INTEGER), - renderWhitespace: renderWhitespace, - renderControlCharacters: _boolean(opts.renderControlCharacters, defaults.renderControlCharacters), - fontLigatures: fontLigatures, - renderIndentGuides: _boolean(opts.renderIndentGuides, defaults.renderIndentGuides), - highlightActiveIndentGuide: _boolean(opts.highlightActiveIndentGuide, defaults.highlightActiveIndentGuide), - renderLineHighlight: renderLineHighlight, - fixedOverflowWidgets: _boolean(opts.fixedOverflowWidgets, defaults.fixedOverflowWidgets), - }; - } - private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions { let quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean }; if (typeof opts.quickSuggestions === 'object') { @@ -1741,44 +1432,11 @@ export class EditorOptionsValidator { export class InternalEditorOptionsFactory { public static createInternalEditorOptions(env: IEnvironmentalOptions, opts: IValidatedEditorOptions) { - - let className = 'monaco-editor'; - if (opts.viewInfo.extraEditorClassName) { - className += ' ' + opts.viewInfo.extraEditorClassName; - } - if (env.extraEditorClassName) { - className += ' ' + env.extraEditorClassName; - } - if (opts.viewInfo.fontLigatures) { - className += ' enable-ligatures'; - } - if (opts.mouseStyle === 'default') { - className += ' mouse-default'; - } else if (opts.mouseStyle === 'copy') { - className += ' mouse-copy'; - } - return new InternalEditorOptions({ - canUseLayerHinting: opts.disableLayerHinting ? false : true, pixelRatio: env.pixelRatio, - editorClassName: className, lineHeight: env.fontInfo.lineHeight, - multiCursorModifier: opts.multiCursorModifier, - multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping, - wordSeparators: opts.wordSeparators, - autoClosingBrackets: opts.autoClosingBrackets, - autoClosingQuotes: opts.autoClosingQuotes, - autoClosingOvertype: opts.autoClosingOvertype, - autoSurround: opts.autoSurround, - autoIndent: opts.autoIndent, - useTabStops: opts.useTabStops, - dragAndDrop: opts.dragAndDrop, - emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard, - copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting, fontInfo: env.fontInfo, - viewInfo: opts.viewInfo, contribInfo: opts.contribInfo, - showUnused: opts.showUnused, }); } } @@ -1849,53 +1507,6 @@ export const EDITOR_MODEL_DEFAULTS = { * @internal */ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { - wordSeparators: USUAL_WORD_SEPARATORS, - lineDecorationsWidth: 10, - mouseStyle: 'text', - disableLayerHinting: false, - automaticLayout: false, - autoClosingBrackets: 'languageDefined', - autoClosingQuotes: 'languageDefined', - autoClosingOvertype: 'auto', - autoSurround: 'languageDefined', - autoIndent: true, - dragAndDrop: true, - emptySelectionClipboard: true, - copyWithSyntaxHighlighting: true, - useTabStops: true, - multiCursorModifier: 'altKey', - multiCursorMergeOverlapping: true, - showUnused: true, - - viewInfo: { - extraEditorClassName: '', - disableMonospaceOptimizations: false, - rulers: [], - cursorSurroundingLines: 0, - glyphMargin: true, - revealHorizontalRightPadding: 30, - roundedSelection: true, - overviewRulerLanes: 2, - overviewRulerBorder: true, - cursorBlinking: TextEditorCursorBlinkingStyle.Blink, - mouseWheelZoom: false, - cursorSmoothCaretAnimation: false, - cursorStyle: TextEditorCursorStyle.Line, - cursorWidth: 0, - hideCursorInOverviewRuler: false, - scrollBeyondLastLine: true, - scrollBeyondLastColumn: 5, - smoothScrolling: false, - stopRenderingLineAfter: 10000, - renderWhitespace: 'none', - renderControlCharacters: false, - fontLigatures: false, - renderIndentGuides: true, - highlightActiveIndentGuide: true, - renderLineHighlight: 'line', - fixedOverflowWidgets: false, - }, - contribInfo: { hover: { enabled: true, @@ -1977,6 +1588,9 @@ export class ValidatedEditorOptions { public _read(option: EditorOption): T { return this._values[option]; } + public get(id: T): FindComputedEditorOptionValueById { + return this._values[id]; + } public _write(option: EditorOption, value: T): void { this._values[option] = value; } @@ -2264,6 +1878,30 @@ class EditorAccessibilitySupportOption> extends BaseEditorOption { + public validate(input: number[] | undefined): number[] { + if (Array.isArray(input)) { + let rulers: number[] = []; + for (let value in input) { + rulers.push(_clampedInt(value, 0, 0, 10000)); + } + rulers.sort(); + return rulers; + } + return this.defaultValue; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number[]): number[] { + return value; + } + public equals(a: number[], b: number[]): boolean { + return arrays.equals(a, b); + } +} + +//#endregion + //#region ariaLabel class EditorAriaLabel> extends BaseEditorOption { @@ -2281,6 +1919,47 @@ class EditorAriaLabel> extends BaseEditorOption { + public validate(input: boolean | undefined): boolean { + return _boolean(input, this.defaultValue); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { + return (value || options.get(EditorOption.folding)); + } +} + +//#endregion + +//#region editorClassName + +class EditorClassName> extends BaseEditorOption { + public validate(input: undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): string { + let className = 'monaco-editor'; + if (options.get(EditorOption.extraEditorClassName)) { + className += ' ' + options.get(EditorOption.extraEditorClassName); + } + if (env.extraEditorClassName) { + className += ' ' + env.extraEditorClassName; + } + if (options.get(EditorOption.fontLigatures)) { + className += ' enable-ligatures'; + } + if (options.get(EditorOption.mouseStyle) === 'default') { + className += ' mouse-default'; + } else if (options.get(EditorOption.mouseStyle) === 'copy') { + className += ' mouse-copy'; + } + return className; + } +} + +//#endregion + //#region tabFocusMode class EditorTabFocusMode> extends BaseEditorOption { @@ -2295,6 +1974,16 @@ class EditorTabFocusMode> extends EditorBooleanOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { + return value && env.emptySelectionClipboard; + } +} + +//#endregion + //#region scrollbar export interface InternalEditorScrollbarOptions { @@ -2492,7 +2181,7 @@ export class EditorLayoutInfoComputer x)), + autoClosingOvertype: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto', ['always', 'auto', 'never'], x => x)), + autoClosingQuotes: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingQuotes, 'autoClosingQuotes', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], x => x)), + autoIndent: registerEditorOption(new EditorBooleanOption(EditorOption.autoIndent, 'autoIndent', true)), + automaticLayout: registerEditorOption(new EditorBooleanOption(EditorOption.automaticLayout, 'automaticLayout', false)), + autoSurround: registerEditorOption(new EditorEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined', ['languageDefined', 'quotes', 'brackets', 'never'], x => x)), + copyWithSyntaxHighlighting: registerEditorOption(new EditorBooleanOption(EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true)), + cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', 'blink', ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)), + cursorSmoothCaretAnimation: registerEditorOption(new EditorBooleanOption(EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false)), + cursorStyle: registerEditorOption(new EditorEnumOption(EditorOption.cursorStyle, 'cursorStyle', 'line', ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString)), + cursorSurroundingLines: registerEditorOption(new EditorIntOption(EditorOption.cursorSurroundingLines, 'cursorSurroundingLines', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)), + cursorWidth: registerEditorOption(new EditorIntOption(EditorOption.cursorWidth, 'cursorWidth', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)), + disableLayerHinting: registerEditorOption(new EditorBooleanOption(EditorOption.disableLayerHinting, 'disableLayerHinting', false)), + dragAndDrop: registerEditorOption(new EditorBooleanOption(EditorOption.dragAndDrop, 'dragAndDrop', true)), + emptySelectionClipboard: registerEditorOption(new EditorEmptySelectionClipboard(EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true)), + extraEditorClassName: registerEditorOption(new EditorStringOption(EditorOption.extraEditorClassName, 'extraEditorClassName', '')), fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))), + fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)), folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), + fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), + hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)), + highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), minimap: registerEditorOption(new EditorMinimapOption(EditorOption.minimap, 'minimap', { enabled: true, @@ -2831,10 +2589,22 @@ export const EditorOptions = { renderCharacters: true, maxColumn: 120, })), + mouseStyle: registerEditorOption(new EditorEnumOption(EditorOption.mouseStyle, 'mouseStyle', 'text', ['text', 'default', 'copy'], x => x)), mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), + mouseWheelZoom: registerEditorOption(new EditorBooleanOption(EditorOption.mouseWheelZoom, 'mouseWheelZoom', false)), + multiCursorMergeOverlapping: registerEditorOption(new EditorBooleanOption(EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true)), + multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'alt', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)), + overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)), + overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)), readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)), + renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)), + renderIndentGuides: registerEditorOption(new EditorBooleanOption(EditorOption.renderIndentGuides, 'renderIndentGuides', true)), renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOption.renderFinalNewline, 'renderFinalNewline', true)), - renderLineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.renderLineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), + renderLineHighlight: registerEditorOption(new EditorEnumOption(EditorOption.renderLineHighlight, 'renderLineHighlight', 'line', ['none', 'gutter', 'line', 'all'], x => x)), + renderWhitespace: registerEditorOption(new EditorEnumOption(EditorOption.renderWhitespace, 'renderWhitespace', 'none', ['none', 'boundary', 'selection', 'all'], x => x)), + revealHorizontalRightPadding: registerEditorOption(new EditorIntOption(EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding', 30, 0, 1000)), + roundedSelection: registerEditorOption(new EditorBooleanOption(EditorOption.roundedSelection, 'roundedSelection', true)), + rulers: registerEditorOption(new EditorRulers(EditorOption.rulers, 'rulers', [])), scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOption.scrollbar, 'scrollbar', { vertical: ScrollbarVisibility.Auto, horizontal: ScrollbarVisibility.Auto, @@ -2848,22 +2618,40 @@ export const EditorOptions = { verticalSliderSize: 14, handleMouseWheel: true, })), + scrollBeyondLastColumn: registerEditorOption(new EditorIntOption(EditorOption.scrollBeyondLastColumn, 'scrollBeyondLastColumn', 5, 0, Constants.MAX_SAFE_SMALL_INTEGER)), + scrollBeyondLastLine: registerEditorOption(new EditorBooleanOption(EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true)), selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), - tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), + showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)), + smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)), + stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)), + useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)), + wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)), wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), - wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'tabFocusMode', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), + wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)), wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), // Leave these at the end! - layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.renderLineNumbers])), + ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])), + disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])), + editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])), + tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), + layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])), wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), }; +// const tmp: { [key: string]: IEditorOption; } = EditorOptions; +// for (const key of Object.keys(tmp)) { +// const option = tmp[key]; +// if (key !== option.name) { +// throw new Error(`mismatch - ${key} - ${option.name}`); +// } +// } + export type EditorOptionsType = typeof EditorOptions; export type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index e4de9b731c151..d5162df16c727 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -113,14 +113,14 @@ export class CursorConfiguration { public static shouldRecreate(e: IConfigurationChangedEvent): boolean { return ( e.hasChanged(EditorOption.layoutInfo) - || e.wordSeparators - || e.emptySelectionClipboard - || e.multiCursorMergeOverlapping - || e.autoClosingBrackets - || e.autoClosingQuotes - || e.autoClosingOvertype - || e.autoSurround - || e.useTabStops + || e.hasChanged(EditorOption.wordSeparators) + || e.hasChanged(EditorOption.emptySelectionClipboard) + || e.hasChanged(EditorOption.multiCursorMergeOverlapping) + || e.hasChanged(EditorOption.autoClosingBrackets) + || e.hasChanged(EditorOption.autoClosingQuotes) + || e.hasChanged(EditorOption.autoClosingOvertype) + || e.hasChanged(EditorOption.autoSurround) + || e.hasChanged(EditorOption.useTabStops) || e.lineHeight || e.hasChanged(EditorOption.readOnly) ); @@ -143,16 +143,16 @@ export class CursorConfiguration { this.insertSpaces = modelOptions.insertSpaces; this.pageSize = Math.max(1, Math.floor(layoutInfo.height / c.fontInfo.lineHeight) - 2); this.lineHeight = c.lineHeight; - this.useTabStops = c.useTabStops; - this.wordSeparators = c.wordSeparators; - this.emptySelectionClipboard = c.emptySelectionClipboard; - this.copyWithSyntaxHighlighting = c.copyWithSyntaxHighlighting; - this.multiCursorMergeOverlapping = c.multiCursorMergeOverlapping; - this.autoClosingBrackets = c.autoClosingBrackets; - this.autoClosingQuotes = c.autoClosingQuotes; - this.autoClosingOvertype = c.autoClosingOvertype; - this.autoSurround = c.autoSurround; - this.autoIndent = c.autoIndent; + this.useTabStops = options.get(EditorOption.useTabStops); + this.wordSeparators = options.get(EditorOption.wordSeparators); + this.emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); + this.copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); + this.multiCursorMergeOverlapping = options.get(EditorOption.multiCursorMergeOverlapping); + this.autoClosingBrackets = options.get(EditorOption.autoClosingBrackets); + this.autoClosingQuotes = options.get(EditorOption.autoClosingQuotes); + this.autoClosingOvertype = options.get(EditorOption.autoClosingOvertype); + this.autoSurround = options.get(EditorOption.autoSurround); + this.autoIndent = options.get(EditorOption.autoIndent); this.autoClosingPairsOpen2 = new Map(); this.autoClosingPairsClose2 = new Map(); diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 4027972d75e30..27c45cf7c94b1 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -441,31 +441,73 @@ export enum RenderLineNumbersType { export enum EditorOption { accessibilitySupport = 0, - ariaLabel = 1, - fastScrollSensitivity = 2, - folding = 3, - glyphMargin = 4, - inDiffEditor = 5, - lineDecorationsWidth = 6, - lineNumbersMinChars = 7, - minimap = 8, - mouseWheelScrollSensitivity = 9, - readOnly = 10, - renderFinalNewline = 11, - renderLineNumbers = 12, - scrollbar = 13, - selectionClipboard = 14, - selectOnLineNumbers = 15, - tabFocusMode = 16, - wordWrap = 17, - wordWrapBreakAfterCharacters = 18, - wordWrapBreakBeforeCharacters = 19, - wordWrapBreakObtrusiveCharacters = 20, - wordWrapColumn = 21, - wordWrapMinified = 22, - wrappingIndent = 23, - layoutInfo = 24, - wrappingInfo = 25 + autoClosingBrackets = 1, + autoClosingOvertype = 2, + autoClosingQuotes = 3, + autoIndent = 4, + automaticLayout = 5, + autoSurround = 6, + copyWithSyntaxHighlighting = 7, + cursorBlinking = 8, + cursorSmoothCaretAnimation = 9, + cursorStyle = 10, + cursorSurroundingLines = 11, + cursorWidth = 12, + disableLayerHinting = 13, + dragAndDrop = 14, + emptySelectionClipboard = 15, + extraEditorClassName = 16, + fastScrollSensitivity = 17, + fixedOverflowWidgets = 18, + folding = 19, + fontLigatures = 20, + glyphMargin = 21, + hideCursorInOverviewRuler = 22, + highlightActiveIndentGuide = 23, + inDiffEditor = 24, + lineDecorationsWidth = 25, + lineNumbers = 26, + lineNumbersMinChars = 27, + minimap = 28, + mouseStyle = 29, + mouseWheelScrollSensitivity = 30, + mouseWheelZoom = 31, + multiCursorMergeOverlapping = 32, + multiCursorModifier = 33, + overviewRulerBorder = 34, + overviewRulerLanes = 35, + readOnly = 36, + renderControlCharacters = 37, + renderIndentGuides = 38, + renderFinalNewline = 39, + renderLineHighlight = 40, + renderWhitespace = 41, + revealHorizontalRightPadding = 42, + roundedSelection = 43, + rulers = 44, + scrollbar = 45, + scrollBeyondLastColumn = 46, + scrollBeyondLastLine = 47, + selectionClipboard = 48, + selectOnLineNumbers = 49, + showUnused = 50, + smoothScrolling = 51, + stopRenderingLineAfter = 52, + useTabStops = 53, + wordSeparators = 54, + wordWrap = 55, + wordWrapBreakAfterCharacters = 56, + wordWrapBreakBeforeCharacters = 57, + wordWrapBreakObtrusiveCharacters = 58, + wordWrapColumn = 59, + wordWrapMinified = 60, + wrappingIndent = 61, + ariaLabel = 62, + disableMonospaceOptimizations = 63, + editorClassName = 64, + tabFocusMode = 65, + layoutInfo = 66, + wrappingInfo = 67 } /** diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index a3da3dfa94cbc..1416bd3407785 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -35,25 +35,15 @@ export class ViewConfigurationChangedEvent { public readonly type = ViewEventType.ViewConfigurationChanged; public readonly _source: IConfigurationChangedEvent; - public readonly canUseLayerHinting: boolean; public readonly pixelRatio: boolean; - public readonly editorClassName: boolean; public readonly lineHeight: boolean; - public readonly emptySelectionClipboard: boolean; - public readonly copyWithSyntaxHighlighting: boolean; public readonly fontInfo: boolean; - public readonly viewInfo: boolean; constructor(source: IConfigurationChangedEvent) { this._source = source; - this.canUseLayerHinting = source.canUseLayerHinting; this.pixelRatio = source.pixelRatio; - this.editorClassName = source.editorClassName; this.lineHeight = source.lineHeight; - this.emptySelectionClipboard = source.emptySelectionClipboard; - this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting; this.fontInfo = source.fontInfo; - this.viewInfo = source.viewInfo; } public hasChanged(id: EditorOption): boolean { diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index 6950cb302a8dd..952406baa27e9 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -53,7 +53,7 @@ export class ViewLayout extends Disposable implements IViewLayout { } private _configureSmoothScrollDuration(): void { - this.scrollable.setSmoothScrollDuration(this._configuration.editor.viewInfo.smoothScrolling ? SMOOTH_SCROLLING_TIME : 0); + this.scrollable.setSmoothScrollDuration(this._configuration.options.get(EditorOption.smoothScrolling) ? SMOOTH_SCROLLING_TIME : 0); } // ---- begin view event handlers @@ -70,7 +70,7 @@ export class ViewLayout extends Disposable implements IViewLayout { height: layoutInfo.contentHeight }); } - if (e.viewInfo) { + if (e.hasChanged(EditorOption.smoothScrolling)) { this._configureSmoothScrollDuration(); } this._updateHeight(); @@ -105,7 +105,7 @@ export class ViewLayout extends Disposable implements IViewLayout { const scrollDimensions = this.scrollable.getScrollDimensions(); let result = this._linesLayout.getLinesTotalHeight(); - if (this._configuration.editor.viewInfo.scrollBeyondLastLine) { + if (this._configuration.options.get(EditorOption.scrollBeyondLastLine)) { result += scrollDimensions.height - this._configuration.editor.lineHeight; } else { result += this._getHorizontalScrollbarHeight(scrollDimensions); @@ -149,7 +149,7 @@ export class ViewLayout extends Disposable implements IViewLayout { const wrappingInfo = options.get(EditorOption.wrappingInfo); let isViewportWrapping = wrappingInfo.isViewportWrapping; if (!isViewportWrapping) { - const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth(); return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth, whitespaceMinWidth); } diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts index c0929f47d0092..df241dc8643c0 100644 --- a/src/vs/editor/contrib/clipboard/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/clipboard.ts @@ -16,6 +16,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { MenuId } from 'vs/platform/actions/common/actions'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste'; @@ -94,7 +95,7 @@ class ExecCommandCutAction extends ExecCommandAction { return; } - const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard; + const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard); if (!emptySelectionClipboard && editor.getSelection().isEmpty()) { return; @@ -143,7 +144,7 @@ class ExecCommandCopyAction extends ExecCommandAction { return; } - const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard; + const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard); if (!emptySelectionClipboard && editor.getSelection().isEmpty()) { return; @@ -209,7 +210,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction { return; } - const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard; + const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard); if (!emptySelectionClipboard && editor.getSelection().isEmpty()) { return; diff --git a/src/vs/editor/contrib/dnd/dnd.ts b/src/vs/editor/contrib/dnd/dnd.ts index 70b3551b532cb..bbf3df37d0147 100644 --- a/src/vs/editor/contrib/dnd/dnd.ts +++ b/src/vs/editor/contrib/dnd/dnd.ts @@ -19,6 +19,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { IModelDeltaDecoration } from 'vs/editor/common/model'; import { IMouseEvent } from 'vs/base/browser/mouseEvent'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; function hasTriggerModifier(e: IKeyboardEvent | IMouseEvent): boolean { if (isMacintosh) { @@ -67,7 +68,7 @@ export class DragAndDropController extends Disposable implements editorCommon.IE } private onEditorKeyDown(e: IKeyboardEvent): void { - if (!this._editor.getConfiguration().dragAndDrop) { + if (!this._editor.getOption(EditorOption.dragAndDrop)) { return; } @@ -83,7 +84,7 @@ export class DragAndDropController extends Disposable implements editorCommon.IE } private onEditorKeyUp(e: IKeyboardEvent): void { - if (!this._editor.getConfiguration().dragAndDrop) { + if (!this._editor.getOption(EditorOption.dragAndDrop)) { return; } diff --git a/src/vs/editor/contrib/find/findModel.ts b/src/vs/editor/contrib/find/findModel.ts index faca23f0a556c..c25fd810bade6 100644 --- a/src/vs/editor/contrib/find/findModel.ts +++ b/src/vs/editor/contrib/find/findModel.ts @@ -22,6 +22,7 @@ import { ReplaceAllCommand } from 'vs/editor/contrib/find/replaceAllCommand'; import { ReplacePattern, parseReplaceString } from 'vs/editor/contrib/find/replacePattern'; import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey('findWidgetVisible', false); export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated(); @@ -287,12 +288,12 @@ export class FindModelBoundToEditorModel { let position = new Position(lineNumber, column); - let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false); + let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false); if (prevMatch && prevMatch.range.isEmpty() && prevMatch.range.getStartPosition().equals(position)) { // Looks like we're stuck at this position, unacceptable! position = this._prevSearchPosition(position); - prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false); + prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false); } if (!prevMatch) { @@ -379,12 +380,12 @@ export class FindModelBoundToEditorModel { let position = new Position(lineNumber, column); - let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches); + let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches); if (forceMove && nextMatch && nextMatch.range.isEmpty() && nextMatch.range.getStartPosition().equals(position)) { // Looks like we're stuck at this position, unacceptable! position = this._nextSearchPosition(position); - nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches); + nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches); } if (!nextMatch) { @@ -438,7 +439,7 @@ export class FindModelBoundToEditorModel { private _findMatches(findScope: Range | null, captureMatches: boolean, limitResultCount: number): FindMatch[] { let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope); - return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches, limitResultCount); + return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches, limitResultCount); } public replaceAll(): void { @@ -459,7 +460,7 @@ export class FindModelBoundToEditorModel { } private _largeReplaceAll(): void { - const searchParams = new SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null); + const searchParams = new SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null); const searchData = searchParams.parseSearchRequest(); if (!searchData) { return; diff --git a/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts b/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts index 3b72a01a35cbc..f23c13dcd38c9 100644 --- a/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts +++ b/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts @@ -12,6 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Event, Emitter } from 'vs/base/common/event'; import * as platform from 'vs/base/common/platform'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; function hasModifier(e: { ctrlKey: boolean; shiftKey: boolean; altKey: boolean; metaKey: boolean }, modifier: 'ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey'): boolean { return !!e[modifier]; @@ -116,14 +117,14 @@ export class ClickLinkGesture extends Disposable { super(); this._editor = editor; - this._opts = createOptions(this._editor.getConfiguration().multiCursorModifier); + this._opts = createOptions(this._editor.getOption(EditorOption.multiCursorModifier)); this.lastMouseMoveEvent = null; this.hasTriggerKeyOnMouseDown = false; this._register(this._editor.onDidChangeConfiguration((e) => { - if (e.multiCursorModifier) { - const newOpts = createOptions(this._editor.getConfiguration().multiCursorModifier); + if (e.hasChanged(EditorOption.multiCursorModifier)) { + const newOpts = createOptions(this._editor.getOption(EditorOption.multiCursorModifier)); if (this._opts.equals(newOpts)) { return; } diff --git a/src/vs/editor/contrib/indentation/indentation.ts b/src/vs/editor/contrib/indentation/indentation.ts index fd9fcee54ea49..cc2c6904bfaa9 100644 --- a/src/vs/editor/contrib/indentation/indentation.ts +++ b/src/vs/editor/contrib/indentation/indentation.ts @@ -22,6 +22,7 @@ import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules'; import { IModelService } from 'vs/editor/common/services/modelService'; import * as indentUtils from 'vs/editor/contrib/indentation/indentUtils'; import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export function getReindentEditOperations(model: ITextModel, startLineNumber: number, endLineNumber: number, inheritedIndent?: string): IIdentifiedSingleEditOperation[] { if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) { @@ -443,7 +444,7 @@ export class AutoIndentOnPaste implements IEditorContribution { this.callOnModel = dispose(this.callOnModel); // we are disabled - if (!this.editor.getConfiguration().autoIndent || this.editor.getConfiguration().contribInfo.formatOnPaste) { + if (!this.editor.getOption(EditorOption.autoIndent) || this.editor.getConfiguration().contribInfo.formatOnPaste) { return; } diff --git a/src/vs/editor/contrib/linesOperations/linesOperations.ts b/src/vs/editor/contrib/linesOperations/linesOperations.ts index 9fb95158f25f5..7f1d517236a07 100644 --- a/src/vs/editor/contrib/linesOperations/linesOperations.ts +++ b/src/vs/editor/contrib/linesOperations/linesOperations.ts @@ -23,6 +23,7 @@ import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCom import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand'; import { MenuId } from 'vs/platform/actions/common/actions'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; // copy lines @@ -111,7 +112,7 @@ abstract class AbstractMoveLinesAction extends EditorAction { let commands: ICommand[] = []; let selections = editor.getSelections() || []; - let autoIndent = editor.getConfiguration().autoIndent; + const autoIndent = editor.getOption(EditorOption.autoIndent); for (const selection of selections) { commands.push(new MoveLinesCommand(selection, this.down, autoIndent)); @@ -886,7 +887,7 @@ export abstract class AbstractCaseAction extends EditorAction { return; } - let wordSeparators = editor.getConfiguration().wordSeparators; + let wordSeparators = editor.getOption(EditorOption.wordSeparators); let commands: ICommand[] = []; diff --git a/src/vs/editor/contrib/links/links.ts b/src/vs/editor/contrib/links/links.ts index f9f19e5211caf..237ced230c064 100644 --- a/src/vs/editor/contrib/links/links.ts +++ b/src/vs/editor/contrib/links/links.ts @@ -24,6 +24,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { IOpenerService } from 'vs/platform/opener/common/opener'; import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; function getHoverMessage(link: Link, useMetaKey: boolean): MarkdownString { const executeCmd = link.url && /^command:/i.test(link.url.toString()); @@ -218,7 +219,7 @@ class LinkDetector implements editorCommon.IEditorContribution { } private updateDecorations(links: Link[]): void { - const useMetaKey = (this.editor.getConfiguration().multiCursorModifier === 'altKey'); + const useMetaKey = (this.editor.getOption(EditorOption.multiCursorModifier) === 'altKey'); let oldDecorations: string[] = []; let keys = Object.keys(this.currentOccurrences); for (let i = 0, len = keys.length; i < len; i++) { @@ -246,7 +247,7 @@ class LinkDetector implements editorCommon.IEditorContribution { } private _onEditorMouseMove(mouseEvent: ClickLinkMouseEvent, withKey: ClickLinkKeyboardEvent | null): void { - const useMetaKey = (this.editor.getConfiguration().multiCursorModifier === 'altKey'); + const useMetaKey = (this.editor.getOption(EditorOption.multiCursorModifier) === 'altKey'); if (this.isEnabled(mouseEvent, withKey)) { this.cleanUpActiveLinkDecoration(); // always remove previous link decoration as their can only be one const occurrence = this.getLinkOccurrence(mouseEvent.target.position); @@ -262,7 +263,7 @@ class LinkDetector implements editorCommon.IEditorContribution { } private cleanUpActiveLinkDecoration(): void { - const useMetaKey = (this.editor.getConfiguration().multiCursorModifier === 'altKey'); + const useMetaKey = (this.editor.getOption(EditorOption.multiCursorModifier) === 'altKey'); if (this.activeLinkDecorationId) { const occurrence = this.currentOccurrences[this.activeLinkDecorationId]; if (occurrence) { diff --git a/src/vs/editor/contrib/multicursor/multicursor.ts b/src/vs/editor/contrib/multicursor/multicursor.ts index ec0925af31ad2..4da9f3490051c 100644 --- a/src/vs/editor/contrib/multicursor/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/multicursor.ts @@ -26,6 +26,7 @@ import { MenuId } from 'vs/platform/actions/common/actions'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { overviewRulerSelectionHighlightForeground } from 'vs/platform/theme/common/colorRegistry'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class InsertCursorAbove extends EditorAction { @@ -350,7 +351,7 @@ export class MultiCursorSession { const allSelections = this._editor.getSelections(); const lastAddedSelection = allSelections[allSelections.length - 1]; - const nextMatch = this._editor.getModel().findNextMatch(this.searchText, lastAddedSelection.getEndPosition(), false, this.matchCase, this.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false); + const nextMatch = this._editor.getModel().findNextMatch(this.searchText, lastAddedSelection.getEndPosition(), false, this.matchCase, this.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false); if (!nextMatch) { return null; @@ -401,7 +402,7 @@ export class MultiCursorSession { const allSelections = this._editor.getSelections(); const lastAddedSelection = allSelections[allSelections.length - 1]; - const previousMatch = this._editor.getModel().findPreviousMatch(this.searchText, lastAddedSelection.getStartPosition(), false, this.matchCase, this.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false); + const previousMatch = this._editor.getModel().findPreviousMatch(this.searchText, lastAddedSelection.getStartPosition(), false, this.matchCase, this.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false); if (!previousMatch) { return null; @@ -416,7 +417,7 @@ export class MultiCursorSession { this.findController.highlightFindOptions(); - return this._editor.getModel().findMatches(this.searchText, true, false, this.matchCase, this.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false, Constants.MAX_SAFE_SMALL_INTEGER); + return this._editor.getModel().findMatches(this.searchText, true, false, this.matchCase, this.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false, Constants.MAX_SAFE_SMALL_INTEGER); } } @@ -593,7 +594,7 @@ export class MultiCursorSelectionController extends Disposable implements IEdito // - and we're searching for a regex if (findState.isRevealed && findState.searchString.length > 0 && findState.isRegex) { - matches = this._editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false, Constants.MAX_SAFE_SMALL_INTEGER); + matches = this._editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false, Constants.MAX_SAFE_SMALL_INTEGER); } else { @@ -928,7 +929,7 @@ export class SelectionHighlighter extends Disposable implements IEditorContribut } } - return new SelectionHighlighterState(r.searchText, r.matchCase, r.wholeWord ? editor.getConfiguration().wordSeparators : null); + return new SelectionHighlighterState(r.searchText, r.matchCase, r.wholeWord ? editor.getOption(EditorOption.wordSeparators) : null); } private _setState(state: SelectionHighlighterState | null): void { @@ -1053,4 +1054,4 @@ registerEditorAction(MoveSelectionToPreviousFindMatchAction); registerEditorAction(SelectHighlightsAction); registerEditorAction(CompatChangeAll); registerEditorAction(InsertCursorAtEndOfLineSelected); -registerEditorAction(InsertCursorAtTopOfLineSelected); \ No newline at end of file +registerEditorAction(InsertCursorAtTopOfLineSelected); diff --git a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts index 4fd4f5d2db069..4e05c3ff8a998 100644 --- a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts @@ -26,6 +26,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { activeContrastBorder, editorSelectionHighlight, editorSelectionHighlightBorder, overviewRulerSelectionHighlightForeground, registerColor } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant, themeColorFromId } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const editorWordHighlight = registerColor('editor.wordHighlightBackground', { dark: '#575757B8', light: '#57575740', hc: null }, nls.localize('wordHighlight', 'Background color of a symbol during read-access, like reading a variable. The color must not be opaque so as not to hide underlying decorations.'), true); export const editorWordHighlightStrong = registerColor('editor.wordHighlightStrongBackground', { dark: '#004972B8', light: '#0e639c40', hc: null }, nls.localize('wordHighlightStrong', 'Background color of a symbol during write-access, like writing to a variable. The color must not be opaque so as not to hide underlying decorations.'), true); @@ -371,7 +372,7 @@ class WordHighlighter { let myRequestId = ++this.workerRequestTokenId; this.workerRequestCompleted = false; - this.workerRequest = computeOccurencesAtPosition(this.model, this.editor.getSelection(), this.editor.getConfiguration().wordSeparators); + this.workerRequest = computeOccurencesAtPosition(this.model, this.editor.getSelection(), this.editor.getOption(EditorOption.wordSeparators)); this.workerRequest.result.then(data => { if (myRequestId === this.workerRequestTokenId) { diff --git a/src/vs/editor/contrib/wordOperations/wordOperations.ts b/src/vs/editor/contrib/wordOperations/wordOperations.ts index a0e5e226cddd3..5e77d1c060774 100644 --- a/src/vs/editor/contrib/wordOperations/wordOperations.ts +++ b/src/vs/editor/contrib/wordOperations/wordOperations.ts @@ -20,7 +20,7 @@ import { ITextModel } from 'vs/editor/common/model'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { EDITOR_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions'; export interface MoveWordOptions extends ICommandOptions { inSelectionMode: boolean; @@ -42,8 +42,7 @@ export abstract class MoveWordCommand extends EditorCommand { if (!editor.hasModel()) { return; } - const config = editor.getConfiguration(); - const wordSeparators = getMapForWordSeparators(config.wordSeparators); + const wordSeparators = getMapForWordSeparators(editor.getOption(EditorOption.wordSeparators)); const model = editor.getModel(); const selections = editor.getSelections(); @@ -190,7 +189,7 @@ export class CursorWordAccessibilityLeft extends WordLeftCommand { } protected _move(_: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position { - return super._move(getMapForWordSeparators(EDITOR_DEFAULTS.wordSeparators), model, position, wordNavigationType); + return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType); } } @@ -211,7 +210,7 @@ export class CursorWordAccessibilityLeftSelect extends WordLeftCommand { } protected _move(_: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position { - return super._move(getMapForWordSeparators(EDITOR_DEFAULTS.wordSeparators), model, position, wordNavigationType); + return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType); } } @@ -310,7 +309,7 @@ export class CursorWordAccessibilityRight extends WordRightCommand { } protected _move(_: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position { - return super._move(getMapForWordSeparators(EDITOR_DEFAULTS.wordSeparators), model, position, wordNavigationType); + return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType); } } @@ -331,7 +330,7 @@ export class CursorWordAccessibilityRightSelect extends WordRightCommand { } protected _move(_: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position { - return super._move(getMapForWordSeparators(EDITOR_DEFAULTS.wordSeparators), model, position, wordNavigationType); + return super._move(getMapForWordSeparators(EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType); } } @@ -354,8 +353,7 @@ export abstract class DeleteWordCommand extends EditorCommand { if (!editor.hasModel()) { return; } - const config = editor.getConfiguration(); - const wordSeparators = getMapForWordSeparators(config.wordSeparators); + const wordSeparators = getMapForWordSeparators(editor.getOption(EditorOption.wordSeparators)); const model = editor.getModel(); const selections = editor.getSelections(); diff --git a/src/vs/editor/editor.api.ts b/src/vs/editor/editor.api.ts index e535b3e44562f..a4e36c33fe0be 100644 --- a/src/vs/editor/editor.api.ts +++ b/src/vs/editor/editor.api.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { EDITOR_DEFAULTS, WrappingIndent } from 'vs/editor/common/config/editorOptions'; +import { EditorOptions } from 'vs/editor/common/config/editorOptions'; import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase'; import { createMonacoEditorAPI } from 'vs/editor/standalone/browser/standaloneEditor'; import { createMonacoLanguagesAPI } from 'vs/editor/standalone/browser/standaloneLanguages'; @@ -11,9 +11,9 @@ import { createMonacoLanguagesAPI } from 'vs/editor/standalone/browser/standalon const global: any = self; // Set defaults for standalone editor -(EDITOR_DEFAULTS).wrappingIndent = WrappingIndent.None; -(EDITOR_DEFAULTS.viewInfo).glyphMargin = false; -(EDITOR_DEFAULTS).autoIndent = false; +(EditorOptions.wrappingIndent).defaultValue = 'none'; +(EditorOptions.glyphMargin).defaultValue = false; +(EditorOptions.autoIndent).defaultValue = false; const api = createMonacoBaseAPI(); api.editor = createMonacoEditorAPI(); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 304261d93421f..c74ca442fdd6b 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2746,7 +2746,7 @@ declare namespace monaco.editor { * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'. * Defaults to 'blink'. */ - cursorBlinking?: string; + cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'; /** * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. * Defaults to false. @@ -2761,7 +2761,7 @@ declare namespace monaco.editor { * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. */ - cursorStyle?: string; + cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'; /** * Control the width of the cursor when cursorStyle is set to 'line' */ @@ -3269,35 +3269,6 @@ declare namespace monaco.editor { readonly cycle: boolean; } - export interface InternalEditorViewOptions { - readonly extraEditorClassName: string; - readonly disableMonospaceOptimizations: boolean; - readonly rulers: number[]; - readonly cursorSurroundingLines: number; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: number; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: number; - readonly overviewRulerBorder: boolean; - readonly cursorBlinking: TextEditorCursorBlinkingStyle; - readonly mouseWheelZoom: boolean; - readonly cursorSmoothCaretAnimation: boolean; - readonly cursorStyle: TextEditorCursorStyle; - readonly cursorWidth: number; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly scrollBeyondLastColumn: number; - readonly smoothScrolling: boolean; - readonly stopRenderingLineAfter: number; - readonly renderWhitespace: 'none' | 'boundary' | 'selection' | 'all'; - readonly renderControlCharacters: boolean; - readonly fontLigatures: boolean; - readonly renderIndentGuides: boolean; - readonly highlightActiveIndentGuide: boolean; - readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly fixedOverflowWidgets: boolean; - } - export interface EditorContribOptions { readonly hover: InternalEditorHoverOptions; readonly links: boolean; @@ -3339,25 +3310,9 @@ declare namespace monaco.editor { */ export class InternalEditorOptions { readonly _internalEditorOptionsBrand: void; - readonly canUseLayerHinting: boolean; readonly pixelRatio: number; - readonly editorClassName: string; readonly lineHeight: number; - readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; - readonly multiCursorMergeOverlapping: boolean; - readonly showUnused: boolean; - readonly wordSeparators: string; - readonly autoClosingBrackets: EditorAutoClosingStrategy; - readonly autoClosingQuotes: EditorAutoClosingStrategy; - readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy; - readonly autoSurround: EditorAutoSurroundStrategy; - readonly autoIndent: boolean; - readonly useTabStops: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; readonly fontInfo: FontInfo; - readonly viewInfo: InternalEditorViewOptions; readonly contribInfo: EditorContribOptions; } @@ -3366,24 +3321,9 @@ declare namespace monaco.editor { */ export interface IConfigurationChangedEvent { hasChanged(id: EditorOption): boolean; - readonly canUseLayerHinting: boolean; readonly pixelRatio: boolean; - readonly editorClassName: boolean; readonly lineHeight: boolean; - readonly multiCursorModifier: boolean; - readonly multiCursorMergeOverlapping: boolean; - readonly wordSeparators: boolean; - readonly autoClosingBrackets: boolean; - readonly autoClosingQuotes: boolean; - readonly autoClosingOvertype: boolean; - readonly autoSurround: boolean; - readonly autoIndent: boolean; - readonly useTabStops: boolean; - readonly dragAndDrop: boolean; - readonly emptySelectionClipboard: boolean; - readonly copyWithSyntaxHighlighting: boolean; readonly fontInfo: boolean; - readonly viewInfo: boolean; readonly contribInfo: boolean; } @@ -3595,51 +3535,131 @@ declare namespace monaco.editor { export enum EditorOption { accessibilitySupport = 0, - ariaLabel = 1, - fastScrollSensitivity = 2, - folding = 3, - glyphMargin = 4, - inDiffEditor = 5, - lineDecorationsWidth = 6, - lineNumbersMinChars = 7, - minimap = 8, - mouseWheelScrollSensitivity = 9, - readOnly = 10, - renderFinalNewline = 11, - renderLineNumbers = 12, - scrollbar = 13, - selectionClipboard = 14, - selectOnLineNumbers = 15, - tabFocusMode = 16, - wordWrap = 17, - wordWrapBreakAfterCharacters = 18, - wordWrapBreakBeforeCharacters = 19, - wordWrapBreakObtrusiveCharacters = 20, - wordWrapColumn = 21, - wordWrapMinified = 22, - wrappingIndent = 23, - layoutInfo = 24, - wrappingInfo = 25 + autoClosingBrackets = 1, + autoClosingOvertype = 2, + autoClosingQuotes = 3, + autoIndent = 4, + automaticLayout = 5, + autoSurround = 6, + copyWithSyntaxHighlighting = 7, + cursorBlinking = 8, + cursorSmoothCaretAnimation = 9, + cursorStyle = 10, + cursorSurroundingLines = 11, + cursorWidth = 12, + disableLayerHinting = 13, + dragAndDrop = 14, + emptySelectionClipboard = 15, + extraEditorClassName = 16, + fastScrollSensitivity = 17, + fixedOverflowWidgets = 18, + folding = 19, + fontLigatures = 20, + glyphMargin = 21, + hideCursorInOverviewRuler = 22, + highlightActiveIndentGuide = 23, + inDiffEditor = 24, + lineDecorationsWidth = 25, + lineNumbers = 26, + lineNumbersMinChars = 27, + minimap = 28, + mouseStyle = 29, + mouseWheelScrollSensitivity = 30, + mouseWheelZoom = 31, + multiCursorMergeOverlapping = 32, + multiCursorModifier = 33, + overviewRulerBorder = 34, + overviewRulerLanes = 35, + readOnly = 36, + renderControlCharacters = 37, + renderIndentGuides = 38, + renderFinalNewline = 39, + renderLineHighlight = 40, + renderWhitespace = 41, + revealHorizontalRightPadding = 42, + roundedSelection = 43, + rulers = 44, + scrollbar = 45, + scrollBeyondLastColumn = 46, + scrollBeyondLastLine = 47, + selectionClipboard = 48, + selectOnLineNumbers = 49, + showUnused = 50, + smoothScrolling = 51, + stopRenderingLineAfter = 52, + useTabStops = 53, + wordSeparators = 54, + wordWrap = 55, + wordWrapBreakAfterCharacters = 56, + wordWrapBreakBeforeCharacters = 57, + wordWrapBreakObtrusiveCharacters = 58, + wordWrapColumn = 59, + wordWrapMinified = 60, + wrappingIndent = 61, + ariaLabel = 62, + disableMonospaceOptimizations = 63, + editorClassName = 64, + tabFocusMode = 65, + layoutInfo = 66, + wrappingInfo = 67 } export const EditorOptions: { accessibilitySupport: any; - ariaLabel: any; + autoClosingBrackets: any; + autoClosingOvertype: any; + autoClosingQuotes: any; + autoIndent: any; + automaticLayout: any; + autoSurround: any; + copyWithSyntaxHighlighting: any; + cursorBlinking: any; + cursorSmoothCaretAnimation: any; + cursorStyle: any; + cursorSurroundingLines: any; + cursorWidth: any; + disableLayerHinting: any; + dragAndDrop: any; + emptySelectionClipboard: any; + extraEditorClassName: any; fastScrollSensitivity: any; + fixedOverflowWidgets: any; folding: any; + fontLigatures: any; glyphMargin: any; + hideCursorInOverviewRuler: any; + highlightActiveIndentGuide: any; inDiffEditor: any; lineDecorationsWidth: IEditorOption; + lineNumbers: any; lineNumbersMinChars: any; minimap: any; + mouseStyle: any; mouseWheelScrollSensitivity: any; + mouseWheelZoom: any; + multiCursorMergeOverlapping: any; + multiCursorModifier: any; + overviewRulerBorder: any; + overviewRulerLanes: any; readOnly: any; + renderControlCharacters: any; + renderIndentGuides: any; renderFinalNewline: any; - renderLineNumbers: any; + renderLineHighlight: any; + renderWhitespace: any; + revealHorizontalRightPadding: any; + roundedSelection: any; + rulers: any; scrollbar: any; + scrollBeyondLastColumn: any; + scrollBeyondLastLine: any; selectionClipboard: any; selectOnLineNumbers: any; - tabFocusMode: any; + showUnused: any; + smoothScrolling: any; + stopRenderingLineAfter: any; + useTabStops: any; + wordSeparators: any; wordWrap: any; wordWrapBreakAfterCharacters: any; wordWrapBreakBeforeCharacters: any; @@ -3647,6 +3667,10 @@ declare namespace monaco.editor { wordWrapColumn: any; wordWrapMinified: any; wrappingIndent: any; + ariaLabel: any; + disableMonospaceOptimizations: any; + editorClassName: any; + tabFocusMode: any; layoutInfo: any; wrappingInfo: any; }; diff --git a/src/vs/workbench/api/browser/mainThreadEditor.ts b/src/vs/workbench/api/browser/mainThreadEditor.ts index 2d210bb3febce..520801babe664 100644 --- a/src/vs/workbench/api/browser/mainThreadEditor.ts +++ b/src/vs/workbench/api/browser/mainThreadEditor.ts @@ -58,11 +58,10 @@ export class MainThreadTextEditorProperties { let cursorStyle: TextEditorCursorStyle; let lineNumbers: RenderLineNumbersType; if (codeEditor) { - const codeEditorOpts = codeEditor.getConfiguration(); const options = codeEditor.getOptions(); - const renderLineNumbers = options.get(EditorOption.renderLineNumbers); - cursorStyle = codeEditorOpts.viewInfo.cursorStyle; - lineNumbers = renderLineNumbers.renderType; + const lineNumbersOpts = options.get(EditorOption.lineNumbers); + cursorStyle = options.get(EditorOption.cursorStyle); + lineNumbers = lineNumbersOpts.renderType; } else if (previousProperties) { cursorStyle = previousProperties.options.cursorStyle; lineNumbers = previousProperties.options.lineNumbers; diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts index ccede6e64c68c..94a0f2cd23531 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts @@ -31,6 +31,7 @@ import { IFilterResult, IPreferencesEditorModel, IPreferencesService, ISetting, import { DefaultSettingsEditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels'; import { IMarkerService, IMarkerData, MarkerSeverity, MarkerTag } from 'vs/platform/markers/common/markers'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IPreferencesRenderer extends IDisposable { readonly preferencesModel: IPreferencesEditorModel; @@ -690,7 +691,7 @@ class EditSettingRenderer extends Disposable { } private onConfigurationChanged(): void { - if (!this.editor.getConfiguration().viewInfo.glyphMargin) { + if (!this.editor.getOption(EditorOption.glyphMargin)) { this.editPreferenceWidgetForCursorPosition.hide(); this.editPreferenceWidgetForMouseMove.hide(); } @@ -740,7 +741,7 @@ class EditSettingRenderer extends Disposable { private showEditPreferencesWidget(editPreferencesWidget: EditPreferenceWidget, settings: IIndexedSetting[]) { const line = settings[0].valueRange.startLineNumber; - if (this.editor.getConfiguration().viewInfo.glyphMargin && this.marginFreeFromOtherDecorations(line)) { + if (this.editor.getOption(EditorOption.glyphMargin) && this.marginFreeFromOtherDecorations(line)) { editPreferencesWidget.show(line, nls.localize('editTtile', "Edit"), settings); const editPreferenceWidgetToHide = editPreferencesWidget === this.editPreferenceWidgetForCursorPosition ? this.editPreferenceWidgetForMouseMove : this.editPreferenceWidgetForCursorPosition; editPreferenceWidgetToHide.hide(); diff --git a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts index 5a0e888e93186..59ef23bc2e17b 100644 --- a/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/gotoLineHandler.ts @@ -51,8 +51,8 @@ export class GotoLineAction extends QuickOpenAction { if (isCodeEditor(activeTextEditorWidget)) { const options = activeTextEditorWidget.getOptions(); - const renderLineNumbers = options.get(EditorOption.renderLineNumbers); - if (renderLineNumbers.renderType === RenderLineNumbersType.Relative) { + const lineNumbers = options.get(EditorOption.lineNumbers); + if (lineNumbers.renderType === RenderLineNumbersType.Relative) { activeTextEditorWidget.updateOptions({ lineNumbers: 'on' }); From cd3481d9d9071f0670167e8bf4d9ccf079af134b Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 3 Sep 2019 11:56:19 -0700 Subject: [PATCH 034/204] right click context menu for inline diff actions --- .../editor/browser/widget/inlineDiffMargin.ts | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/vs/editor/browser/widget/inlineDiffMargin.ts b/src/vs/editor/browser/widget/inlineDiffMargin.ts index 7933869ab4ff2..a911a6b4c502b 100644 --- a/src/vs/editor/browser/widget/inlineDiffMargin.ts +++ b/src/vs/editor/browser/widget/inlineDiffMargin.ts @@ -122,15 +122,12 @@ export class InlineDiffMargin extends Disposable { })); } - this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => { - const { top, height } = dom.getDomNodePagePosition(this._diffActions); - let pad = Math.floor(lineHeight / 3); - e.preventDefault(); + const showContextMenu = (x: number, y: number) => { this._contextMenuService.showContextMenu({ getAnchor: () => { return { - x: e.posx, - y: top + height + pad + x, + y }; }, getActions: () => { @@ -141,6 +138,15 @@ export class InlineDiffMargin extends Disposable { }, autoSelectFirstItem: true }); + }; + + this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => { + const { top, height } = dom.getDomNodePagePosition(this._diffActions); + let pad = Math.floor(lineHeight / 3); + e.preventDefault(); + + showContextMenu(e.posx, top + height + pad); + })); this._register(editor.onMouseMove((e: editorBrowser.IEditorMouseEvent) => { @@ -157,6 +163,22 @@ export class InlineDiffMargin extends Disposable { this.visibility = false; } })); + + this._register(editor.onMouseDown((e: editorBrowser.IEditorMouseEvent) => { + if (!e.event.rightButton) { + return; + } + + if (e.target.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || e.target.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE) { + const viewZoneId = e.target.detail.viewZoneId; + + if (viewZoneId === this._viewZoneId) { + e.event.preventDefault(); + currentLineNumberOffset = this._updateLightBulbPosition(this._marginDomNode, e.event.browserEvent.y, lineHeight); + showContextMenu(e.event.posx, e.event.posy + lineHeight); + } + } + })); } private _updateLightBulbPosition(marginDomNode: HTMLElement, y: number, lineHeight: number): number { From dd1146ee8fe656da0633304646ed9e5bf6e1fdcd Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 3 Sep 2019 12:54:55 -0700 Subject: [PATCH 035/204] Fix lint --- src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts index 6e41c9c5eee15..50aa2e843a8c1 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts @@ -14,7 +14,7 @@ export interface XTermCore { _coreService: { triggerDataEvent(data: string, wasUserInput?: boolean): void; - } + }; _renderService: { _renderer: { From 802826e02a33b699d5c7f53dc1c5c69da44ffeed Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 3 Sep 2019 23:10:32 +0200 Subject: [PATCH 036/204] Move more editor options --- .../common/config/commonEditorConfig.ts | 35 ++-- src/vs/editor/common/config/editorOptions.ts | 141 +++++++------ .../common/standalone/standaloneEnums.ts | 151 +++++++------- .../bracketMatching/bracketMatching.ts | 7 +- .../contrib/codeAction/lightBulbWidget.ts | 6 +- .../contrib/codelens/codelensController.ts | 5 +- .../contrib/colorPicker/colorDetector.ts | 3 +- .../editor/contrib/contextmenu/contextmenu.ts | 5 +- src/vs/editor/contrib/format/formatActions.ts | 5 +- .../editor/contrib/indentation/indentation.ts | 2 +- src/vs/editor/contrib/links/links.ts | 4 +- .../editor/contrib/multicursor/multicursor.ts | 4 +- .../suggest/suggestCommitCharacters.ts | 3 +- .../contrib/suggest/suggestController.ts | 5 +- src/vs/editor/contrib/suggest/suggestModel.ts | 4 +- .../wordHighlighter/wordHighlighter.ts | 4 +- src/vs/monaco.d.ts | 187 ++++++++++-------- 17 files changed, 308 insertions(+), 263 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index df3551bfebd98..3e48ce0e7b86f 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -155,6 +155,13 @@ function migrateOptions(options: IEditorOptions): void { } else if (renderLineHighlight === false) { options.renderLineHighlight = 'none'; } + + let acceptSuggestionOnEnter = options.acceptSuggestionOnEnter; + if (acceptSuggestionOnEnter === true) { + options.acceptSuggestionOnEnter = 'on'; + } else if (acceptSuggestionOnEnter === false) { + options.acceptSuggestionOnEnter = 'off'; + } } export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { @@ -633,7 +640,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.quickSuggestionsDelay': { 'type': 'integer', - 'default': EDITOR_DEFAULTS.contribInfo.quickSuggestionsDelay, + 'default': EditorOptions.quickSuggestionsDelay.defaultValue, 'minimum': 0, 'description': nls.localize('quickSuggestionsDelay', "Controls the delay in milliseconds after which quick suggestions will show up.") }, @@ -696,12 +703,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.formatOnType': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.formatOnType, + 'default': EditorOptions.formatOnType.defaultValue, 'description': nls.localize('formatOnType', "Controls whether the editor should automatically format the line after typing.") }, 'editor.formatOnPaste': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.formatOnPaste, + 'default': EditorOptions.formatOnPaste.defaultValue, 'description': nls.localize('formatOnPaste', "Controls whether the editor should automatically format the pasted content. A formatter must be available and the formatter should be able to format a range in a document.") }, 'editor.autoIndent': { @@ -711,13 +718,13 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.suggestOnTriggerCharacters': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.suggestOnTriggerCharacters, + 'default': EditorOptions.suggestOnTriggerCharacters.defaultValue, 'description': nls.localize('suggestOnTriggerCharacters', "Controls whether suggestions should automatically show up when typing trigger characters.") }, 'editor.acceptSuggestionOnEnter': { 'type': 'string', 'enum': ['on', 'smart', 'off'], - 'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnEnter, + 'default': EditorOptions.acceptSuggestionOnEnter.defaultValue, 'markdownEnumDescriptions': [ '', nls.localize('acceptSuggestionOnEnterSmart', "Only accept a suggestion with `Enter` when it makes a textual change."), @@ -727,7 +734,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.acceptSuggestionOnCommitCharacter': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnCommitCharacter, + 'default': EditorOptions.acceptSuggestionOnCommitCharacter.defaultValue, 'markdownDescription': nls.localize('acceptSuggestionOnCommitCharacter', "Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.") }, 'editor.snippetSuggestions': { @@ -754,7 +761,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.wordBasedSuggestions': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions, + 'default': EditorOptions.wordBasedSuggestions.defaultValue, 'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.") }, 'editor.suggestSelection': { @@ -973,12 +980,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.selectionHighlight': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.selectionHighlight, + 'default': EditorOptions.selectionHighlight.defaultValue, 'description': nls.localize('selectionHighlight', "Controls whether the editor should highlight matches similar to the selection.") }, 'editor.occurrencesHighlight': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.occurrencesHighlight, + 'default': EditorOptions.occurrencesHighlight.defaultValue, 'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences.") }, 'editor.overviewRulerLanes': { @@ -1069,7 +1076,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.codeLens': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.codeLens, + 'default': EditorOptions.codeLens.defaultValue, 'description': nls.localize('codeLens', "Controls whether the editor shows CodeLens.") }, 'editor.folding': { @@ -1091,7 +1098,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.matchBrackets': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.matchBrackets, + 'default': EditorOptions.matchBrackets.defaultValue, 'description': nls.localize('matchBrackets', "Highlight matching brackets when one of them is selected.") }, 'editor.glyphMargin': { @@ -1137,17 +1144,17 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.links': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.links, + 'default': EditorOptions.links.defaultValue, 'description': nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }, 'editor.colorDecorators': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.colorDecorators, + 'default': EditorOptions.colorDecorators.defaultValue, 'description': nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators and color picker.") }, 'editor.lightbulb.enabled': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.lightbulbEnabled, + 'default': EditorOptions.lightbulb.defaultValue.enabled, 'description': nls.localize('codeActions', "Enables the code action lightbulb in the editor.") }, 'editor.maxTokenizationLineLength': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index d3eeb2ec5c2d1..6d3ba78ade019 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -533,7 +533,7 @@ export interface IEditorOptions { quickSuggestions?: boolean | { other: boolean, comments: boolean, strings: boolean }; /** * Quick suggestions show delay (in ms) - * Defaults to 500 (ms) + * Defaults to 10 (ms) */ quickSuggestionsDelay?: number; /** @@ -588,7 +588,7 @@ export interface IEditorOptions { * Accept suggestions on ENTER. * Defaults to 'on'. */ - acceptSuggestionOnEnter?: boolean | 'on' | 'smart' | 'off'; + acceptSuggestionOnEnter?: 'on' | 'smart' | 'off'; /** * Accept suggestions on provider defined characters. * Defaults to true. @@ -947,32 +947,17 @@ export interface InternalParameterHintOptions { export interface EditorContribOptions { readonly hover: InternalEditorHoverOptions; - readonly links: boolean; - readonly contextmenu: boolean; readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean }; - readonly quickSuggestionsDelay: number; readonly parameterHints: InternalParameterHintOptions; - readonly formatOnType: boolean; - readonly formatOnPaste: boolean; - readonly suggestOnTriggerCharacters: boolean; - readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off'; - readonly acceptSuggestionOnCommitCharacter: boolean; - readonly wordBasedSuggestions: boolean; readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; readonly suggest: InternalSuggestOptions; readonly gotoLocation: InternalGoToLocationOptions; - readonly selectionHighlight: boolean; - readonly occurrencesHighlight: boolean; - readonly codeLens: boolean; readonly foldingStrategy: 'auto' | 'indentation'; readonly showFoldingControls: 'always' | 'mouseover'; - readonly matchBrackets: boolean; readonly find: InternalEditorFindOptions; - readonly colorDecorators: boolean; - readonly lightbulbEnabled: boolean; readonly codeActionsOnSave: ICodeActionsOnSaveOptions; readonly codeActionsOnSaveTimeout: number; } @@ -1113,34 +1098,19 @@ export class InternalEditorOptions { private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean { return ( this._equalsHoverOptions(a.hover, b.hover) - && a.links === b.links - && a.contextmenu === b.contextmenu && InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions) - && a.quickSuggestionsDelay === b.quickSuggestionsDelay && this._equalsParameterHintOptions(a.parameterHints, b.parameterHints) - && a.formatOnType === b.formatOnType - && a.formatOnPaste === b.formatOnPaste - && a.suggestOnTriggerCharacters === b.suggestOnTriggerCharacters - && a.acceptSuggestionOnEnter === b.acceptSuggestionOnEnter - && a.acceptSuggestionOnCommitCharacter === b.acceptSuggestionOnCommitCharacter - && a.wordBasedSuggestions === b.wordBasedSuggestions && a.suggestSelection === b.suggestSelection && a.suggestFontSize === b.suggestFontSize && a.suggestLineHeight === b.suggestLineHeight && a.tabCompletion === b.tabCompletion && this._equalsSuggestOptions(a.suggest, b.suggest) && InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation) - && a.selectionHighlight === b.selectionHighlight - && a.occurrencesHighlight === b.occurrencesHighlight - && a.codeLens === b.codeLens && a.foldingStrategy === b.foldingStrategy && a.showFoldingControls === b.showFoldingControls - && a.matchBrackets === b.matchBrackets && this._equalFindOptions(a.find, b.find) - && a.colorDecorators === b.colorDecorators && objects.equals(a.codeActionsOnSave, b.codeActionsOnSave) && a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout - && a.lightbulbEnabled === b.lightbulbEnabled ); } @@ -1387,39 +1357,20 @@ export class EditorOptionsValidator { } else { quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions); } - // Compatibility support for acceptSuggestionOnEnter - if (typeof opts.acceptSuggestionOnEnter === 'boolean') { - opts.acceptSuggestionOnEnter = opts.acceptSuggestionOnEnter ? 'on' : 'off'; - } const find = this._sanitizeFindOpts(opts.find, defaults.find); return { hover: this._sanitizeHoverOpts(opts.hover, defaults.hover), - links: _boolean(opts.links, defaults.links), - contextmenu: _boolean(opts.contextmenu, defaults.contextmenu), quickSuggestions: quickSuggestions, - quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER), parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints), - formatOnType: _boolean(opts.formatOnType, defaults.formatOnType), - formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste), - suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters), - acceptSuggestionOnEnter: _stringSet<'on' | 'smart' | 'off'>(opts.acceptSuggestionOnEnter, defaults.acceptSuggestionOnEnter, ['on', 'smart', 'off']), - acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter), - wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions), suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']), suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000), suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000), tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion), suggest: this._sanitizeSuggestOpts(opts, defaults.suggest), gotoLocation: this._sanitizeGotoLocationOpts(opts, defaults.gotoLocation), - selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight), - occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight), - codeLens: _boolean(opts.codeLens, defaults.codeLens), foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']), showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']), - matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets), find: find, - colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators), - lightbulbEnabled: _boolean(opts.lightbulb ? opts.lightbulb.enabled : false, defaults.lightbulbEnabled), codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}), codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000) }; @@ -1513,20 +1464,15 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { delay: 300, sticky: true }, - links: true, - contextmenu: true, - quickSuggestions: { other: true, comments: false, strings: false }, - quickSuggestionsDelay: 10, + quickSuggestions: { + other: true, + comments: false, + strings: false + }, parameterHints: { enabled: true, cycle: false }, - formatOnType: false, - formatOnPaste: false, - suggestOnTriggerCharacters: true, - acceptSuggestionOnEnter: 'on', - acceptSuggestionOnCommitCharacter: true, - wordBasedSuggestions: true, suggestSelection: 'recentlyUsed', suggestFontSize: 0, suggestLineHeight: 0, @@ -1544,20 +1490,14 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { gotoLocation: { multiple: 'peek' }, - selectionHighlight: true, - occurrencesHighlight: true, - codeLens: true, foldingStrategy: 'auto', showFoldingControls: 'mouseover', - matchBrackets: true, find: { seedSearchStringFromSelection: true, autoFindInSelection: false, globalFindClipboard: false, addExtraSpaceOnTop: true }, - colorDecorators: true, - lightbulbEnabled: true, codeActionsOnSave: {}, codeActionsOnSaveTimeout: 750 }, @@ -1829,7 +1769,7 @@ export interface InternalEditorMinimapOptions { readonly maxColumn: number; } -class EditorMinimapOption> extends BaseEditorOption { +class EditorMinimap> extends BaseEditorOption { public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -1974,7 +1914,7 @@ class EditorTabFocusMode> extends EditorBooleanOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { @@ -1984,6 +1924,31 @@ class EditorEmptySelectionClipboard; + +class EditorLightbulb> extends BaseEditorOption { + public validate(input: IEditorLightbulbOptions | undefined): ValidEditorLightbulbOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidEditorLightbulbOptions): ValidEditorLightbulbOptions { + return value; + } + public equals(a: ValidEditorLightbulbOptions, b: ValidEditorLightbulbOptions): boolean { + return ( + a.enabled === b.enabled + ); + } +} + +//#endregion + //#region scrollbar export interface InternalEditorScrollbarOptions { @@ -2000,7 +1965,7 @@ export interface InternalEditorScrollbarOptions { readonly verticalSliderSize: number; } -class EditorScrollbarOption> extends BaseEditorOption { +class EditorScrollbar> extends BaseEditorOption { public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { if (typeof input !== 'object') { return this.defaultValue; @@ -2482,6 +2447,8 @@ function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): } export const enum EditorOption { + acceptSuggestionOnCommitCharacter, + acceptSuggestionOnEnter, accessibilitySupport, autoClosingBrackets, autoClosingOvertype, @@ -2489,6 +2456,9 @@ export const enum EditorOption { autoIndent, automaticLayout, autoSurround, + codeLens, + colorDecorators, + contextmenu, copyWithSyntaxHighlighting, cursorBlinking, cursorSmoothCaretAnimation, @@ -2503,21 +2473,28 @@ export const enum EditorOption { fixedOverflowWidgets, folding, fontLigatures, + formatOnPaste, + formatOnType, glyphMargin, hideCursorInOverviewRuler, highlightActiveIndentGuide, inDiffEditor, + lightbulb, lineDecorationsWidth, lineNumbers, lineNumbersMinChars, + links, + matchBrackets, minimap, mouseStyle, mouseWheelScrollSensitivity, mouseWheelZoom, multiCursorMergeOverlapping, multiCursorModifier, + occurrencesHighlight, overviewRulerBorder, overviewRulerLanes, + quickSuggestionsDelay, readOnly, renderControlCharacters, renderIndentGuides, @@ -2531,11 +2508,14 @@ export const enum EditorOption { scrollBeyondLastColumn, scrollBeyondLastLine, selectionClipboard, + selectionHighlight, selectOnLineNumbers, showUnused, smoothScrolling, stopRenderingLineAfter, + suggestOnTriggerCharacters, useTabStops, + wordBasedSuggestions, wordSeparators, wordWrap, wordWrapBreakAfterCharacters, @@ -2554,6 +2534,8 @@ export const enum EditorOption { } export const EditorOptions = { + acceptSuggestionOnCommitCharacter: registerEditorOption(new EditorBooleanOption(EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true)), + acceptSuggestionOnEnter: registerEditorOption(new EditorEnumOption(EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter', 'on', ['on', 'smart', 'off'], x => x)), accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', 'auto')), autoClosingBrackets: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingBrackets, 'autoClosingBrackets', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], x => x)), autoClosingOvertype: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto', ['always', 'auto', 'never'], x => x)), @@ -2561,6 +2543,9 @@ export const EditorOptions = { autoIndent: registerEditorOption(new EditorBooleanOption(EditorOption.autoIndent, 'autoIndent', true)), automaticLayout: registerEditorOption(new EditorBooleanOption(EditorOption.automaticLayout, 'automaticLayout', false)), autoSurround: registerEditorOption(new EditorEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined', ['languageDefined', 'quotes', 'brackets', 'never'], x => x)), + codeLens: registerEditorOption(new EditorBooleanOption(EditorOption.codeLens, 'codeLens', true)), + colorDecorators: registerEditorOption(new EditorBooleanOption(EditorOption.colorDecorators, 'colorDecorators', true)), + contextmenu: registerEditorOption(new EditorBooleanOption(EditorOption.contextmenu, 'contextmenu', true)), copyWithSyntaxHighlighting: registerEditorOption(new EditorBooleanOption(EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true)), cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', 'blink', ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)), cursorSmoothCaretAnimation: registerEditorOption(new EditorBooleanOption(EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false)), @@ -2575,14 +2560,21 @@ export const EditorOptions = { fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)), folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), + formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)), + formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)), highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), + lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', { + enabled: true + })), lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), - minimap: registerEditorOption(new EditorMinimapOption(EditorOption.minimap, 'minimap', { + links: registerEditorOption(new EditorBooleanOption(EditorOption.links, 'links', true)), + matchBrackets: registerEditorOption(new EditorBooleanOption(EditorOption.matchBrackets, 'matchBrackets', true)), + minimap: registerEditorOption(new EditorMinimap(EditorOption.minimap, 'minimap', { enabled: true, side: 'right', showSlider: 'mouseover', @@ -2594,8 +2586,10 @@ export const EditorOptions = { mouseWheelZoom: registerEditorOption(new EditorBooleanOption(EditorOption.mouseWheelZoom, 'mouseWheelZoom', false)), multiCursorMergeOverlapping: registerEditorOption(new EditorBooleanOption(EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true)), multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'alt', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)), + occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)), overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)), overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)), + quickSuggestionsDelay: registerEditorOption(new EditorIntOption(EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay', 10, 0, Constants.MAX_SAFE_SMALL_INTEGER)), readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)), renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)), renderIndentGuides: registerEditorOption(new EditorBooleanOption(EditorOption.renderIndentGuides, 'renderIndentGuides', true)), @@ -2605,7 +2599,7 @@ export const EditorOptions = { revealHorizontalRightPadding: registerEditorOption(new EditorIntOption(EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding', 30, 0, 1000)), roundedSelection: registerEditorOption(new EditorBooleanOption(EditorOption.roundedSelection, 'roundedSelection', true)), rulers: registerEditorOption(new EditorRulers(EditorOption.rulers, 'rulers', [])), - scrollbar: registerEditorOption(new EditorScrollbarOption(EditorOption.scrollbar, 'scrollbar', { + scrollbar: registerEditorOption(new EditorScrollbar(EditorOption.scrollbar, 'scrollbar', { vertical: ScrollbarVisibility.Auto, horizontal: ScrollbarVisibility.Auto, arrowSize: 11, @@ -2621,11 +2615,14 @@ export const EditorOptions = { scrollBeyondLastColumn: registerEditorOption(new EditorIntOption(EditorOption.scrollBeyondLastColumn, 'scrollBeyondLastColumn', 5, 0, Constants.MAX_SAFE_SMALL_INTEGER)), scrollBeyondLastLine: registerEditorOption(new EditorBooleanOption(EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true)), selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), + selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)), smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)), stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)), + suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)), useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)), + wordBasedSuggestions: registerEditorOption(new EditorBooleanOption(EditorOption.wordBasedSuggestions, 'wordBasedSuggestions', true)), wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)), wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 27c45cf7c94b1..8393a6c1ec6bb 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -440,74 +440,89 @@ export enum RenderLineNumbersType { } export enum EditorOption { - accessibilitySupport = 0, - autoClosingBrackets = 1, - autoClosingOvertype = 2, - autoClosingQuotes = 3, - autoIndent = 4, - automaticLayout = 5, - autoSurround = 6, - copyWithSyntaxHighlighting = 7, - cursorBlinking = 8, - cursorSmoothCaretAnimation = 9, - cursorStyle = 10, - cursorSurroundingLines = 11, - cursorWidth = 12, - disableLayerHinting = 13, - dragAndDrop = 14, - emptySelectionClipboard = 15, - extraEditorClassName = 16, - fastScrollSensitivity = 17, - fixedOverflowWidgets = 18, - folding = 19, - fontLigatures = 20, - glyphMargin = 21, - hideCursorInOverviewRuler = 22, - highlightActiveIndentGuide = 23, - inDiffEditor = 24, - lineDecorationsWidth = 25, - lineNumbers = 26, - lineNumbersMinChars = 27, - minimap = 28, - mouseStyle = 29, - mouseWheelScrollSensitivity = 30, - mouseWheelZoom = 31, - multiCursorMergeOverlapping = 32, - multiCursorModifier = 33, - overviewRulerBorder = 34, - overviewRulerLanes = 35, - readOnly = 36, - renderControlCharacters = 37, - renderIndentGuides = 38, - renderFinalNewline = 39, - renderLineHighlight = 40, - renderWhitespace = 41, - revealHorizontalRightPadding = 42, - roundedSelection = 43, - rulers = 44, - scrollbar = 45, - scrollBeyondLastColumn = 46, - scrollBeyondLastLine = 47, - selectionClipboard = 48, - selectOnLineNumbers = 49, - showUnused = 50, - smoothScrolling = 51, - stopRenderingLineAfter = 52, - useTabStops = 53, - wordSeparators = 54, - wordWrap = 55, - wordWrapBreakAfterCharacters = 56, - wordWrapBreakBeforeCharacters = 57, - wordWrapBreakObtrusiveCharacters = 58, - wordWrapColumn = 59, - wordWrapMinified = 60, - wrappingIndent = 61, - ariaLabel = 62, - disableMonospaceOptimizations = 63, - editorClassName = 64, - tabFocusMode = 65, - layoutInfo = 66, - wrappingInfo = 67 + acceptSuggestionOnCommitCharacter = 0, + acceptSuggestionOnEnter = 1, + accessibilitySupport = 2, + autoClosingBrackets = 3, + autoClosingOvertype = 4, + autoClosingQuotes = 5, + autoIndent = 6, + automaticLayout = 7, + autoSurround = 8, + codeLens = 9, + colorDecorators = 10, + contextmenu = 11, + copyWithSyntaxHighlighting = 12, + cursorBlinking = 13, + cursorSmoothCaretAnimation = 14, + cursorStyle = 15, + cursorSurroundingLines = 16, + cursorWidth = 17, + disableLayerHinting = 18, + dragAndDrop = 19, + emptySelectionClipboard = 20, + extraEditorClassName = 21, + fastScrollSensitivity = 22, + fixedOverflowWidgets = 23, + folding = 24, + fontLigatures = 25, + formatOnPaste = 26, + formatOnType = 27, + glyphMargin = 28, + hideCursorInOverviewRuler = 29, + highlightActiveIndentGuide = 30, + inDiffEditor = 31, + lightbulb = 32, + lineDecorationsWidth = 33, + lineNumbers = 34, + lineNumbersMinChars = 35, + links = 36, + matchBrackets = 37, + minimap = 38, + mouseStyle = 39, + mouseWheelScrollSensitivity = 40, + mouseWheelZoom = 41, + multiCursorMergeOverlapping = 42, + multiCursorModifier = 43, + occurrencesHighlight = 44, + overviewRulerBorder = 45, + overviewRulerLanes = 46, + quickSuggestionsDelay = 47, + readOnly = 48, + renderControlCharacters = 49, + renderIndentGuides = 50, + renderFinalNewline = 51, + renderLineHighlight = 52, + renderWhitespace = 53, + revealHorizontalRightPadding = 54, + roundedSelection = 55, + rulers = 56, + scrollbar = 57, + scrollBeyondLastColumn = 58, + scrollBeyondLastLine = 59, + selectionClipboard = 60, + selectionHighlight = 61, + selectOnLineNumbers = 62, + showUnused = 63, + smoothScrolling = 64, + stopRenderingLineAfter = 65, + suggestOnTriggerCharacters = 66, + useTabStops = 67, + wordBasedSuggestions = 68, + wordSeparators = 69, + wordWrap = 70, + wordWrapBreakAfterCharacters = 71, + wordWrapBreakBeforeCharacters = 72, + wordWrapBreakObtrusiveCharacters = 73, + wordWrapColumn = 74, + wordWrapMinified = 75, + wrappingIndent = 76, + ariaLabel = 77, + disableMonospaceOptimizations = 78, + editorClassName = 79, + tabFocusMode = 80, + layoutInfo = 81, + wrappingInfo = 82 } /** diff --git a/src/vs/editor/contrib/bracketMatching/bracketMatching.ts b/src/vs/editor/contrib/bracketMatching/bracketMatching.ts index 675fa71bd8c16..44d7bb7613ae1 100644 --- a/src/vs/editor/contrib/bracketMatching/bracketMatching.ts +++ b/src/vs/editor/contrib/bracketMatching/bracketMatching.ts @@ -22,6 +22,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { registerColor } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant, themeColorFromId } from 'vs/platform/theme/common/themeService'; import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const overviewRulerBracketMatchForeground = registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize('overviewRulerBracketMatchForeground', 'Overview ruler marker color for matching brackets.')); @@ -104,7 +105,7 @@ export class BracketMatchingController extends Disposable implements editorCommo this._lastVersionId = 0; this._decorations = []; this._updateBracketsSoon = this._register(new RunOnceScheduler(() => this._updateBrackets(), 50)); - this._matchBrackets = this._editor.getConfiguration().contribInfo.matchBrackets; + this._matchBrackets = this._editor.getOption(EditorOption.matchBrackets); this._updateBracketsSoon.schedule(); this._register(editor.onDidChangeCursorPosition((e) => { @@ -130,7 +131,7 @@ export class BracketMatchingController extends Disposable implements editorCommo this._updateBracketsSoon.schedule(); })); this._register(editor.onDidChangeConfiguration((e) => { - this._matchBrackets = this._editor.getConfiguration().contribInfo.matchBrackets; + this._matchBrackets = this._editor.getOption(EditorOption.matchBrackets); if (!this._matchBrackets && this._decorations.length > 0) { // Remove existing decorations if bracket matching is off this._decorations = this._editor.deltaDecorations(this._decorations, []); @@ -332,4 +333,4 @@ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, { title: nls.localize({ key: 'miGoToBracket', comment: ['&& denotes a mnemonic'] }, "Go to &&Bracket") }, order: 2 -}); \ No newline at end of file +}); diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index 8575f354d5ce9..a43dabec6f0b8 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -14,6 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel'; import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction'; import * as nls from 'vs/nls'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; namespace LightBulbState { @@ -106,7 +107,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget { })); this._register(this._editor.onDidChangeConfiguration(e => { // hide when told to do so - if (e.contribInfo && !this._editor.getConfiguration().contribInfo.lightbulbEnabled) { + if (e.contribInfo && !this._editor.getOption(EditorOption.lightbulb).enabled) { this.hide(); } })); @@ -138,7 +139,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget { } const config = this._editor.getConfiguration(); - if (!config.contribInfo.lightbulbEnabled) { + const options = this._editor.getOptions(); + if (!options.get(EditorOption.lightbulb).enabled) { return this.hide(); } diff --git a/src/vs/editor/contrib/codelens/codelensController.ts b/src/vs/editor/contrib/codelens/codelensController.ts index 726133c3f7f6e..72e341842a883 100644 --- a/src/vs/editor/contrib/codelens/codelensController.ts +++ b/src/vs/editor/contrib/codelens/codelensController.ts @@ -17,6 +17,7 @@ import { CodeLensWidget, CodeLensHelper } from 'vs/editor/contrib/codelens/codel import { ICommandService } from 'vs/platform/commands/common/commands'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { ICodeLensCache } from 'vs/editor/contrib/codelens/codeLensCache'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class CodeLensContribution implements editorCommon.IEditorContribution { @@ -40,13 +41,13 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { @INotificationService private readonly _notificationService: INotificationService, @ICodeLensCache private readonly _codeLensCache: ICodeLensCache ) { - this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens; + this._isEnabled = this._editor.getOption(EditorOption.codeLens); this._globalToDispose.add(this._editor.onDidChangeModel(() => this._onModelChange())); this._globalToDispose.add(this._editor.onDidChangeModelLanguage(() => this._onModelChange())); this._globalToDispose.add(this._editor.onDidChangeConfiguration(() => { const prevIsEnabled = this._isEnabled; - this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens; + this._isEnabled = this._editor.getOption(EditorOption.codeLens); if (prevIsEnabled !== this._isEnabled) { this._onModelChange(); } diff --git a/src/vs/editor/contrib/colorPicker/colorDetector.ts b/src/vs/editor/contrib/colorPicker/colorDetector.ts index 0ccf498c009f2..c1460b7650d57 100644 --- a/src/vs/editor/contrib/colorPicker/colorDetector.ts +++ b/src/vs/editor/contrib/colorPicker/colorDetector.ts @@ -19,6 +19,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { ColorProviderRegistry } from 'vs/editor/common/modes'; import { IColorData, getColors } from 'vs/editor/contrib/colorPicker/color'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const MAX_DECORATORS = 500; @@ -84,7 +85,7 @@ export class ColorDetector extends Disposable implements IEditorContribution { } } - return this._editor.getConfiguration().contribInfo.colorDecorators; + return this._editor.getOption(EditorOption.colorDecorators); } getId(): string { diff --git a/src/vs/editor/contrib/contextmenu/contextmenu.ts b/src/vs/editor/contrib/contextmenu/contextmenu.ts index 2209b38da7fa5..65fbdef07bbee 100644 --- a/src/vs/editor/contrib/contextmenu/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/contextmenu.ts @@ -22,6 +22,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { ITextModel } from 'vs/editor/common/model'; import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class ContextMenuController implements IEditorContribution { @@ -66,7 +67,7 @@ export class ContextMenuController implements IEditorContribution { return; } - if (!this._editor.getConfiguration().contribInfo.contextmenu) { + if (!this._editor.getOption(EditorOption.contextmenu)) { this._editor.focus(); // Ensure the cursor is at the position of the mouse click if (e.target.position && !this._editor.getSelection().containsPosition(e.target.position)) { @@ -104,7 +105,7 @@ export class ContextMenuController implements IEditorContribution { } public showContextMenu(anchor?: IAnchor | null): void { - if (!this._editor.getConfiguration().contribInfo.contextmenu) { + if (!this._editor.getOption(EditorOption.contextmenu)) { return; // Context menu is turned off through configuration } if (!this._editor.hasModel()) { diff --git a/src/vs/editor/contrib/format/formatActions.ts b/src/vs/editor/contrib/format/formatActions.ts index 8b2798a496de8..1af6506e0d870 100644 --- a/src/vs/editor/contrib/format/formatActions.ts +++ b/src/vs/editor/contrib/format/formatActions.ts @@ -24,6 +24,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { onUnexpectedError } from 'vs/base/common/errors'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class FormatOnType implements editorCommon.IEditorContribution { @@ -59,7 +60,7 @@ class FormatOnType implements editorCommon.IEditorContribution { this._callOnModel.clear(); // we are disabled - if (!this._editor.getConfiguration().contribInfo.formatOnType) { + if (!this._editor.getOption(EditorOption.formatOnType)) { return; } @@ -184,7 +185,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution { this._callOnModel.clear(); // we are disabled - if (!this.editor.getConfiguration().contribInfo.formatOnPaste) { + if (!this.editor.getOption(EditorOption.formatOnPaste)) { return; } diff --git a/src/vs/editor/contrib/indentation/indentation.ts b/src/vs/editor/contrib/indentation/indentation.ts index cc2c6904bfaa9..bbd4f5e563d46 100644 --- a/src/vs/editor/contrib/indentation/indentation.ts +++ b/src/vs/editor/contrib/indentation/indentation.ts @@ -444,7 +444,7 @@ export class AutoIndentOnPaste implements IEditorContribution { this.callOnModel = dispose(this.callOnModel); // we are disabled - if (!this.editor.getOption(EditorOption.autoIndent) || this.editor.getConfiguration().contribInfo.formatOnPaste) { + if (!this.editor.getOption(EditorOption.autoIndent) || this.editor.getOption(EditorOption.formatOnPaste)) { return; } diff --git a/src/vs/editor/contrib/links/links.ts b/src/vs/editor/contrib/links/links.ts index 237ced230c064..1eee5898a9637 100644 --- a/src/vs/editor/contrib/links/links.ts +++ b/src/vs/editor/contrib/links/links.ts @@ -140,9 +140,9 @@ class LinkDetector implements editorCommon.IEditorContribution { this.cleanUpActiveLinkDecoration(); })); - this.enabled = editor.getConfiguration().contribInfo.links; + this.enabled = editor.getOption(EditorOption.links); this.listenersToRemove.add(editor.onDidChangeConfiguration((e) => { - let enabled = editor.getConfiguration().contribInfo.links; + const enabled = editor.getOption(EditorOption.links); if (this.enabled === enabled) { // No change in our configuration option return; diff --git a/src/vs/editor/contrib/multicursor/multicursor.ts b/src/vs/editor/contrib/multicursor/multicursor.ts index 4da9f3490051c..028ddab538cea 100644 --- a/src/vs/editor/contrib/multicursor/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/multicursor.ts @@ -809,13 +809,13 @@ export class SelectionHighlighter extends Disposable implements IEditorContribut constructor(editor: ICodeEditor) { super(); this.editor = editor; - this._isEnabled = editor.getConfiguration().contribInfo.selectionHighlight; + this._isEnabled = editor.getOption(EditorOption.selectionHighlight); this.decorations = []; this.updateSoon = this._register(new RunOnceScheduler(() => this._update(), 300)); this.state = null; this._register(editor.onDidChangeConfiguration((e) => { - this._isEnabled = editor.getConfiguration().contribInfo.selectionHighlight; + this._isEnabled = editor.getOption(EditorOption.selectionHighlight); })); this._register(editor.onDidChangeCursorSelection((e: ICursorSelectionChangedEvent) => { diff --git a/src/vs/editor/contrib/suggest/suggestCommitCharacters.ts b/src/vs/editor/contrib/suggest/suggestCommitCharacters.ts index 20a7656532ac4..3831500a4f861 100644 --- a/src/vs/editor/contrib/suggest/suggestCommitCharacters.ts +++ b/src/vs/editor/contrib/suggest/suggestCommitCharacters.ts @@ -8,6 +8,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ISelectedSuggestion, SuggestWidget } from './suggestWidget'; import { CharacterSet } from 'vs/editor/common/core/characterClassifier'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class CommitCharacterController { @@ -27,7 +28,7 @@ export class CommitCharacterController { this._disposables.add(editor.onWillType(text => { if (this._active) { const ch = text.charCodeAt(text.length - 1); - if (this._active.acceptCharacters.has(ch) && editor.getConfiguration().contribInfo.acceptSuggestionOnCommitCharacter) { + if (this._active.acceptCharacters.has(ch) && editor.getOption(EditorOption.acceptSuggestionOnCommitCharacter)) { accept(this._active.item); } } diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index a86c5148d2c8d..e8bc0699c821a 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -35,6 +35,7 @@ import { isObject } from 'vs/base/common/types'; import { CommitCharacterController } from './suggestCommitCharacters'; import { IPosition } from 'vs/editor/common/core/position'; import { TrackedRangeStickiness, ITextModel } from 'vs/editor/common/model'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const _sticky = false; // for development purposes only @@ -129,7 +130,7 @@ export class SuggestController implements IEditorContribution { const endColumn = position.column; let value = true; if ( - this._editor.getConfiguration().contribInfo.acceptSuggestionOnEnter === 'smart' + this._editor.getOption(EditorOption.acceptSuggestionOnEnter) === 'smart' && this._model.state === State.Auto && !item.completion.command && !item.completion.additionalTextEdits @@ -182,7 +183,7 @@ export class SuggestController implements IEditorContribution { // Manage the acceptSuggestionsOnEnter context key let acceptSuggestionsOnEnter = SuggestContext.AcceptSuggestionsOnEnter.bindTo(_contextKeyService); let updateFromConfig = () => { - const { acceptSuggestionOnEnter } = this._editor.getConfiguration().contribInfo; + const acceptSuggestionOnEnter = this._editor.getOption(EditorOption.acceptSuggestionOnEnter); acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart'); }; this._toDispose.add(this._editor.onDidChangeConfiguration(() => updateFromConfig())); diff --git a/src/vs/editor/contrib/suggest/suggestModel.ts b/src/vs/editor/contrib/suggest/suggestModel.ts index 174f87f6a0c47..0d0bbe19f4d44 100644 --- a/src/vs/editor/contrib/suggest/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/suggestModel.ts @@ -173,7 +173,7 @@ export class SuggestModel implements IDisposable { // --- handle configuration & precondition changes private _updateQuickSuggest(): void { - this._quickSuggestDelay = this._editor.getConfiguration().contribInfo.quickSuggestionsDelay; + this._quickSuggestDelay = this._editor.getOption(EditorOption.quickSuggestionsDelay); if (isNaN(this._quickSuggestDelay) || (!this._quickSuggestDelay && this._quickSuggestDelay !== 0) || this._quickSuggestDelay < 0) { this._quickSuggestDelay = 10; @@ -186,7 +186,7 @@ export class SuggestModel implements IDisposable { if (this._editor.getOption(EditorOption.readOnly) || !this._editor.hasModel() - || !this._editor.getConfiguration().contribInfo.suggestOnTriggerCharacters) { + || !this._editor.getOption(EditorOption.suggestOnTriggerCharacters)) { return; } diff --git a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts index 4e05c3ff8a998..11cbf87647cac 100644 --- a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts @@ -182,7 +182,7 @@ class WordHighlighter { this.editor = editor; this._hasWordHighlights = ctxHasWordHighlights.bindTo(contextKeyService); this._ignorePositionChangeEvent = false; - this.occurrencesHighlight = this.editor.getConfiguration().contribInfo.occurrencesHighlight; + this.occurrencesHighlight = this.editor.getOption(EditorOption.occurrencesHighlight); this.model = this.editor.getModel(); this.toUnhook.add(editor.onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => { @@ -203,7 +203,7 @@ class WordHighlighter { this._stopAll(); })); this.toUnhook.add(editor.onDidChangeConfiguration((e) => { - let newValue = this.editor.getConfiguration().contribInfo.occurrencesHighlight; + let newValue = this.editor.getOption(EditorOption.occurrencesHighlight); if (this.occurrencesHighlight !== newValue) { this.occurrencesHighlight = newValue; this._stopAll(); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index c74ca442fdd6b..2307b5caedb92 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2919,7 +2919,7 @@ declare namespace monaco.editor { }; /** * Quick suggestions show delay (in ms) - * Defaults to 500 (ms) + * Defaults to 10 (ms) */ quickSuggestionsDelay?: number; /** @@ -2974,7 +2974,7 @@ declare namespace monaco.editor { * Accept suggestions on ENTER. * Defaults to 'on'. */ - acceptSuggestionOnEnter?: boolean | 'on' | 'smart' | 'off'; + acceptSuggestionOnEnter?: 'on' | 'smart' | 'off'; /** * Accept suggestions on provider defined characters. * Defaults to true. @@ -3271,36 +3271,21 @@ declare namespace monaco.editor { export interface EditorContribOptions { readonly hover: InternalEditorHoverOptions; - readonly links: boolean; - readonly contextmenu: boolean; readonly quickSuggestions: boolean | { other: boolean; comments: boolean; strings: boolean; }; - readonly quickSuggestionsDelay: number; readonly parameterHints: InternalParameterHintOptions; - readonly formatOnType: boolean; - readonly formatOnPaste: boolean; - readonly suggestOnTriggerCharacters: boolean; - readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off'; - readonly acceptSuggestionOnCommitCharacter: boolean; - readonly wordBasedSuggestions: boolean; readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; readonly suggest: InternalSuggestOptions; readonly gotoLocation: InternalGoToLocationOptions; - readonly selectionHighlight: boolean; - readonly occurrencesHighlight: boolean; - readonly codeLens: boolean; readonly foldingStrategy: 'auto' | 'indentation'; readonly showFoldingControls: 'always' | 'mouseover'; - readonly matchBrackets: boolean; readonly find: InternalEditorFindOptions; - readonly colorDecorators: boolean; - readonly lightbulbEnabled: boolean; readonly codeActionsOnSave: ICodeActionsOnSaveOptions; readonly codeActionsOnSaveTimeout: number; } @@ -3400,6 +3385,8 @@ declare namespace monaco.editor { readonly maxColumn: number; } + export type ValidEditorLightbulbOptions = Required; + export interface InternalEditorScrollbarOptions { readonly arrowSize: number; readonly vertical: ScrollbarVisibility; @@ -3534,77 +3521,94 @@ declare namespace monaco.editor { } export enum EditorOption { - accessibilitySupport = 0, - autoClosingBrackets = 1, - autoClosingOvertype = 2, - autoClosingQuotes = 3, - autoIndent = 4, - automaticLayout = 5, - autoSurround = 6, - copyWithSyntaxHighlighting = 7, - cursorBlinking = 8, - cursorSmoothCaretAnimation = 9, - cursorStyle = 10, - cursorSurroundingLines = 11, - cursorWidth = 12, - disableLayerHinting = 13, - dragAndDrop = 14, - emptySelectionClipboard = 15, - extraEditorClassName = 16, - fastScrollSensitivity = 17, - fixedOverflowWidgets = 18, - folding = 19, - fontLigatures = 20, - glyphMargin = 21, - hideCursorInOverviewRuler = 22, - highlightActiveIndentGuide = 23, - inDiffEditor = 24, - lineDecorationsWidth = 25, - lineNumbers = 26, - lineNumbersMinChars = 27, - minimap = 28, - mouseStyle = 29, - mouseWheelScrollSensitivity = 30, - mouseWheelZoom = 31, - multiCursorMergeOverlapping = 32, - multiCursorModifier = 33, - overviewRulerBorder = 34, - overviewRulerLanes = 35, - readOnly = 36, - renderControlCharacters = 37, - renderIndentGuides = 38, - renderFinalNewline = 39, - renderLineHighlight = 40, - renderWhitespace = 41, - revealHorizontalRightPadding = 42, - roundedSelection = 43, - rulers = 44, - scrollbar = 45, - scrollBeyondLastColumn = 46, - scrollBeyondLastLine = 47, - selectionClipboard = 48, - selectOnLineNumbers = 49, - showUnused = 50, - smoothScrolling = 51, - stopRenderingLineAfter = 52, - useTabStops = 53, - wordSeparators = 54, - wordWrap = 55, - wordWrapBreakAfterCharacters = 56, - wordWrapBreakBeforeCharacters = 57, - wordWrapBreakObtrusiveCharacters = 58, - wordWrapColumn = 59, - wordWrapMinified = 60, - wrappingIndent = 61, - ariaLabel = 62, - disableMonospaceOptimizations = 63, - editorClassName = 64, - tabFocusMode = 65, - layoutInfo = 66, - wrappingInfo = 67 + acceptSuggestionOnCommitCharacter = 0, + acceptSuggestionOnEnter = 1, + accessibilitySupport = 2, + autoClosingBrackets = 3, + autoClosingOvertype = 4, + autoClosingQuotes = 5, + autoIndent = 6, + automaticLayout = 7, + autoSurround = 8, + codeLens = 9, + colorDecorators = 10, + contextmenu = 11, + copyWithSyntaxHighlighting = 12, + cursorBlinking = 13, + cursorSmoothCaretAnimation = 14, + cursorStyle = 15, + cursorSurroundingLines = 16, + cursorWidth = 17, + disableLayerHinting = 18, + dragAndDrop = 19, + emptySelectionClipboard = 20, + extraEditorClassName = 21, + fastScrollSensitivity = 22, + fixedOverflowWidgets = 23, + folding = 24, + fontLigatures = 25, + formatOnPaste = 26, + formatOnType = 27, + glyphMargin = 28, + hideCursorInOverviewRuler = 29, + highlightActiveIndentGuide = 30, + inDiffEditor = 31, + lightbulb = 32, + lineDecorationsWidth = 33, + lineNumbers = 34, + lineNumbersMinChars = 35, + links = 36, + matchBrackets = 37, + minimap = 38, + mouseStyle = 39, + mouseWheelScrollSensitivity = 40, + mouseWheelZoom = 41, + multiCursorMergeOverlapping = 42, + multiCursorModifier = 43, + occurrencesHighlight = 44, + overviewRulerBorder = 45, + overviewRulerLanes = 46, + quickSuggestionsDelay = 47, + readOnly = 48, + renderControlCharacters = 49, + renderIndentGuides = 50, + renderFinalNewline = 51, + renderLineHighlight = 52, + renderWhitespace = 53, + revealHorizontalRightPadding = 54, + roundedSelection = 55, + rulers = 56, + scrollbar = 57, + scrollBeyondLastColumn = 58, + scrollBeyondLastLine = 59, + selectionClipboard = 60, + selectionHighlight = 61, + selectOnLineNumbers = 62, + showUnused = 63, + smoothScrolling = 64, + stopRenderingLineAfter = 65, + suggestOnTriggerCharacters = 66, + useTabStops = 67, + wordBasedSuggestions = 68, + wordSeparators = 69, + wordWrap = 70, + wordWrapBreakAfterCharacters = 71, + wordWrapBreakBeforeCharacters = 72, + wordWrapBreakObtrusiveCharacters = 73, + wordWrapColumn = 74, + wordWrapMinified = 75, + wrappingIndent = 76, + ariaLabel = 77, + disableMonospaceOptimizations = 78, + editorClassName = 79, + tabFocusMode = 80, + layoutInfo = 81, + wrappingInfo = 82 } export const EditorOptions: { + acceptSuggestionOnCommitCharacter: any; + acceptSuggestionOnEnter: any; accessibilitySupport: any; autoClosingBrackets: any; autoClosingOvertype: any; @@ -3612,6 +3616,9 @@ declare namespace monaco.editor { autoIndent: any; automaticLayout: any; autoSurround: any; + codeLens: any; + colorDecorators: any; + contextmenu: any; copyWithSyntaxHighlighting: any; cursorBlinking: any; cursorSmoothCaretAnimation: any; @@ -3626,21 +3633,28 @@ declare namespace monaco.editor { fixedOverflowWidgets: any; folding: any; fontLigatures: any; + formatOnPaste: any; + formatOnType: any; glyphMargin: any; hideCursorInOverviewRuler: any; highlightActiveIndentGuide: any; inDiffEditor: any; + lightbulb: any; lineDecorationsWidth: IEditorOption; lineNumbers: any; lineNumbersMinChars: any; + links: any; + matchBrackets: any; minimap: any; mouseStyle: any; mouseWheelScrollSensitivity: any; mouseWheelZoom: any; multiCursorMergeOverlapping: any; multiCursorModifier: any; + occurrencesHighlight: any; overviewRulerBorder: any; overviewRulerLanes: any; + quickSuggestionsDelay: any; readOnly: any; renderControlCharacters: any; renderIndentGuides: any; @@ -3654,11 +3668,14 @@ declare namespace monaco.editor { scrollBeyondLastColumn: any; scrollBeyondLastLine: any; selectionClipboard: any; + selectionHighlight: any; selectOnLineNumbers: any; showUnused: any; smoothScrolling: any; stopRenderingLineAfter: any; + suggestOnTriggerCharacters: any; useTabStops: any; + wordBasedSuggestions: any; wordSeparators: any; wordWrap: any; wordWrapBreakAfterCharacters: any; From 779e29a41cd3d3c32843a3e6e3826a66f18e97a5 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Tue, 3 Sep 2019 11:34:32 -0700 Subject: [PATCH 037/204] Fix some strictPropertyInitialization in search, #78168 --- src/tsconfig.base.json | 1 + src/vs/workbench/api/node/extHostSearch.ts | 4 +-- .../contrib/search/browser/searchView.ts | 34 +++++++++---------- .../contrib/search/common/searchModel.ts | 32 ++++++++++------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/tsconfig.base.json b/src/tsconfig.base.json index 907c210b53038..134310d55d43d 100644 --- a/src/tsconfig.base.json +++ b/src/tsconfig.base.json @@ -11,6 +11,7 @@ "strictBindCallApply": true, "strictNullChecks": true, "forceConsistentCasingInFileNames": true, + "strictPropertyInitialization": true, "baseUrl": ".", "paths": { "vs/*": [ diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index b0e8753c0cd3c..639e1f835c1ed 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -29,8 +29,8 @@ export class ExtHostSearch implements ExtHostSearchShape { private readonly _fileSearchUsedSchemes = new Set(); private _handlePool: number = 0; - private _internalFileSearchHandle: number; - private _internalFileSearchProvider: SearchService | null; + private _internalFileSearchHandle: number = -1; + private _internalFileSearchProvider: SearchService | null = null; private _fileSearchManager: FileSearchManager; diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 4399e11c6fadc..fd16b71ced78f 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -78,9 +78,9 @@ export class SearchView extends ViewletPanel { private static readonly WIDE_VIEW_SIZE = 1000; private static readonly ACTIONS_RIGHT_CLASS_NAME = 'actions-right'; - private isDisposed: boolean; + private isDisposed = false; - private container: HTMLElement; + private container!: HTMLElement; private queryBuilder: QueryBuilder; private viewModel: SearchModel; private memento: Memento; @@ -99,31 +99,31 @@ export class SearchView extends ViewletPanel { private matchFocused: IContextKey; private hasSearchResultsKey: IContextKey; - private state: SearchUIState; + private state: SearchUIState = SearchUIState.Idle; private actions: Array = []; private cancelAction: CancelSearchAction; private refreshAction: RefreshAction; - private contextMenu: IMenu; + private contextMenu: IMenu | null = null; - private tree: WorkbenchObjectTree; - private treeLabels: ResourceLabels; + private tree!: WorkbenchObjectTree; + private treeLabels!: ResourceLabels; private viewletState: MementoObject; - private messagesElement: HTMLElement; + private messagesElement!: HTMLElement; private messageDisposables: IDisposable[] = []; - private searchWidgetsContainerElement: HTMLElement; - private searchWidget: SearchWidget; - private size: dom.Dimension; - private queryDetails: HTMLElement; - private toggleQueryDetailsButton: HTMLElement; - private inputPatternExcludes: ExcludePatternInputWidget; - private inputPatternIncludes: PatternInputWidget; - private resultsElement: HTMLElement; + private searchWidgetsContainerElement!: HTMLElement; + private searchWidget!: SearchWidget; + private size!: dom.Dimension; + private queryDetails!: HTMLElement; + private toggleQueryDetailsButton!: HTMLElement; + private inputPatternExcludes!: ExcludePatternInputWidget; + private inputPatternIncludes!: PatternInputWidget; + private resultsElement!: HTMLElement; private currentSelectedFileMatch: FileMatch | undefined; private delayedRefresh: Delayer; - private changedWhileHidden: boolean; + private changedWhileHidden: boolean = false; private searchWithoutFolderMessageElement: HTMLElement | undefined; @@ -441,7 +441,7 @@ export class SearchView extends ViewletPanel { private refreshAndUpdateCount(event?: IChangeEvent): void { this.searchWidget.setReplaceAllActionState(!this.viewModel.searchResult.isEmpty()); - this.updateSearchResultCount(this.viewModel.searchResult.query.userDisabledExcludesAndIgnoreFiles); + this.updateSearchResultCount(this.viewModel.searchResult.query!.userDisabledExcludesAndIgnoreFiles); return this.refreshTree(event); } diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index 7d003d61cd4f3..e6205366550ee 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -188,11 +188,11 @@ export class FileMatch extends Disposable implements IFileMatch { readonly onDispose: Event = this._onDispose.event; private _resource: URI; - private _model: ITextModel | null; - private _modelListener: IDisposable; + private _model: ITextModel | null = null; + private _modelListener: IDisposable | null = null; private _matches: Map; private _removedMatches: Set; - private _selectedMatch: Match | null; + private _selectedMatch: Match | null = null; private _updateScheduler: RunOnceScheduler; private _modelDecorations: string[] = []; @@ -244,7 +244,7 @@ export class FileMatch extends Disposable implements IFileMatch { this._updateScheduler.cancel(); this._model.deltaDecorations(this._modelDecorations, []); this._model = null; - this._modelListener.dispose(); + this._modelListener!.dispose(); } } @@ -633,10 +633,10 @@ export class SearchResult extends Disposable { readonly onChange: Event = this._onChange.event; private _folderMatches: FolderMatchWithResource[] = []; - private _otherFilesMatch: FolderMatch; + private _otherFilesMatch: FolderMatch | null = null; private _folderMatchesMap: TernarySearchTree = TernarySearchTree.forPaths(); - private _showHighlights: boolean; - private _query: ITextQuery; + private _showHighlights: boolean = false; + private _query: ITextQuery | null = null; private _rangeHighlightDecorations: RangeHighlightDecorations; @@ -653,14 +653,18 @@ export class SearchResult extends Disposable { this._register(this.modelService.onModelAdded(model => this.onModelAdded(model))); } - get query(): ITextQuery { + get query(): ITextQuery | null { return this._query; } - set query(query: ITextQuery) { + set query(query: ITextQuery | null) { // When updating the query we could change the roots, so ensure we clean up the old roots first. this.clear(); - this._folderMatches = (query.folderQueries || []) + if (!query) { + return; + } + + this._folderMatches = (query && query.folderQueries || []) .map(fq => fq.folder) .map((resource, index) => this.createFolderMatchWithResource(resource, resource.toString(), index, query)); @@ -717,6 +721,8 @@ export class SearchResult extends Disposable { clear(): void { this.folderMatches().forEach((folderMatch) => folderMatch.clear()); this.disposeMatches(); + this._folderMatches = []; + this._otherFilesMatch = null; } remove(matches: FileMatch | FolderMatch | (FileMatch | FolderMatch)[]): void { @@ -835,7 +841,7 @@ export class SearchResult extends Disposable { private getFolderMatch(resource: URI): FolderMatch { const folderMatch = this._folderMatchesMap.findSubstr(resource.toString()); - return folderMatch ? folderMatch : this._otherFilesMatch; + return folderMatch ? folderMatch : this._otherFilesMatch!; } private set replacingAll(running: boolean) { @@ -896,7 +902,7 @@ export class SearchModel extends Disposable { private readonly _onReplaceTermChanged: Emitter = this._register(new Emitter()); readonly onReplaceTermChanged: Event = this._onReplaceTermChanged.event; - private currentCancelTokenSource: CancellationTokenSource; + private currentCancelTokenSource: CancellationTokenSource | null = null; constructor( @ISearchService private readonly searchService: ISearchService, @@ -1064,7 +1070,7 @@ export type RenderableMatch = FolderMatch | FolderMatchWithResource | FileMatch export class SearchWorkbenchService implements ISearchWorkbenchService { _serviceBrand: undefined; - private _searchModel: SearchModel; + private _searchModel: SearchModel | null = null; constructor(@IInstantiationService private readonly instantiationService: IInstantiationService) { } From e8fc7db0d1e3f3a94b1cdcc136d146134b7a4c9a Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Tue, 3 Sep 2019 14:28:18 -0700 Subject: [PATCH 038/204] Fix some strictPropertyInitialization in search, #78168 --- src/tsconfig.base.json | 1 - .../search/browser/patternInputWidget.ts | 12 ++++---- .../contrib/search/browser/searchWidget.ts | 24 ++++++++-------- .../search/test/common/searchModel.test.ts | 12 ++++---- .../services/search/common/search.ts | 2 +- .../services/search/common/searchExtTypes.ts | 6 ++-- .../services/search/common/searchService.ts | 2 +- .../services/search/node/fileSearch.ts | 28 +++++++++---------- .../services/search/node/textSearchManager.ts | 14 ++++------ 9 files changed, 49 insertions(+), 52 deletions(-) diff --git a/src/tsconfig.base.json b/src/tsconfig.base.json index 134310d55d43d..907c210b53038 100644 --- a/src/tsconfig.base.json +++ b/src/tsconfig.base.json @@ -11,7 +11,6 @@ "strictBindCallApply": true, "strictNullChecks": true, "forceConsistentCasingInFileNames": true, - "strictPropertyInitialization": true, "baseUrl": ".", "paths": { "vs/*": [ diff --git a/src/vs/workbench/contrib/search/browser/patternInputWidget.ts b/src/vs/workbench/contrib/search/browser/patternInputWidget.ts index c6851d2fa400e..2dc5484c5348e 100644 --- a/src/vs/workbench/contrib/search/browser/patternInputWidget.ts +++ b/src/vs/workbench/contrib/search/browser/patternInputWidget.ts @@ -29,14 +29,14 @@ export class PatternInputWidget extends Widget { static OPTION_CHANGE: string = 'optionChange'; - inputFocusTracker: dom.IFocusTracker; + inputFocusTracker!: dom.IFocusTracker; private width: number; private placeholder: string; private ariaLabel: string; - private domNode: HTMLElement; - protected inputBox: HistoryInputBox; + private domNode!: HTMLElement; + protected inputBox!: HistoryInputBox; private _onSubmit = this._register(new Emitter()); onSubmit: CommonEvent = this._onSubmit.event; @@ -148,7 +148,7 @@ export class PatternInputWidget extends Widget { this.setInputWidth(); } - protected renderSubcontrols(controlsDiv: HTMLDivElement): void { + protected renderSubcontrols(_controlsDiv: HTMLDivElement): void { } private onInputKeyUp(keyboardEvent: IKeyboardEvent) { @@ -174,7 +174,7 @@ export class ExcludePatternInputWidget extends PatternInputWidget { super(parent, contextViewProvider, options, themeService, contextKeyService); } - private useExcludesAndIgnoreFilesBox: Checkbox; + private useExcludesAndIgnoreFilesBox!: Checkbox; dispose(): void { super.dispose(); @@ -209,4 +209,4 @@ export class ExcludePatternInputWidget extends PatternInputWidget { controlsDiv.appendChild(this.useExcludesAndIgnoreFilesBox.domNode); super.renderSubcontrols(controlsDiv); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index 26b29b280c182..e2db0035eb2f5 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -58,7 +58,7 @@ class ReplaceAllAction extends Action { return ReplaceAllAction.fgInstance; } - private _searchWidget: SearchWidget; + private _searchWidget: SearchWidget | null = null; constructor() { super(ReplaceAllAction.ID, '', 'action-replace-all', false); @@ -84,25 +84,25 @@ export class SearchWidget extends Widget { return appendKeyBindingLabel(nls.localize('search.action.replaceAll.enabled.label', "Replace All"), kb, keyBindingService2); } - domNode: HTMLElement; + domNode!: HTMLElement; - searchInput: FindInput; - searchInputFocusTracker: dom.IFocusTracker; + searchInput!: FindInput; + searchInputFocusTracker!: dom.IFocusTracker; private searchInputBoxFocused: IContextKey; - private replaceContainer: HTMLElement; - replaceInput: HistoryInputBox; - private toggleReplaceButton: Button; - private replaceAllAction: ReplaceAllAction; + private replaceContainer!: HTMLElement; + replaceInput!: HistoryInputBox; + private toggleReplaceButton!: Button; + private replaceAllAction!: ReplaceAllAction; private replaceActive: IContextKey; - private replaceActionBar: ActionBar; - replaceInputFocusTracker: dom.IFocusTracker; + private replaceActionBar!: ActionBar; + replaceInputFocusTracker!: dom.IFocusTracker; private replaceInputBoxFocused: IContextKey; private _replaceHistoryDelayer: Delayer; - private _preserveCase: Checkbox; + private _preserveCase!: Checkbox; private ignoreGlobalFindBufferOnNextFocus = false; - private previousGlobalFindBufferValue: string; + private previousGlobalFindBufferValue: string | null = null; private _onSearchSubmit = this._register(new Emitter()); readonly onSearchSubmit: Event = this._onSearchSubmit.event; diff --git a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts index 7ad9e679d1f2b..38d90f655d00d 100644 --- a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts @@ -21,14 +21,14 @@ import { SearchModel } from 'vs/workbench/contrib/search/common/searchModel'; import * as process from 'vs/base/common/process'; const nullEvent = new class { - id: number; - topic: string; - name: string; - description: string; + id: number = -1; + topic!: string; + name!: string; + description!: string; data: any; - startTime: Date; - stopTime: Date; + startTime!: Date; + stopTime!: Date; stop(): void { return; diff --git a/src/vs/workbench/services/search/common/search.ts b/src/vs/workbench/services/search/common/search.ts index 30e38c2c7686d..f66e10720cbe5 100644 --- a/src/vs/workbench/services/search/common/search.ts +++ b/src/vs/workbench/services/search/common/search.ts @@ -517,7 +517,7 @@ export class QueryGlobTester { private _excludeExpression: glob.IExpression; private _parsedExcludeExpression: glob.ParsedExpression; - private _parsedIncludeExpression: glob.ParsedExpression; + private _parsedIncludeExpression: glob.ParsedExpression | null = null; constructor(config: ISearchQuery, folderQuery: IFolderQuery) { this._excludeExpression = { diff --git a/src/vs/workbench/services/search/common/searchExtTypes.ts b/src/vs/workbench/services/search/common/searchExtTypes.ts index 6e75b70b491da..6c818f7fda714 100644 --- a/src/vs/workbench/services/search/common/searchExtTypes.ts +++ b/src/vs/workbench/services/search/common/searchExtTypes.ts @@ -33,8 +33,8 @@ export class Range { this.end = new Position(endLine, endCol); } - isEmpty: boolean; - isSingleLine: boolean; + isEmpty = false; + isSingleLine = false; contains(positionOrRange: Position | Range): boolean { return false; } isEqual(other: Range): boolean { return false; } intersection(range: Range): Range | undefined { return undefined; } @@ -410,4 +410,4 @@ export interface FindTextInFilesOptions { * Number of lines of context to include after each match. */ afterContext?: number; -} \ No newline at end of file +} diff --git a/src/vs/workbench/services/search/common/searchService.ts b/src/vs/workbench/services/search/common/searchService.ts index c6c01de154874..cdb840a46b3c9 100644 --- a/src/vs/workbench/services/search/common/searchService.ts +++ b/src/vs/workbench/services/search/common/searchService.ts @@ -26,7 +26,7 @@ export class SearchService extends Disposable implements ISearchService { _serviceBrand: undefined; - protected diskSearch: ISearchResultProvider; + protected diskSearch: ISearchResultProvider | null = null; private readonly fileSearchProviders = new Map(); private readonly textSearchProviders = new Map(); diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 5ade08b60cae9..8df60ae29c114 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -43,20 +43,20 @@ process.on('exit', () => { export class FileWalker { private config: IFileQuery; private filePattern: string; - private normalizedFilePatternLowercase: string; + private normalizedFilePatternLowercase: string | null = null; private includePattern: glob.ParsedExpression | undefined; private maxResults: number | null; private exists: boolean; - private maxFilesize: number | null; + private maxFilesize: number | null = null; private isLimitHit: boolean; private resultCount: number; - private isCanceled: boolean; - private fileWalkSW: StopWatch; + private isCanceled = false; + private fileWalkSW: StopWatch | null = null; private directoriesWalked: number; private filesWalked: number; private errors: string[]; - private cmdSW: StopWatch; - private cmdResultCount: number; + private cmdSW: StopWatch | null = null; + private cmdResultCount: number = 0; private folderExcludePatterns: Map; private globalExcludePattern: glob.ParsedExpression | undefined; @@ -139,8 +139,8 @@ export class FileWalker { rootFolderDone(null, undefined); } }); - }, (errors, result) => { - this.fileWalkSW.stop(); + }, (errors, _result) => { + this.fileWalkSW!.stop(); const err = errors ? arrays.coalesce(errors)[0] : null; done(err, this.isLimitHit); }); @@ -318,9 +318,7 @@ export class FileWalker { if (err || last) { onData = () => { }; - if (this.cmdSW) { - this.cmdSW.stop(); - } + this.cmdSW!.stop(); } cb(err, stdout, last); }; @@ -455,8 +453,8 @@ export class FileWalker { getStats(): ISearchEngineStats { return { - cmdTime: this.cmdSW && this.cmdSW.elapsed(), - fileWalkTime: this.fileWalkSW.elapsed(), + cmdTime: this.cmdSW!.elapsed(), + fileWalkTime: this.fileWalkSW!.elapsed(), directoriesWalked: this.directoriesWalked, filesWalked: this.filesWalked, cmdResultCount: this.cmdResultCount @@ -578,7 +576,9 @@ export class FileWalker { return true; // support the all-matching wildcard } - return strings.fuzzyContains(path, this.normalizedFilePatternLowercase); + if (this.normalizedFilePatternLowercase) { + return strings.fuzzyContains(path, this.normalizedFilePatternLowercase); + } } // No patterns means we match all diff --git a/src/vs/workbench/services/search/node/textSearchManager.ts b/src/vs/workbench/services/search/node/textSearchManager.ts index b7ac01c436b26..d8f7674c7e5f2 100644 --- a/src/vs/workbench/services/search/node/textSearchManager.ts +++ b/src/vs/workbench/services/search/node/textSearchManager.ts @@ -8,7 +8,6 @@ import { mapArrayOrNot } from 'vs/base/common/arrays'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { toErrorMessage } from 'vs/base/common/errorMessage'; import * as glob from 'vs/base/common/glob'; -import * as resources from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; import { toCanonicalName } from 'vs/base/node/encoding'; import * as pfs from 'vs/base/node/pfs'; @@ -17,9 +16,9 @@ import { TextSearchProvider, TextSearchResult, TextSearchMatch, TextSearchComple export class TextSearchManager { - private collector: TextSearchResultsCollector; + private collector: TextSearchResultsCollector | null = null; - private isLimitHit: boolean; + private isLimitHit = false; private resultCount = 0; constructor(private query: ITextQuery, private provider: TextSearchProvider, private _pfs: typeof pfs = pfs) { @@ -52,7 +51,7 @@ export class TextSearchManager { const newResultSize = this.resultSize(result); this.resultCount += newResultSize; if (newResultSize > 0) { - this.collector.add(result, folderIdx); + this.collector!.add(result, folderIdx); } } }; @@ -62,7 +61,7 @@ export class TextSearchManager { return this.searchInFolder(fq, r => onResult(r, i), tokenSource.token); })).then(results => { tokenSource.dispose(); - this.collector.flush(); + this.collector!.flush(); const someFolderHitLImit = results.some(result => !!result && !!result.limitHit); resolve({ @@ -198,8 +197,7 @@ function patternInfoToQuery(patternInfo: IPatternInfo): TextSearchQuery { export class TextSearchResultsCollector { private _batchedCollector: BatchedCollector; - private _currentFolderIdx: number; - private _currentUri: URI; + private _currentFolderIdx: number = -1; private _currentFileMatch: IFileMatch | null = null; constructor(private _onResult: (result: IFileMatch[]) => void) { @@ -210,7 +208,7 @@ export class TextSearchResultsCollector { // Collects TextSearchResults into IInternalFileMatches and collates using BatchedCollector. // This is efficient for ripgrep which sends results back one file at a time. It wouldn't be efficient for other search // providers that send results in random order. We could do this step afterwards instead. - if (this._currentFileMatch && (this._currentFolderIdx !== folderIdx || !resources.isEqual(this._currentUri, data.uri))) { + if (this._currentFileMatch && this._currentFolderIdx !== folderIdx) { this.pushToCollector(); this._currentFileMatch = null; } From 104ab4ad2b7df255c39595ff69041e3c81469274 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Tue, 3 Sep 2019 15:03:54 -0700 Subject: [PATCH 039/204] Fix #79839 --- src/vs/editor/contrib/hover/hover.css | 4 ++++ src/vs/editor/contrib/suggest/media/suggest.css | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/hover/hover.css b/src/vs/editor/contrib/hover/hover.css index 066390051929d..0906f2aed721c 100644 --- a/src/vs/editor/contrib/hover/hover.css +++ b/src/vs/editor/contrib/hover/hover.css @@ -55,9 +55,13 @@ margin-bottom: 0; } +/* MarkupContent Layout */ .monaco-editor-hover ul { padding-left: 20px; } +.monaco-editor-hover ol { + padding-left: 20px; +} .monaco-editor-hover li > p { margin-bottom: 0; diff --git a/src/vs/editor/contrib/suggest/media/suggest.css b/src/vs/editor/contrib/suggest/media/suggest.css index a0115bd552864..481a63fec106b 100644 --- a/src/vs/editor/contrib/suggest/media/suggest.css +++ b/src/vs/editor/contrib/suggest/media/suggest.css @@ -45,11 +45,13 @@ float: right; } -/* Details Layout */ +/* MarkupContent Layout */ .monaco-editor .suggest-widget > .details ul { padding-left: 20px; } - +.monaco-editor .suggest-widget > .details ol { + padding-left: 20px; +} /* Styles for Message element for when widget is loading or is empty */ .monaco-editor .suggest-widget > .message { From 109add76dad3dd1cbe05215d26cb62be6dbfdc47 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Tue, 3 Sep 2019 15:31:44 -0700 Subject: [PATCH 040/204] Fix search tests after strictPropInit --- src/vs/workbench/services/search/node/fileSearch.ts | 4 +++- src/vs/workbench/services/search/node/textSearchManager.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 8df60ae29c114..fc838b95e80ca 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -318,7 +318,9 @@ export class FileWalker { if (err || last) { onData = () => { }; - this.cmdSW!.stop(); + if (this.cmdSW) { + this.cmdSW.stop(); + } } cb(err, stdout, last); }; diff --git a/src/vs/workbench/services/search/node/textSearchManager.ts b/src/vs/workbench/services/search/node/textSearchManager.ts index d8f7674c7e5f2..9d566a9bdabaa 100644 --- a/src/vs/workbench/services/search/node/textSearchManager.ts +++ b/src/vs/workbench/services/search/node/textSearchManager.ts @@ -7,6 +7,7 @@ import * as path from 'vs/base/common/path'; import { mapArrayOrNot } from 'vs/base/common/arrays'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { toErrorMessage } from 'vs/base/common/errorMessage'; +import * as resources from 'vs/base/common/resources'; import * as glob from 'vs/base/common/glob'; import { URI } from 'vs/base/common/uri'; import { toCanonicalName } from 'vs/base/node/encoding'; @@ -198,6 +199,7 @@ export class TextSearchResultsCollector { private _batchedCollector: BatchedCollector; private _currentFolderIdx: number = -1; + private _currentUri: URI; private _currentFileMatch: IFileMatch | null = null; constructor(private _onResult: (result: IFileMatch[]) => void) { @@ -208,7 +210,7 @@ export class TextSearchResultsCollector { // Collects TextSearchResults into IInternalFileMatches and collates using BatchedCollector. // This is efficient for ripgrep which sends results back one file at a time. It wouldn't be efficient for other search // providers that send results in random order. We could do this step afterwards instead. - if (this._currentFileMatch && this._currentFolderIdx !== folderIdx) { + if (this._currentFileMatch && (this._currentFolderIdx !== folderIdx || !resources.isEqual(this._currentUri, data.uri))) { this.pushToCollector(); this._currentFileMatch = null; } From b5251d43fa8049c32262730e71342ea8fc82da3a Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 3 Sep 2019 16:51:27 -0700 Subject: [PATCH 041/204] bump version --- build/monaco/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/monaco/package.json b/build/monaco/package.json index 1962694ce6ddc..1ff3e4e72f3fe 100644 --- a/build/monaco/package.json +++ b/build/monaco/package.json @@ -1,7 +1,7 @@ { "name": "monaco-editor-core", "private": true, - "version": "0.16.0", + "version": "0.18.0", "description": "A browser based code editor", "author": "Microsoft Corporation", "license": "MIT", From 8755b78acf4432f9cfd88b39acd82851423fd897 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 07:33:39 +0200 Subject: [PATCH 042/204] web - add pwa icons --- build/gulpfile.vscode.web.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js index edd34cd39316e..1c21e3cd5a357 100644 --- a/build/gulpfile.vscode.web.js +++ b/build/gulpfile.vscode.web.js @@ -118,7 +118,10 @@ function packageTask(sourceFolderName, destinationFolderName) { const favicon = gulp.src('resources/server/favicon.ico', { base: 'resources/server' }); const manifest = gulp.src('resources/server/manifest.json', { base: 'resources/server' }); - const pwaicon = gulp.src('resources/server/code.png', { base: 'resources/server' }); + const pwaicons = es.merge( + gulp.src('resources/server/code-192.png', { base: 'resources/server' }), + gulp.src('resources/server/code-512.png', { base: 'resources/server' }) + ); let all = es.merge( packageJsonStream, @@ -128,7 +131,7 @@ function packageTask(sourceFolderName, destinationFolderName) { deps, favicon, manifest, - pwaicon + pwaicons ); let result = all From bfad559382565c066d4874ba35a410fce7e191bf Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 07:36:28 +0200 Subject: [PATCH 043/204] :up: distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44e5ecd868242..0b46f5033ca81 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.39.0", - "distro": "02850a424614d800c64b5b0a03ccc751b6383760", + "distro": "1bba48aa5a9271599af81fc8ca35b813c16e7c4b", "author": { "name": "Microsoft Corporation" }, From 5d7c8d9212ede10c81a078857ca15e279445878a Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 Sep 2019 08:05:36 +0200 Subject: [PATCH 044/204] fix i18n for extensions --- build/gulpfile.vscode.js | 4 ++-- build/lib/i18n.js | 10 +++++----- build/lib/i18n.ts | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 6bb695db68cfe..c891b8f48e021 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -480,7 +480,7 @@ gulp.task(task.define( optimizeVSCodeTask, function () { const pathToMetadata = './out-vscode/nls.metadata.json'; - const pathToExtensions = './extensions/*'; + const pathToExtensions = '.build/extensions/*'; const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}'; return es.merge( @@ -501,7 +501,7 @@ gulp.task(task.define( optimizeVSCodeTask, function () { const pathToMetadata = './out-vscode/nls.metadata.json'; - const pathToExtensions = './extensions/*'; + const pathToExtensions = '.build/extensions/*'; const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}'; return es.merge( diff --git a/build/lib/i18n.js b/build/lib/i18n.js index 067e1e66889b2..f7302fc12eefc 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -580,7 +580,7 @@ function createXlfFilesForExtensions() { } return _xlf; } - gulp.src([`./extensions/${extensionName}/package.nls.json`, `./extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(event_stream_1.through(function (file) { + gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(event_stream_1.through(function (file) { if (file.isBuffer()) { const buffer = file.contents; const basename = path.basename(file.path); @@ -603,7 +603,7 @@ function createXlfFilesForExtensions() { } else if (basename === 'nls.metadata.json') { const json = JSON.parse(buffer.toString('utf8')); - const relPath = path.relative(`./extensions/${extensionName}`, path.dirname(file.path)); + const relPath = path.relative(`.build/extensions/${extensionName}`, path.dirname(file.path)); for (let file in json) { const fileContent = json[file]; getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages); @@ -906,8 +906,8 @@ function pullCoreAndExtensionsXlfFiles(apiHostname, username, password, language _coreAndExtensionResources.push(...json.workbench); // extensions let extensionsToLocalize = Object.create(null); - glob.sync('./extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); - glob.sync('./extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); + glob.sync('.build/extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); + glob.sync('.build/extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); Object.keys(extensionsToLocalize).forEach(extension => { _coreAndExtensionResources.push({ name: extension, project: extensionsProject }); }); @@ -1080,7 +1080,7 @@ function prepareI18nPackFiles(externalExtensions, resultingTranslationPaths, pse resultingTranslationPaths.push({ id: 'vscode', resourceName: 'main.i18n.json' }); this.queue(translatedMainFile); for (let extension in extensionsPacks) { - const translatedExtFile = createI18nFile(`./extensions/${extension}`, extensionsPacks[extension]); + const translatedExtFile = createI18nFile(`.build/extensions/${extension}`, extensionsPacks[extension]); this.queue(translatedExtFile); const externalExtensionId = externalExtensions[extension]; if (externalExtensionId) { diff --git a/build/lib/i18n.ts b/build/lib/i18n.ts index 9f53df17bad6d..81bf1d3991ba6 100644 --- a/build/lib/i18n.ts +++ b/build/lib/i18n.ts @@ -701,7 +701,7 @@ export function createXlfFilesForExtensions(): ThroughStream { } return _xlf; } - gulp.src([`./extensions/${extensionName}/package.nls.json`, `./extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(through(function (file: File) { + gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(through(function (file: File) { if (file.isBuffer()) { const buffer: Buffer = file.contents as Buffer; const basename = path.basename(file.path); @@ -721,7 +721,7 @@ export function createXlfFilesForExtensions(): ThroughStream { getXlf().addFile(`extensions/${extensionName}/package`, keys, messages); } else if (basename === 'nls.metadata.json') { const json: BundledExtensionFormat = JSON.parse(buffer.toString('utf8')); - const relPath = path.relative(`./extensions/${extensionName}`, path.dirname(file.path)); + const relPath = path.relative(`.build/extensions/${extensionName}`, path.dirname(file.path)); for (let file in json) { const fileContent = json[file]; getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages); @@ -1045,8 +1045,8 @@ export function pullCoreAndExtensionsXlfFiles(apiHostname: string, username: str // extensions let extensionsToLocalize = Object.create(null); - glob.sync('./extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); - glob.sync('./extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); + glob.sync('.build/extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); + glob.sync('.build/extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); Object.keys(extensionsToLocalize).forEach(extension => { _coreAndExtensionResources.push({ name: extension, project: extensionsProject }); @@ -1245,7 +1245,7 @@ export function prepareI18nPackFiles(externalExtensions: Map, resultingT this.queue(translatedMainFile); for (let extension in extensionsPacks) { - const translatedExtFile = createI18nFile(`./extensions/${extension}`, extensionsPacks[extension]); + const translatedExtFile = createI18nFile(`.build/extensions/${extension}`, extensionsPacks[extension]); this.queue(translatedExtFile); const externalExtensionId = externalExtensions[extension]; From e5db2c31e4f7459a084977ed5bafc2a39ff50a37 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 08:44:43 +0200 Subject: [PATCH 045/204] workaround #80251 --- src/vs/workbench/contrib/search/test/common/searchModel.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts index 38d90f655d00d..a834061021843 100644 --- a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts @@ -158,6 +158,7 @@ suite('SearchModel', () => { const testObject: SearchModel = instantiationService.createInstance(SearchModel); await testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries }); + await timeout(0); // TODO@rob https://github.com/microsoft/vscode/issues/80251 assert.ok(target.calledThrice); const data = target.args[0]; From 4cd50470733dfaaf9cd3f2ee863cef89fadde4b2 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 08:55:20 +0200 Subject: [PATCH 046/204] build :lipstick: --- build/azure-pipelines/darwin/product-build-darwin.yml | 3 +++ build/azure-pipelines/linux/product-build-linux.yml | 3 +++ build/azure-pipelines/win32/product-build-win32.yml | 3 +++ extensions/vscode-test-resolver/src/extension.ts | 2 +- scripts/test-integration.bat | 9 ++++++--- scripts/test-integration.sh | 8 +++++--- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index 4595281f50864..71dea8f381d7c 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -102,6 +102,9 @@ steps: condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - script: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. set -e APP_ROOT=$(agent.builddirectory)/VSCode-darwin APP_NAME="`ls $APP_ROOT | head -n 1`" diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 32ff5710091b4..0d01ba8a60833 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -105,6 +105,9 @@ steps: condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - script: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. set -e APP_ROOT=$(agent.builddirectory)/VSCode-linux-x64 APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index 2785923c587f6..ae36c8cbe841b 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -113,6 +113,9 @@ steps: condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - powershell: | + # Figure out the full absolute path of the product we just built + # including the remote server and configure the integration tests + # to run with these builds instead of running out of sources. . build/azure-pipelines/win32/exec.ps1 $ErrorActionPreference = "Stop" $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)" diff --git a/extensions/vscode-test-resolver/src/extension.ts b/extensions/vscode-test-resolver/src/extension.ts index cb562bf3896b3..64734212d79c9 100644 --- a/extensions/vscode-test-resolver/src/extension.ts +++ b/extensions/vscode-test-resolver/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath }); } else { const serverCommand = process.platform === 'win32' ? 'server.cmd' : 'server.sh'; - let serverLocation = env['VSCODE_REMOTE_SERVER_PATH']; // support environment + let serverLocation = env['VSCODE_REMOTE_SERVER_PATH']; // support environment variable to specify location of server on disk if (!serverLocation) { const serverBin = path.join(remoteDataDir, 'bin'); progress.report({ message: 'Installing VSCode Server' }); diff --git a/scripts/test-integration.bat b/scripts/test-integration.bat index 280bc476ebea0..d557a24edaa39 100644 --- a/scripts/test-integration.bat +++ b/scripts/test-integration.bat @@ -5,11 +5,14 @@ pushd %~dp0\.. set VSCODEUSERDATADIR=%TMP%\vscodeuserfolder-%RANDOM%-%TIME:~6,5% +:: Figure out which Electron to use for running tests if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" ( - :: code.bat makes sure Test Extensions are compiled + :: Run out of sources: no need to compile as code.sh takes care of it set INTEGRATION_TEST_ELECTRON_PATH=.\scripts\code.bat + + echo "Running integration tests out of sources." ) else ( - :: Compile Test Extensions + :: Run from a built: need to compile all test extensions call yarn gulp compile-extension:vscode-api-tests call yarn gulp compile-extension:vscode-colorize-tests call yarn gulp compile-extension:markdown-language-features @@ -18,7 +21,7 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" ( call yarn gulp compile-extension:html-language-features-server call yarn gulp compile-extension:json-language-features-server - echo "Using %INTEGRATION_TEST_ELECTRON_PATH% as Electron path" + echo "Running integration tests with '%INTEGRATION_TEST_ELECTRON_PATH%' as build." ) :: Integration & performance tests in AMD diff --git a/scripts/test-integration.sh b/scripts/test-integration.sh index 0bcbcee72f78b..0d236609708bd 100755 --- a/scripts/test-integration.sh +++ b/scripts/test-integration.sh @@ -15,10 +15,12 @@ cd $ROOT # Figure out which Electron to use for running tests if [ -z "$INTEGRATION_TEST_ELECTRON_PATH" ] then - # code.sh makes sure Test Extensions are compiled + # Run out of sources: no need to compile as code.sh takes care of it INTEGRATION_TEST_ELECTRON_PATH="./scripts/code.sh" + + echo "Running integration tests out of sources." else - # Compile Test Extensions + # Run from a built: need to compile all test extensions yarn gulp compile-extension:vscode-api-tests yarn gulp compile-extension:vscode-colorize-tests yarn gulp compile-extension:markdown-language-features @@ -27,7 +29,7 @@ else yarn gulp compile-extension:html-language-features-server yarn gulp compile-extension:json-language-features-server - echo "Using $INTEGRATION_TEST_ELECTRON_PATH as Electron path" + echo "Running integration tests with '$INTEGRATION_TEST_ELECTRON_PATH' as build." fi # Integration tests in AMD From ddff4bc8933217a797a6ae8695333acbdf7c8d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Wed, 4 Sep 2019 10:55:47 +0200 Subject: [PATCH 047/204] Fix AsyncDataTree concurrent refresh/expand calls (#80300) * failing test for #80098 * AsyncDataTree: watch out for concurrent refresh and expand calls fixes #80098 * remove explorer workaround * cleanup rogue import --- src/vs/base/browser/ui/tree/asyncDataTree.ts | 43 +++--- .../browser/ui/tree/asyncDataTree.test.ts | 142 ++++++++++++++++++ .../files/browser/views/explorerView.ts | 3 - 3 files changed, 166 insertions(+), 22 deletions(-) diff --git a/src/vs/base/browser/ui/tree/asyncDataTree.ts b/src/vs/base/browser/ui/tree/asyncDataTree.ts index a8dca1e311a1e..f9380aaf2430a 100644 --- a/src/vs/base/browser/ui/tree/asyncDataTree.ts +++ b/src/vs/base/browser/ui/tree/asyncDataTree.ts @@ -24,7 +24,7 @@ interface IAsyncDataTreeNode { readonly parent: IAsyncDataTreeNode | null; readonly children: IAsyncDataTreeNode[]; readonly id?: string | null; - loading: boolean; + refreshPromise: Promise | undefined; hasChildren: boolean; stale: boolean; slow: boolean; @@ -41,7 +41,7 @@ function createAsyncDataTreeNode(props: IAsyncDataTreeNodeRequiredPro return { ...props, children: [], - loading: false, + refreshPromise: undefined, stale: true, slow: false, collapsedByDefault: undefined @@ -468,8 +468,8 @@ export class AsyncDataTree implements IDisposable throw new TreeError(this.user, 'Tree input not set'); } - if (this.root.loading) { - await this.subTreeRefreshPromises.get(this.root)!; + if (this.root.refreshPromise) { + await this.root.refreshPromise; await Event.toPromise(this._onDidRender.event); } @@ -519,21 +519,26 @@ export class AsyncDataTree implements IDisposable throw new TreeError(this.user, 'Tree input not set'); } - if (this.root.loading) { - await this.subTreeRefreshPromises.get(this.root)!; + if (this.root.refreshPromise) { + await this.root.refreshPromise; await Event.toPromise(this._onDidRender.event); } const node = this.getDataNode(element); - if (node !== this.root && !node.loading && !this.tree.isCollapsed(node)) { + if (node.refreshPromise) { + await this.root.refreshPromise; + await Event.toPromise(this._onDidRender.event); + } + + if (node !== this.root && !node.refreshPromise && !this.tree.isCollapsed(node)) { return false; } const result = this.tree.expand(node === this.root ? null : node, recursive); - if (node.loading) { - await this.subTreeRefreshPromises.get(node)!; + if (node.refreshPromise) { + await this.root.refreshPromise; await Event.toPromise(this._onDidRender.event); } @@ -677,18 +682,18 @@ export class AsyncDataTree implements IDisposable return result; } - result = this.doRefreshSubTree(node, recursive, viewStateContext); - this.subTreeRefreshPromises.set(node, result); - - try { - await result; - } finally { - this.subTreeRefreshPromises.delete(node); - } + return this.doRefreshSubTree(node, recursive, viewStateContext); } private async doRefreshSubTree(node: IAsyncDataTreeNode, recursive: boolean, viewStateContext?: IAsyncDataTreeViewStateContext): Promise { - node.loading = true; + let done: () => void; + node.refreshPromise = new Promise(c => done = c); + this.subTreeRefreshPromises.set(node, node.refreshPromise); + + node.refreshPromise.finally(() => { + node.refreshPromise = undefined; + this.subTreeRefreshPromises.delete(node); + }); try { const childrenToRefresh = await this.doRefreshNode(node, recursive, viewStateContext); @@ -696,7 +701,7 @@ export class AsyncDataTree implements IDisposable await Promise.all(childrenToRefresh.map(child => this.doRefreshSubTree(child, recursive, viewStateContext))); } finally { - node.loading = false; + done!(); } } diff --git a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts index 1aa1c6fa550bd..0c7d67a253a87 100644 --- a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts +++ b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts @@ -8,6 +8,7 @@ import { ITreeNode, ITreeRenderer, IAsyncDataSource } from 'vs/base/browser/ui/t import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree'; import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list/list'; import { hasClass } from 'vs/base/browser/dom'; +import { timeout } from 'vs/base/common/async'; interface Element { id: string; @@ -379,4 +380,145 @@ suite('AsyncDataTree', function () { assert(!tree.getNode(_('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root', 'a']); }); + + test('issue #80098 - concurrent refresh and expand', async () => { + const container = document.createElement('div'); + container.style.width = '200px'; + container.style.height = '200px'; + + const delegate = new class implements IListVirtualDelegate { + getHeight() { return 20; } + getTemplateId(element: Element): string { return 'default'; } + }; + + const renderer = new class implements ITreeRenderer { + readonly templateId = 'default'; + renderTemplate(container: HTMLElement): HTMLElement { + return container; + } + renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { + templateData.textContent = element.element.id; + } + disposeTemplate(templateData: HTMLElement): void { + // noop + } + }; + + const calls: Function[] = []; + const dataSource = new class implements IAsyncDataSource { + hasChildren(element: Element): boolean { + return !!element.children && element.children.length > 0; + } + getChildren(element: Element): Promise { + return new Promise(c => calls.push(() => c(element.children))); + } + }; + + const identityProvider = new class implements IIdentityProvider { + getId(element: Element) { + return element.id; + } + }; + + const root: Element = { + id: 'root', + children: [{ + id: 'a', children: [{ + id: 'aa' + }] + }] + }; + + const _: (id: string) => Element = find.bind(null, root.children); + + const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + tree.layout(200); + + const pSetInput = tree.setInput(root); + calls.pop()!(); // resolve getChildren(root) + await pSetInput; + + const pUpdateChildrenA = tree.updateChildren(_('a')); + const pExpandA = tree.expand(_('a')); + assert.equal(calls.length, 1, 'expand(a) still hasn\'t called getChildren(a)'); + + calls.pop()!(); + assert.equal(calls.length, 0, 'no pending getChildren calls'); + + await pUpdateChildrenA; + assert.equal(calls.length, 0, 'expand(a) should not have forced a second refresh'); + + const result = await pExpandA; + assert.equal(result, true, 'expand(a) should be done'); + }); + + test('issue #80098 - first expand should call getChildren', async () => { + const container = document.createElement('div'); + container.style.width = '200px'; + container.style.height = '200px'; + + const delegate = new class implements IListVirtualDelegate { + getHeight() { return 20; } + getTemplateId(element: Element): string { return 'default'; } + }; + + const renderer = new class implements ITreeRenderer { + readonly templateId = 'default'; + renderTemplate(container: HTMLElement): HTMLElement { + return container; + } + renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { + templateData.textContent = element.element.id; + } + disposeTemplate(templateData: HTMLElement): void { + // noop + } + }; + + const calls: Function[] = []; + const dataSource = new class implements IAsyncDataSource { + hasChildren(element: Element): boolean { + return !!element.children && element.children.length > 0; + } + getChildren(element: Element): Promise { + return new Promise(c => calls.push(() => c(element.children))); + } + }; + + const identityProvider = new class implements IIdentityProvider { + getId(element: Element) { + return element.id; + } + }; + + const root: Element = { + id: 'root', + children: [{ + id: 'a', children: [{ + id: 'aa' + }] + }] + }; + + const _: (id: string) => Element = find.bind(null, root.children); + + const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + tree.layout(200); + + const pSetInput = tree.setInput(root); + calls.pop()!(); // resolve getChildren(root) + await pSetInput; + + const pExpandA = tree.expand(_('a')); + assert.equal(calls.length, 1, 'expand(a) should\'ve called getChildren(a)'); + + let race = await Promise.race([pExpandA.then(() => 'expand'), timeout(1).then(() => 'timeout')]); + assert.equal(race, 'timeout', 'expand(a) should not be yet done'); + + calls.pop()!(); + assert.equal(calls.length, 0, 'no pending getChildren calls'); + + race = await Promise.race([pExpandA.then(() => 'expand'), timeout(1).then(() => 'timeout')]); + assert.equal(race, 'expand', 'expand(a) should now be done'); + }); }); diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index bb0f7e04b7f78..52583917ba028 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -50,7 +50,6 @@ import { first } from 'vs/base/common/arrays'; import { withNullAsUndefined } from 'vs/base/common/types'; import { IFileService, FileSystemProviderCapabilities } from 'vs/platform/files/common/files'; import { dispose } from 'vs/base/common/lifecycle'; -import { timeout } from 'vs/base/common/async'; export class ExplorerView extends ViewletPanel { static readonly ID: string = 'workbench.explorer.fileView'; @@ -522,8 +521,6 @@ export class ExplorerView extends ViewletPanel { while (item && item.resource.toString() !== resource.toString()) { await this.tree.expand(item); - // Tree returns too early from the expand, need to wait for next tick #77106 - await timeout(0); item = first(values(item.children), i => isEqualOrParent(resource, i.resource)); } From 07d19b90a594a0f8efe9133237e939c511b5399e Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 4 Sep 2019 10:52:31 +0200 Subject: [PATCH 048/204] remove automatic merging/overwriting of decorations, simplify proposed API, #54938 --- extensions/git/src/decorationProvider.ts | 7 ++-- extensions/git/src/repository.ts | 7 ++-- src/vs/vscode.proposed.d.ts | 7 ---- .../api/browser/mainThreadDecorations.ts | 5 ++- src/vs/workbench/api/browser/mainThreadSCM.ts | 7 ++-- .../workbench/api/common/extHost.protocol.ts | 8 ++--- .../api/common/extHostDecorations.ts | 2 +- src/vs/workbench/api/common/extHostSCM.ts | 6 +--- src/vs/workbench/browser/labels.ts | 7 ++-- .../contrib/scm/browser/scmViewlet.ts | 2 +- src/vs/workbench/contrib/scm/common/scm.ts | 5 --- .../decorations/browser/decorations.ts | 4 +-- .../decorations/browser/decorationsService.ts | 35 ++++--------------- .../test/browser/decorationsService.test.ts | 26 -------------- 14 files changed, 23 insertions(+), 105 deletions(-) diff --git a/extensions/git/src/decorationProvider.ts b/extensions/git/src/decorationProvider.ts index 9f17b20ee8ee0..a939af65055e0 100644 --- a/extensions/git/src/decorationProvider.ts +++ b/extensions/git/src/decorationProvider.ts @@ -9,7 +9,7 @@ import { Repository, GitResourceGroup } from './repository'; import { Model } from './model'; import { debounce } from './decorators'; import { filterEvent, dispose, anyEvent, fireEvent } from './util'; -import { GitErrorCodes, Status } from './api/git'; +import { GitErrorCodes } from './api/git'; type Callback = { resolve: (status: boolean) => void, reject: (err: any) => void }; @@ -123,10 +123,7 @@ class GitDecorationProvider implements DecorationProvider { private collectDecorationData(group: GitResourceGroup, bucket: Map): void { group.resourceStates.forEach(r => { - if (r.resourceDecoration - && r.type !== Status.DELETED - && r.type !== Status.INDEX_DELETED - ) { + if (r.resourceDecoration) { // not deleted and has a decoration bucket.set(r.original.toString(), r.resourceDecoration); } diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index bf37d036d5ca1..3217ad17789f8 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -157,10 +157,7 @@ export class Resource implements SourceControlResourceState { const tooltip = this.tooltip; const strikeThrough = this.strikeThrough; const faded = this.faded; - const letter = this.letter; - const color = this.color; - - return { strikeThrough, faded, tooltip, light, dark, letter, color, source: 'git.resource' /*todo@joh*/ }; + return { strikeThrough, faded, tooltip, light, dark }; } get letter(): string { @@ -252,7 +249,7 @@ export class Resource implements SourceControlResourceState { const letter = this.letter; const color = this.color; const priority = this.priority; - return { bubble: true, source: 'git.resource', title, letter, color, priority }; + return { bubble: true, title, letter, color, priority }; } constructor( diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index aea830a6a9fc4..f26c8501c1f46 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -563,13 +563,6 @@ declare module 'vscode' { color?: ThemeColor; priority?: number; bubble?: boolean; - source?: string; // hacky... we should remove it and use equality under the hood - } - - export interface SourceControlResourceDecorations { - source?: string; - letter?: string; - color?: ThemeColor; } export interface DecorationProvider { diff --git a/src/vs/workbench/api/browser/mainThreadDecorations.ts b/src/vs/workbench/api/browser/mainThreadDecorations.ts index f34105ddf73a5..08d46a9840595 100644 --- a/src/vs/workbench/api/browser/mainThreadDecorations.ts +++ b/src/vs/workbench/api/browser/mainThreadDecorations.ts @@ -93,14 +93,13 @@ export class MainThreadDecorations implements MainThreadDecorationsShape { if (!data) { return undefined; } - const [weight, bubble, tooltip, letter, themeColor, source] = data; + const [weight, bubble, tooltip, letter, themeColor] = data; return { weight: weight || 0, bubble: bubble || false, color: themeColor && themeColor.id, tooltip, - letter, - source, + letter }; }); } diff --git a/src/vs/workbench/api/browser/mainThreadSCM.ts b/src/vs/workbench/api/browser/mainThreadSCM.ts index 089cb517b4565..e71a7c8a007c2 100644 --- a/src/vs/workbench/api/browser/mainThreadSCM.ts +++ b/src/vs/workbench/api/browser/mainThreadSCM.ts @@ -198,7 +198,7 @@ class MainThreadSCMProvider implements ISCMProvider { for (const [start, deleteCount, rawResources] of groupSlices) { const resources = rawResources.map(rawResource => { - const [handle, sourceUri, icons, tooltip, strikeThrough, faded, source, letter, color] = rawResource; + const [handle, sourceUri, icons, tooltip, strikeThrough, faded] = rawResource; const icon = icons[0]; const iconDark = icons[1] || icon; const decorations = { @@ -206,10 +206,7 @@ class MainThreadSCMProvider implements ISCMProvider { iconDark: iconDark ? URI.parse(iconDark) : undefined, tooltip, strikeThrough, - faded, - source, - letter, - color: color ? color.id : undefined + faded }; return new MainThreadSCMResource( diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index a6ac9b8086c7e..8ffe27541cdfa 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -661,11 +661,7 @@ export type SCMRawResource = [ string[] /*icons: light, dark*/, string /*tooltip*/, boolean /*strike through*/, - boolean /*faded*/, - - string | undefined /*source*/, - string | undefined /*letter*/, - ThemeColor | null /*color*/ + boolean /*faded*/ ]; export type SCMRawResourceSplice = [ @@ -1272,7 +1268,7 @@ export interface DecorationRequest { readonly uri: UriComponents; } -export type DecorationData = [number, boolean, string, string, ThemeColor, string]; +export type DecorationData = [number, boolean, string, string, ThemeColor]; export type DecorationReply = { [id: number]: DecorationData }; export interface ExtHostDecorationsShape { diff --git a/src/vs/workbench/api/common/extHostDecorations.ts b/src/vs/workbench/api/common/extHostDecorations.ts index b62fc15ee328f..739854ec18323 100644 --- a/src/vs/workbench/api/common/extHostDecorations.ts +++ b/src/vs/workbench/api/common/extHostDecorations.ts @@ -63,7 +63,7 @@ export class ExtHostDecorations implements IExtHostDecorations { console.warn(`INVALID decoration from extension '${extensionId.value}'. The 'letter' must be set and be one character, not '${data.letter}'.`); } if (data) { - result[id] = [data.priority, data.bubble, data.title, data.letter, data.color, data.source]; + result[id] = [data.priority, data.bubble, data.title, data.letter, data.color]; } }, err => { diff --git a/src/vs/workbench/api/common/extHostSCM.ts b/src/vs/workbench/api/common/extHostSCM.ts index 00b3315f6c723..9ab1b4977613f 100644 --- a/src/vs/workbench/api/common/extHostSCM.ts +++ b/src/vs/workbench/api/common/extHostSCM.ts @@ -319,11 +319,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG const strikeThrough = r.decorations && !!r.decorations.strikeThrough; const faded = r.decorations && !!r.decorations.faded; - const source = r.decorations && r.decorations.source || undefined; - const letter = r.decorations && r.decorations.letter || undefined; - const color = r.decorations && r.decorations.color || undefined; - - const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded, source, letter, color] as SCMRawResource; + const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded] as SCMRawResource; return { rawResource, handle }; }); diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index 35a19a119b411..2b5d9be879046 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -14,7 +14,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; -import { IDecorationsService, IResourceDecorationChangeEvent, IDecorationData } from 'vs/workbench/services/decorations/browser/decorations'; +import { IDecorationsService, IResourceDecorationChangeEvent } from 'vs/workbench/services/decorations/browser/decorations'; import { Schemas } from 'vs/base/common/network'; import { FileKind, FILES_ASSOCIATIONS_CONFIG, IFileService } from 'vs/platform/files/common/files'; import { ITextModel } from 'vs/editor/common/model'; @@ -34,7 +34,7 @@ export interface IResourceLabelProps { export interface IResourceLabelOptions extends IIconLabelValueOptions { fileKind?: FileKind; - fileDecorations?: { colors: boolean, badges: boolean, data?: IDecorationData }; + fileDecorations?: { colors: boolean, badges: boolean }; descriptionVerbosity?: Verbosity; } @@ -468,8 +468,7 @@ class ResourceLabelWidget extends IconLabel { if (this.options && this.options.fileDecorations && resource) { const deco = this.decorationsService.getDecoration( resource, - this.options.fileKind !== FileKind.FILE, - this.options.fileDecorations.data + this.options.fileKind !== FileKind.FILE ); if (deco) { diff --git a/src/vs/workbench/contrib/scm/browser/scmViewlet.ts b/src/vs/workbench/contrib/scm/browser/scmViewlet.ts index 6c1b3ed618257..e01dbff4d32cb 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewlet.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewlet.ts @@ -495,7 +495,7 @@ class ResourceRenderer implements IListRenderer const theme = this.themeService.getTheme(); const icon = theme.type === LIGHT ? resource.decorations.icon : resource.decorations.iconDark; - template.fileLabel.setFile(resource.sourceUri, { fileDecorations: { colors: false, badges: !icon, data: resource.decorations } }); + template.fileLabel.setFile(resource.sourceUri, { fileDecorations: { colors: false, badges: !icon } }); template.actionBar.clear(); template.actionBar.context = resource; diff --git a/src/vs/workbench/contrib/scm/common/scm.ts b/src/vs/workbench/contrib/scm/common/scm.ts index 5e1afd2d5fb00..106a85c5f8187 100644 --- a/src/vs/workbench/contrib/scm/common/scm.ts +++ b/src/vs/workbench/contrib/scm/common/scm.ts @@ -10,7 +10,6 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Command } from 'vs/editor/common/modes'; -import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry'; import { ISequence } from 'vs/base/common/sequence'; export const VIEWLET_ID = 'workbench.view.scm'; @@ -28,10 +27,6 @@ export interface ISCMResourceDecorations { tooltip?: string; strikeThrough?: boolean; faded?: boolean; - - source?: string; - letter?: string; - color?: ColorIdentifier; } export interface ISCMResource { diff --git a/src/vs/workbench/services/decorations/browser/decorations.ts b/src/vs/workbench/services/decorations/browser/decorations.ts index 214118a2c2ccd..69a276b3bc4e2 100644 --- a/src/vs/workbench/services/decorations/browser/decorations.ts +++ b/src/vs/workbench/services/decorations/browser/decorations.ts @@ -18,14 +18,12 @@ export interface IDecorationData { readonly letter?: string; readonly tooltip?: string; readonly bubble?: boolean; - readonly source?: string; } export interface IDecoration { readonly tooltip: string; readonly labelClassName: string; readonly badgeClassName: string; - update(data: IDecorationData): IDecoration; } export interface IDecorationsProvider { @@ -46,5 +44,5 @@ export interface IDecorationsService { registerDecorationsProvider(provider: IDecorationsProvider): IDisposable; - getDecoration(uri: URI, includeChildren: boolean, overwrite?: IDecorationData): IDecoration | undefined; + getDecoration(uri: URI, includeChildren: boolean): IDecoration | undefined; } diff --git a/src/vs/workbench/services/decorations/browser/decorationsService.ts b/src/vs/workbench/services/decorations/browser/decorationsService.ts index 7721cb6d80293..a10d68678a51b 100644 --- a/src/vs/workbench/services/decorations/browser/decorationsService.ts +++ b/src/vs/workbench/services/decorations/browser/decorationsService.ts @@ -144,17 +144,7 @@ class DecorationStyles extends Disposable { return { labelClassName, badgeClassName, - tooltip, - update: (replace) => { - let newData = data.slice(); - for (let i = 0; i < newData.length; i++) { - if (newData[i].source === replace.source) { - // replace - newData[i] = replace; - } - } - return this.asDecoration(newData, onlyChildren); - } + tooltip }; } @@ -402,7 +392,7 @@ export class FileDecorationsService implements IDecorationsService { }); } - getDecoration(uri: URI, includeChildren: boolean, overwrite?: IDecorationData): IDecoration | undefined { + getDecoration(uri: URI, includeChildren: boolean): IDecoration | undefined { let data: IDecorationData[] = []; let containsChildren: boolean = false; for (let iter = this._data.iterator(), next = iter.next(); !next.done; next = iter.next()) { @@ -414,22 +404,9 @@ export class FileDecorationsService implements IDecorationsService { }); } - if (data.length === 0) { - // nothing, maybe overwrite data - if (overwrite) { - return this._decorationStyles.asDecoration([overwrite], containsChildren); - } else { - return undefined; - } - } else { - // result, maybe overwrite - let result = this._decorationStyles.asDecoration(data, containsChildren); - if (overwrite) { - return result.update(overwrite); - } else { - return result; - } - } + return data.length === 0 + ? undefined + : this._decorationStyles.asDecoration(data, containsChildren); } } function getColor(theme: ITheme, color: string | undefined) { @@ -442,4 +419,4 @@ function getColor(theme: ITheme, color: string | undefined) { return 'inherit'; } -registerSingleton(IDecorationsService, FileDecorationsService); \ No newline at end of file +registerSingleton(IDecorationsService, FileDecorationsService); diff --git a/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts b/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts index 19be00601612c..bd6a66f3fbbc8 100644 --- a/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts +++ b/src/vs/workbench/services/decorations/test/browser/decorationsService.test.ts @@ -146,32 +146,6 @@ suite('DecorationsService', function () { assert.equal(typeof deco.tooltip, 'string'); }); - test('Overwrite data', function () { - - let someUri = URI.parse('file:///some/path/some/file.txt'); - let deco = service.getDecoration(someUri, false); - assert.equal(deco, undefined); - - deco = service.getDecoration(someUri, false, { tooltip: 'Overwrite' })!; - assert.equal(deco.tooltip, 'Overwrite'); - - let reg = service.registerDecorationsProvider({ - label: 'Test', - onDidChange: Event.None, - provideDecorations(uri: URI) { - return { tooltip: 'FromMe', source: 'foo' }; - } - }); - - deco = service.getDecoration(someUri, false)!; - assert.equal(deco.tooltip, 'FromMe'); - - deco = service.getDecoration(someUri, false, { source: 'foo', tooltip: 'O' })!; - assert.equal(deco.tooltip, 'O'); - - reg.dispose(); - }); - test('Decorations not showing up for second root folder #48502', async function () { let cancelCount = 0; From 6c0bb9ba4d90c9f3202d045038a68e89e0a6c288 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 4 Sep 2019 11:16:00 +0200 Subject: [PATCH 049/204] make DecorationData a class and rename it to Decoration, #54938 --- extensions/git/src/decorationProvider.ts | 18 +++++++++--------- extensions/git/src/repository.ts | 4 ++-- src/vs/vscode.proposed.d.ts | 5 ++--- .../workbench/api/common/extHost.api.impl.ts | 3 ++- .../workbench/api/common/extHostDecorations.ts | 12 +++++++----- src/vs/workbench/api/common/extHostTypes.ts | 18 ++++++++++++++++++ 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/extensions/git/src/decorationProvider.ts b/extensions/git/src/decorationProvider.ts index a939af65055e0..92f2ffd126a21 100644 --- a/extensions/git/src/decorationProvider.ts +++ b/extensions/git/src/decorationProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { window, workspace, Uri, Disposable, Event, EventEmitter, DecorationData, DecorationProvider, ThemeColor } from 'vscode'; +import { window, workspace, Uri, Disposable, Event, EventEmitter, Decoration, DecorationProvider, ThemeColor } from 'vscode'; import * as path from 'path'; import { Repository, GitResourceGroup } from './repository'; import { Model } from './model'; @@ -29,7 +29,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider { this.disposables.push(window.registerDecorationProvider(this)); } - provideDecoration(uri: Uri): Promise { + provideDecoration(uri: Uri): Promise { const repository = this.model.getRepository(uri); if (!repository) { @@ -48,7 +48,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider { this.checkIgnoreSoon(); }).then(ignored => { if (ignored) { - return { + return { priority: 3, color: new ThemeColor('gitDecoration.ignoredResourceForeground') }; @@ -89,7 +89,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider { class GitDecorationProvider implements DecorationProvider { - private static SubmoduleDecorationData: DecorationData = { + private static SubmoduleDecorationData: Decoration = { title: 'Submodule', letter: 'S', color: new ThemeColor('gitDecoration.submoduleResourceForeground') @@ -99,7 +99,7 @@ class GitDecorationProvider implements DecorationProvider { readonly onDidChangeDecorations: Event = this._onDidChangeDecorations.event; private disposables: Disposable[] = []; - private decorations = new Map(); + private decorations = new Map(); constructor(private repository: Repository) { this.disposables.push( @@ -109,7 +109,7 @@ class GitDecorationProvider implements DecorationProvider { } private onDidRunGitStatus(): void { - let newDecorations = new Map(); + let newDecorations = new Map(); this.collectSubmoduleDecorationData(newDecorations); this.collectDecorationData(this.repository.indexGroup, newDecorations); @@ -121,7 +121,7 @@ class GitDecorationProvider implements DecorationProvider { this._onDidChangeDecorations.fire([...uris.values()].map(value => Uri.parse(value, true))); } - private collectDecorationData(group: GitResourceGroup, bucket: Map): void { + private collectDecorationData(group: GitResourceGroup, bucket: Map): void { group.resourceStates.forEach(r => { if (r.resourceDecoration) { // not deleted and has a decoration @@ -130,13 +130,13 @@ class GitDecorationProvider implements DecorationProvider { }); } - private collectSubmoduleDecorationData(bucket: Map): void { + private collectSubmoduleDecorationData(bucket: Map): void { for (const submodule of this.repository.submodules) { bucket.set(Uri.file(path.join(this.repository.root, submodule.path)).toString(), GitDecorationProvider.SubmoduleDecorationData); } } - provideDecoration(uri: Uri): DecorationData | undefined { + provideDecoration(uri: Uri): Decoration | undefined { return this.decorations.get(uri.toString()); } diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 3217ad17789f8..1b9f7fbd89a7d 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode'; +import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, Decoration, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode'; import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git'; import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable } from './util'; import { memoize, throttle, debounce } from './decorators'; @@ -244,7 +244,7 @@ export class Resource implements SourceControlResourceState { } } - get resourceDecoration(): DecorationData { + get resourceDecoration(): Decoration { const title = this.tooltip; const letter = this.letter; const color = this.color; diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index f26c8501c1f46..b520c867ca300 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -556,8 +556,7 @@ declare module 'vscode' { //#region Joh: decorations - //todo@joh -> make class - export interface DecorationData { + export class Decoration { letter?: string; title?: string; color?: ThemeColor; @@ -567,7 +566,7 @@ declare module 'vscode' { export interface DecorationProvider { onDidChangeDecorations: Event; - provideDecoration(uri: Uri, token: CancellationToken): ProviderResult; + provideDecoration(uri: Uri, token: CancellationToken): ProviderResult; } export namespace window { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 35d84ff59ae63..63aeff4ceeffc 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -890,7 +890,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I WorkspaceEdit: extHostTypes.WorkspaceEdit, // proposed CallHierarchyDirection: extHostTypes.CallHierarchyDirection, - CallHierarchyItem: extHostTypes.CallHierarchyItem + CallHierarchyItem: extHostTypes.CallHierarchyItem, + Decoration: extHostTypes.Decoration }; }; } diff --git a/src/vs/workbench/api/common/extHostDecorations.ts b/src/vs/workbench/api/common/extHostDecorations.ts index 739854ec18323..a0b0612706a10 100644 --- a/src/vs/workbench/api/common/extHostDecorations.ts +++ b/src/vs/workbench/api/common/extHostDecorations.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode'; import { URI } from 'vs/base/common/uri'; import { MainContext, ExtHostDecorationsShape, MainThreadDecorationsShape, DecorationData, DecorationRequest, DecorationReply } from 'vs/workbench/api/common/extHost.protocol'; -import { Disposable } from 'vs/workbench/api/common/extHostTypes'; +import { Disposable, Decoration } from 'vs/workbench/api/common/extHostTypes'; import { CancellationToken } from 'vs/base/common/cancellation'; import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { asArray } from 'vs/base/common/arrays'; @@ -59,12 +59,14 @@ export class ExtHostDecorations implements IExtHostDecorations { } const { provider, extensionId } = entry; return Promise.resolve(provider.provideDecoration(URI.revive(uri), token)).then(data => { - if (data && data.letter && data.letter.length !== 1) { - console.warn(`INVALID decoration from extension '${extensionId.value}'. The 'letter' must be set and be one character, not '${data.letter}'.`); + if (!data) { + return; } - if (data) { + try { + Decoration.validate(data); result[id] = [data.priority, data.bubble, data.title, data.letter, data.color]; - + } catch (e) { + console.warn(`INVALID decoration from extension '${extensionId.value}': ${e}`); } }, err => { console.error(err); diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index d7b513afd22dc..623297aa26da5 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -2349,3 +2349,21 @@ export enum ExtensionKind { UI = 1, Workspace = 2 } + +export class Decoration { + + static validate(d: Decoration): void { + if (d.letter && d.letter.length !== 1) { + throw new Error(`The 'letter'-property must be undefined or a single character`); + } + if (!d.bubble && !d.color && !d.letter && !d.priority && !d.title) { + throw new Error(`The decoration is empty`); + } + } + + letter?: string; + title?: string; + color?: vscode.ThemeColor; + priority?: number; + bubble?: boolean; +} From 4e230fda77500ccdb51b16b639a85736ba470cc2 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 11:17:48 +0200 Subject: [PATCH 050/204] build - disable web smoke tests for now (#80308) --- .../darwin/product-build-darwin.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index 71dea8f381d7c..f7ee69cd2797a 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -114,15 +114,16 @@ steps: displayName: Run integration tests condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) -- script: | - set -e - cd test/smoke - yarn compile - cd - - yarn smoketest --web --headless - continueOnError: true - displayName: Run web smoke tests - condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) +# Web Smoke Tests disabled due to https://github.com/microsoft/vscode/issues/80308 +# - script: | +# set -e +# cd test/smoke +# yarn compile +# cd - +# yarn smoketest --web --headless +# continueOnError: true +# displayName: Run web smoke tests +# condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - script: | set -e From 491daf2f28ffb3aaa49dd979dbcf153982fb7492 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 4 Sep 2019 11:23:02 +0200 Subject: [PATCH 051/204] avoid shadowed variables --- src/vs/base/common/json.ts | 12 ++++++------ src/vs/base/common/jsonEdit.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vs/base/common/json.ts b/src/vs/base/common/json.ts index 4c0e983324145..12a9c0a97613a 100644 --- a/src/vs/base/common/json.ts +++ b/src/vs/base/common/json.ts @@ -207,17 +207,17 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON function scanHexDigits(count: number): number { let digits = 0; - let value = 0; + let hexValue = 0; while (digits < count) { const ch = text.charCodeAt(pos); if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) { - value = value * 16 + ch - CharacterCodes._0; + hexValue = hexValue * 16 + ch - CharacterCodes._0; } else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) { - value = value * 16 + ch - CharacterCodes.A + 10; + hexValue = hexValue * 16 + ch - CharacterCodes.A + 10; } else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) { - value = value * 16 + ch - CharacterCodes.a + 10; + hexValue = hexValue * 16 + ch - CharacterCodes.a + 10; } else { break; @@ -226,9 +226,9 @@ export function createScanner(text: string, ignoreTrivia: boolean = false): JSON digits++; } if (digits < count) { - value = -1; + hexValue = -1; } - return value; + return hexValue; } function setPosition(newPosition: number) { diff --git a/src/vs/base/common/jsonEdit.ts b/src/vs/base/common/jsonEdit.ts index a153887074945..0aac5a59b2220 100644 --- a/src/vs/base/common/jsonEdit.ts +++ b/src/vs/base/common/jsonEdit.ts @@ -144,11 +144,11 @@ function withFormatting(text: string, edit: Edit, formattingOptions: FormattingO // apply the formatting edits and track the begin and end offsets of the changes for (let i = edits.length - 1; i >= 0; i--) { - const edit = edits[i]; - newText = applyEdit(newText, edit); - begin = Math.min(begin, edit.offset); - end = Math.max(end, edit.offset + edit.length); - end += edit.content.length - edit.length; + const curr = edits[i]; + newText = applyEdit(newText, curr); + begin = Math.min(begin, curr.offset); + end = Math.max(end, curr.offset + curr.length); + end += curr.content.length - curr.length; } // create a single edit with all changes const editLength = text.length - (newText.length - end) - begin; @@ -182,4 +182,4 @@ export function applyEdits(text: string, edits: Edit[]): string { export function isWS(text: string, offset: number) { return '\r\n \t'.indexOf(text.charAt(offset)) !== -1; -} \ No newline at end of file +} From 458ac9652955f422b720f499c3e116d004d35347 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 4 Sep 2019 11:30:50 +0200 Subject: [PATCH 052/204] move SymbolTag and CompletionItemTag apis to stable, #23927 --- src/vs/vscode.d.ts | 38 +++++++++++++++++++++++++++++++++++++ src/vs/vscode.proposed.d.ts | 34 --------------------------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 32533758bb5bb..5607f5eee2c04 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -2532,6 +2532,18 @@ declare module 'vscode' { TypeParameter = 25 } + + /** + * Symbol tags are extra annotations that tweak the rendering of a symbol. + */ + export enum SymbolTag { + + /** + * Render a symbol as obsolete, usually using a strike-out. + */ + Deprecated = 1 + } + /** * Represents information about programming constructs like variables, classes, * interfaces etc. @@ -2553,6 +2565,11 @@ declare module 'vscode' { */ kind: SymbolKind; + /** + * Tags for this symbol. + */ + tags?: ReadonlyArray; + /** * The location of this symbol. */ @@ -2604,6 +2621,11 @@ declare module 'vscode' { */ kind: SymbolKind; + /** + * Tags for this symbol. + */ + tags?: ReadonlyArray; + /** * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. */ @@ -3285,6 +3307,17 @@ declare module 'vscode' { TypeParameter = 24 } + /** + * Completion item tags are extra annotations that tweak the rendering of a completion + * item. + */ + export enum CompletionItemTag { + /** + * Render a completion as obsolete, usually using a strike-out. + */ + Deprecated = 1 + } + /** * A completion item represents a text snippet that is proposed to complete text that is being typed. * @@ -3315,6 +3348,11 @@ declare module 'vscode' { */ kind?: CompletionItemKind; + /** + * Tags for this completion item. + */ + tags?: ReadonlyArray; + /** * A human-readable string with additional information * about this item, like type or symbol information. diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index b520c867ca300..aa7cb2e45709e 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1119,40 +1119,6 @@ declare module 'vscode' { //#endregion - //#region Joh - CompletionItemTag, https://github.com/microsoft/vscode/issues/23927 - - export enum SymbolTag { - Deprecated = 1 - } - - export interface SymbolInformation { - /** - * - */ - tags?: ReadonlyArray; - } - - export interface DocumentSymbol { - /** - * - */ - tags?: ReadonlyArray; - } - - export enum CompletionItemTag { - Deprecated = 1 - } - - export interface CompletionItem { - - /** - * - */ - tags?: ReadonlyArray; - } - - //#endregion - // #region Ben - extension auth flow (desktop+web) export interface AppUriOptions { From f9289bb4c6a8bfab41278ef1c5119e513417a0f9 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 4 Sep 2019 11:36:52 +0200 Subject: [PATCH 053/204] debt - use Record to define [IString|INumber]Dictionary --- src/vs/base/common/collections.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/vs/base/common/collections.ts b/src/vs/base/common/collections.ts index a0f6695e8ae19..ea5c883200406 100644 --- a/src/vs/base/common/collections.ts +++ b/src/vs/base/common/collections.ts @@ -7,17 +7,14 @@ * An interface for a JavaScript object that * acts a dictionary. The keys are strings. */ -export interface IStringDictionary { - [name: string]: V; -} +export type IStringDictionary = Record; + /** * An interface for a JavaScript object that * acts a dictionary. The keys are numbers. */ -export interface INumberDictionary { - [idx: number]: V; -} +export type INumberDictionary = Record; const hasOwnProperty = Object.prototype.hasOwnProperty; @@ -136,4 +133,4 @@ export class SetMap { values.forEach(fn); } -} \ No newline at end of file +} From a199a103a2e72b5becdd0e39837c5c482562543c Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 4 Sep 2019 11:41:44 +0200 Subject: [PATCH 054/204] :lipstick: --- src/vs/base/common/map.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index 277ab50bb88d9..007d0a0d529ff 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -18,7 +18,7 @@ export function values(forEachable: { forEach(callback: (value: V, ...more: a export function keys(map: Map): K[] { const result: K[] = []; - map.forEach((value, key) => result.push(key)); + map.forEach((_value, key) => result.push(key)); return result; } @@ -482,8 +482,6 @@ export class ResourceMap { } } -// We should fold BoundedMap and LinkedMap. See https://github.com/Microsoft/vscode/issues/28496 - interface Item { previous: Item | undefined; next: Item | undefined; From 88a7008ae1849f506576c498da809e7625525dab Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 Sep 2019 17:38:30 +0200 Subject: [PATCH 055/204] fixes #80002 --- .../services/extensions/common/extensionUrlHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts b/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts index c8d9d320630d8..f1afdb4562b94 100644 --- a/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts +++ b/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts @@ -114,11 +114,11 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler { } const result = await this.dialogService.confirm({ - message: localize('confirmUrl', "Allow an extension to open this URL?", extensionId), + message: localize('confirmUrl', "Allow an extension to open this URI?", extensionId), checkbox: { label: localize('rememberConfirmUrl', "Don't ask again for this extension."), }, - detail: `${extension.displayName || extension.name} (${extensionId}) wants to open a URL:\n\n${uriString}`, + detail: `${extension.displayName || extension.name} (${extensionId}) wants to open a URI:\n\n${uriString}`, primaryButton: localize('open', "&&Open"), type: 'question' }); From 32d72e6565a40e3776e757cc7573ef9175acc941 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Wed, 4 Sep 2019 17:43:33 +0200 Subject: [PATCH 056/204] Filter out 'No license field' in gulp tasks Fixes #80081 --- extensions/gulp/src/main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/gulp/src/main.ts b/extensions/gulp/src/main.ts index 6f9a9e4933410..b260f0e49b816 100644 --- a/extensions/gulp/src/main.ts +++ b/extensions/gulp/src/main.ts @@ -156,8 +156,13 @@ class FolderDetector { try { let { stdout, stderr } = await exec(commandLine, { cwd: rootPath }); if (stderr && stderr.length > 0) { - getOutputChannel().appendLine(stderr); - showError(); + // Filter out "No license field" + const errors = stderr.split('\n'); + errors.pop(); // The last line is empty. + if (!errors.every(value => value.indexOf('No license field') >= 0)) { + getOutputChannel().appendLine(stderr); + showError(); + } } let result: vscode.Task[] = []; if (stdout) { From 3a5c7d96ebde2a22244380040175d95bfb4004f6 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 Sep 2019 17:43:26 +0200 Subject: [PATCH 057/204] fixes #79029 --- src/vs/base/browser/ui/inputbox/inputBox.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 48026fe503bed..cae97a6aea0c5 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -240,6 +240,7 @@ export class InputBox extends Widget { } public setPlaceHolder(placeHolder: string): void { + this.placeholder = placeHolder; this.input.setAttribute('placeholder', placeHolder); this.input.title = placeHolder; } From fb85e286d3c267a37ff708f371425deeb1bc1b59 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 Sep 2019 17:51:45 +0200 Subject: [PATCH 058/204] layout splitview views with absolute positioning related to #78167 --- .../base/browser/ui/splitview/splitview.css | 15 +++----------- src/vs/base/browser/ui/splitview/splitview.ts | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/vs/base/browser/ui/splitview/splitview.css b/src/vs/base/browser/ui/splitview/splitview.css index 6fb8f1c61d0e3..75e686cb5fcfc 100644 --- a/src/vs/base/browser/ui/splitview/splitview.css +++ b/src/vs/base/browser/ui/splitview/splitview.css @@ -21,24 +21,15 @@ } .monaco-split-view2 > .split-view-container { - display: flex; width: 100%; height: 100%; white-space: nowrap; -} - -.monaco-split-view2.vertical > .split-view-container { - flex-direction: column; -} - -.monaco-split-view2.horizontal > .split-view-container { - flex-direction: row; + position: relative; } .monaco-split-view2 > .split-view-container > .split-view-view { white-space: initial; - flex: none; - position: relative; + position: absolute; } .monaco-split-view2 > .split-view-container > .split-view-view:not(.visible) { @@ -72,4 +63,4 @@ .monaco-split-view2.separator-border.vertical > .split-view-container > .split-view-view:not(:first-child)::before { height: 1px; width: 100%; -} \ No newline at end of file +} diff --git a/src/vs/base/browser/ui/splitview/splitview.ts b/src/vs/base/browser/ui/splitview/splitview.ts index 5e5e54dcf6172..d89028622d34d 100644 --- a/src/vs/base/browser/ui/splitview/splitview.ts +++ b/src/vs/base/browser/ui/splitview/splitview.ts @@ -125,10 +125,13 @@ abstract class ViewItem { } } - layout(orthogonalSize: number | undefined): void { + layout(position: number, orthogonalSize: number | undefined): void { + this.layoutContainer(position); this.view.layout(this.size, orthogonalSize); } + abstract layoutContainer(position: number): void; + dispose(): IView { this.disposable.dispose(); return this.view; @@ -137,16 +140,16 @@ abstract class ViewItem { class VerticalViewItem extends ViewItem { - layout(orthogonalSize: number | undefined): void { - super.layout(orthogonalSize); + layoutContainer(position: number): void { + this.container.style.top = `${position}px`; this.container.style.height = `${this.size}px`; } } class HorizontalViewItem extends ViewItem { - layout(orthogonalSize: number | undefined): void { - super.layout(orthogonalSize); + layoutContainer(position: number): void { + this.container.style.left = `${position}px`; this.container.style.width = `${this.size}px`; } } @@ -846,7 +849,12 @@ export class SplitView extends Disposable { this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0); // Layout views - this.viewItems.forEach(item => item.layout(this.orthogonalSize)); + let position = 0; + + for (const viewItem of this.viewItems) { + viewItem.layout(position, this.orthogonalSize); + position += viewItem.size; + } // Layout sashes this.sashItems.forEach(item => item.sash.layout()); From bd79c20ac85d44a42d28defb6aa280d5e9ab066b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 4 Sep 2019 17:51:53 +0200 Subject: [PATCH 059/204] prevent overflowing of splitview views and parts fixes #78167 --- src/vs/base/browser/ui/splitview/splitview.css | 1 + src/vs/workbench/browser/media/part.css | 1 + 2 files changed, 2 insertions(+) diff --git a/src/vs/base/browser/ui/splitview/splitview.css b/src/vs/base/browser/ui/splitview/splitview.css index 75e686cb5fcfc..c1b30bf9a3b1b 100644 --- a/src/vs/base/browser/ui/splitview/splitview.css +++ b/src/vs/base/browser/ui/splitview/splitview.css @@ -30,6 +30,7 @@ .monaco-split-view2 > .split-view-container > .split-view-view { white-space: initial; position: absolute; + overflow: hidden; } .monaco-split-view2 > .split-view-container > .split-view-view:not(.visible) { diff --git a/src/vs/workbench/browser/media/part.css b/src/vs/workbench/browser/media/part.css index 60351cbaf2114..c051ed6eb2234 100644 --- a/src/vs/workbench/browser/media/part.css +++ b/src/vs/workbench/browser/media/part.css @@ -9,6 +9,7 @@ .monaco-workbench .part { box-sizing: border-box; + overflow: hidden; } .monaco-workbench .part > .title { From 71754fbb2cb2c401888cb8d2f4088198bcb6d6ad Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Wed, 4 Sep 2019 08:57:08 -0700 Subject: [PATCH 060/204] temporary workaround for treeshaking --- src/vs/editor/contrib/documentSymbols/outlineModel.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vs/editor/contrib/documentSymbols/outlineModel.ts b/src/vs/editor/contrib/documentSymbols/outlineModel.ts index e5004629993f1..8059fdbdcfd40 100644 --- a/src/vs/editor/contrib/documentSymbols/outlineModel.ts +++ b/src/vs/editor/contrib/documentSymbols/outlineModel.ts @@ -386,6 +386,9 @@ export class OutlineModel extends TreeElement { protected constructor(readonly textModel: ITextModel) { super(); + + this.id = 'root'; + this.parent = undefined; } adopt(): OutlineModel { From 6a441bef214f9cb4d9625b79a37522b1eb4b3a4f Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 4 Sep 2019 18:06:15 +0200 Subject: [PATCH 061/204] dialogs - remove unused options --- src/vs/base/browser/ui/dialog/dialog.ts | 2 -- src/vs/platform/dialogs/common/dialogs.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/vs/base/browser/ui/dialog/dialog.ts b/src/vs/base/browser/ui/dialog/dialog.ts index a15f94dab8c43..b3c43c0794cac 100644 --- a/src/vs/base/browser/ui/dialog/dialog.ts +++ b/src/vs/base/browser/ui/dialog/dialog.ts @@ -92,8 +92,6 @@ export class Dialog extends Disposable { checkboxMessageElement.innerText = this.options.checkboxLabel; } - - const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row')); this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar')); } diff --git a/src/vs/platform/dialogs/common/dialogs.ts b/src/vs/platform/dialogs/common/dialogs.ts index f72f2276330ae..ab029f1944e64 100644 --- a/src/vs/platform/dialogs/common/dialogs.ts +++ b/src/vs/platform/dialogs/common/dialogs.ts @@ -127,8 +127,6 @@ export const IDialogService = createDecorator('dialogService'); export interface IDialogOptions { cancelId?: number; detail?: string; - checkboxLabel?: string; - checkboxChecked?: boolean; } /** From c339a5605cafb261247285527889157733bae14f Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Wed, 4 Sep 2019 10:06:19 -0700 Subject: [PATCH 062/204] optional clipboard service for diff editor widget. --- src/vs/editor/browser/widget/diffEditorWidget.ts | 6 +++--- src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts | 2 +- src/vs/editor/standalone/browser/standaloneCodeEditor.ts | 6 +++--- src/vs/editor/standalone/browser/standaloneEditor.ts | 3 +-- src/vs/workbench/browser/parts/editor/textDiffEditor.ts | 6 ++++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index fa0e688d6962b..4a7bc1120449b 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -79,7 +79,7 @@ class VisualEditorState { constructor( private _contextMenuService: IContextMenuService, - private _clipboardService: IClipboardService + private _clipboardService: IClipboardService | null ) { this._zones = []; this.inlineDiffMargins = []; @@ -129,7 +129,7 @@ class VisualEditorState { this._zones.push(zoneId); this._zonesMap[String(zoneId)] = true; - if (newDecorations.zones[i].diff && viewZone.marginDomNode) { + if (newDecorations.zones[i].diff && viewZone.marginDomNode && this._clipboardService) { this.inlineDiffMargins.push(new InlineDiffMargin(zoneId, viewZone.marginDomNode, editor, newDecorations.zones[i].diff!, this._contextMenuService, this._clipboardService)); } } @@ -214,6 +214,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE constructor( domElement: HTMLElement, options: editorOptions.IDiffEditorOptions, + clipboardService: IClipboardService | null, @IEditorWorkerService editorWorkerService: IEditorWorkerService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService instantiationService: IInstantiationService, @@ -221,7 +222,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE @IThemeService themeService: IThemeService, @INotificationService notificationService: INotificationService, @IContextMenuService contextMenuService: IContextMenuService, - @IClipboardService clipboardService: IClipboardService ) { super(); diff --git a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts index 2f36d8e97656d..ffa6ca519cd87 100644 --- a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts +++ b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts @@ -80,7 +80,7 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget { @IContextMenuService contextMenuService: IContextMenuService, @IClipboardService clipboardService: IClipboardService ) { - super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, clipboardService); + super(domElement, parentEditor.getRawConfiguration(), clipboardService, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService); this._parentEditor = parentEditor; this._overwriteOptions = options; diff --git a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts index d64e0e6e2afbb..47d797f25191f 100644 --- a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts @@ -23,7 +23,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -376,7 +376,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon @INotificationService notificationService: INotificationService, @IConfigurationService configurationService: IConfigurationService, @IContextMenuService contextMenuService: IContextMenuService, - @IClipboardService clipboardService: IClipboardService + @optional(IClipboardService) clipboardService: IClipboardService | null, ) { applyConfigurationValues(configurationService, options, true); options = options || {}; @@ -384,7 +384,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon options.theme = themeService.setTheme(options.theme); } - super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, clipboardService); + super(domElement, options, clipboardService, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService); this._contextViewService = contextViewService; this._configurationService = configurationService; diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 280e00cbdf712..11b8580e4e21b 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -38,7 +38,6 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; import { clearAllFontInfos } from 'vs/editor/browser/config/configuration'; -import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; type Omit = Pick>; @@ -121,7 +120,7 @@ export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorC services.get(INotificationService), services.get(IConfigurationService), services.get(IContextMenuService), - services.get(IClipboardService) + null ); }); } diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 7b791423c5eb9..4473c4d02c91f 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -32,6 +32,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor'; import { IWindowService } from 'vs/platform/windows/common/windows'; import { EditorActivation } from 'vs/platform/editor/common/editor'; +import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; /** * The text editor that leverages the diff text editor for the editing experience. @@ -52,7 +53,8 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { @IThemeService themeService: IThemeService, @IEditorGroupsService editorGroupService: IEditorGroupsService, @ITextFileService textFileService: ITextFileService, - @IWindowService windowService: IWindowService + @IWindowService windowService: IWindowService, + @IClipboardService private _clipboardService: IClipboardService, ) { super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, windowService); } @@ -70,7 +72,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { } createEditorControl(parent: HTMLElement, configuration: ICodeEditorOptions): IDiffEditor { - return this.instantiationService.createInstance(DiffEditorWidget, parent, configuration); + return this.instantiationService.createInstance(DiffEditorWidget, parent, configuration, this._clipboardService); } async setInput(input: EditorInput, options: EditorOptions, token: CancellationToken): Promise { From c16c1b7827b1ca6c8ddb5493441a9bbf9769a972 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 4 Sep 2019 10:28:07 -0700 Subject: [PATCH 063/204] Improve createTerminal API docs --- src/vs/vscode.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 5607f5eee2c04..8f84919720eff 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -6835,20 +6835,20 @@ declare module 'vscode' { export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem; /** - * Creates a [Terminal](#Terminal). The cwd of the terminal will be the workspace directory - * if it exists, regardless of whether an explicit customStartPath setting exists. + * Creates a [Terminal](#Terminal) with a backing shell process. The cwd of the terminal will be the workspace + * directory if it exists. * * @param name Optional human-readable string which will be used to represent the terminal in the UI. * @param shellPath Optional path to a custom shell executable to be used in the terminal. * @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which - * allows specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6). + * allows specifying shell args in + * [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6). * @return A new Terminal. */ export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): Terminal; /** - * Creates a [Terminal](#Terminal). The cwd of the terminal will be the workspace directory - * if it exists, regardless of whether an explicit customStartPath setting exists. + * Creates a [Terminal](#Terminal) with a backing shell process. * * @param options A TerminalOptions object describing the characteristics of the new terminal. * @return A new Terminal. From 052ffefc24b50d03a12f6bed6a23b59b4c73445c Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 4 Sep 2019 10:32:24 -0700 Subject: [PATCH 064/204] Move puppeteer dep into smoke test project Fixes #80329 --- package.json | 1 - test/smoke/package.json | 1 + test/smoke/yarn.lock | 100 ++++++++++++++++++++++++++++++++++++++++ yarn.lock | 52 +-------------------- 4 files changed, 103 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 0b46f5033ca81..ae225a90bbfef 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,6 @@ "optimist": "0.3.5", "p-all": "^1.0.0", "pump": "^1.0.1", - "puppeteer": "^1.19.0", "queue": "3.0.6", "rcedit": "^1.1.0", "rimraf": "^2.2.8", diff --git a/test/smoke/package.json b/test/smoke/package.json index 99e9ddf08524a..718ad5e9e0719 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -31,6 +31,7 @@ "mocha-multi-reporters": "^1.1.7", "ncp": "^2.0.0", "portastic": "^1.0.1", + "puppeteer": "^1.19.0", "rimraf": "^2.6.1", "strip-json-comments": "^2.0.1", "tmp": "0.0.33", diff --git a/test/smoke/yarn.lock b/test/smoke/yarn.lock index 81f81a3f414e9..18aa689cc3e9d 100644 --- a/test/smoke/yarn.lock +++ b/test/smoke/yarn.lock @@ -81,6 +81,13 @@ abbrev@1: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== +agent-base@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" + integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== + dependencies: + es6-promisify "^5.0.0" + ajv@^5.1.0: version "5.3.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.3.0.tgz#4414ff74a50879c208ee5fdc826e32c303549eda" @@ -204,6 +211,11 @@ async-each@^1.0.0: resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf" integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ== +async-limiter@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -319,6 +331,11 @@ browser-stdout@1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -463,6 +480,16 @@ concat-stream@1.6.0: readable-stream "^2.2.2" typedarray "^0.0.6" +concat-stream@1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + concurrently@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-3.5.1.tgz#ee8b60018bbe86b02df13e5249453c6ececd2521" @@ -566,6 +593,13 @@ debug@^3.0.0, debug@^3.2.6: dependencies: ms "^2.1.1" +debug@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -709,6 +743,18 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" +es6-promise@^4.0.3: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= + dependencies: + es6-promise "^4.0.3" + escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -799,6 +845,16 @@ extract-zip@^1.0.3: mkdirp "0.5.0" yauzl "2.4.1" +extract-zip@^1.6.6: + version "1.6.7" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" + integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= + dependencies: + concat-stream "1.6.2" + debug "2.6.9" + mkdirp "0.5.1" + yauzl "2.4.1" + extsprintf@1.3.0, extsprintf@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -1114,6 +1170,14 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" +https-proxy-agent@^2.2.1: + version "2.2.2" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz#271ea8e90f836ac9f119daccd39c19ff7dfb0793" + integrity sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg== + dependencies: + agent-base "^4.3.0" + debug "^3.1.0" + iconv-lite@^0.4.4: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -1553,6 +1617,11 @@ mime-types@^2.1.12, mime-types@~2.1.17: dependencies: mime-db "~1.30.0" +mime@^2.0.3: + version "2.4.4" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5" + integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA== + minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -1967,11 +2036,35 @@ progress-stream@^1.1.0: speedometer "~0.1.2" through2 "~0.2.3" +progress@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= + punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= +puppeteer@^1.19.0: + version "1.19.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.19.0.tgz#e3b7b448c2c97933517078d7a2c53687361bebea" + integrity sha512-2S6E6ygpoqcECaagDbBopoSOPDv0pAZvTbnBgUY+6hq0/XDFDOLEMNlHF/SKJlzcaZ9ckiKjKDuueWI3FN/WXw== + dependencies: + debug "^4.1.0" + extract-zip "^1.6.6" + https-proxy-agent "^2.2.1" + mime "^2.0.3" + progress "^2.0.1" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^6.1.0" + qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -2655,6 +2748,13 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +ws@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" + integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== + dependencies: + async-limiter "~1.0.0" + xml@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" diff --git a/yarn.lock b/yarn.lock index 9d0ed2b81772e..75705117265ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1723,7 +1723,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@1.6.2, concat-stream@^1.5.0, concat-stream@^1.6.0: +concat-stream@^1.5.0, concat-stream@^1.6.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -2842,16 +2842,6 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extract-zip@^1.6.6: - version "1.6.7" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" - integrity sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k= - dependencies: - concat-stream "1.6.2" - debug "2.6.9" - mkdirp "0.5.1" - yauzl "2.4.1" - extsprintf@1.3.0, extsprintf@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -5290,11 +5280,6 @@ mime@^1.4.1: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^2.0.3: - version "2.4.4" - resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5" - integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA== - mimic-fn@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" @@ -6667,7 +6652,7 @@ progress@^1.1.8: resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= -progress@^2.0.0, progress@^2.0.1: +progress@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== @@ -6690,11 +6675,6 @@ proxy-addr@~2.0.2: forwarded "~0.1.2" ipaddr.js "1.5.2" -proxy-from-env@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" - integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= - prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" @@ -6777,20 +6757,6 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -puppeteer@^1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.19.0.tgz#e3b7b448c2c97933517078d7a2c53687361bebea" - integrity sha512-2S6E6ygpoqcECaagDbBopoSOPDv0pAZvTbnBgUY+6hq0/XDFDOLEMNlHF/SKJlzcaZ9ckiKjKDuueWI3FN/WXw== - dependencies: - debug "^4.1.0" - extract-zip "^1.6.6" - https-proxy-agent "^2.2.1" - mime "^2.0.3" - progress "^2.0.1" - proxy-from-env "^1.0.0" - rimraf "^2.6.1" - ws "^6.1.0" - q@^1.0.1, q@^1.1.2: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" @@ -9125,13 +9091,6 @@ ws@^3.3.3: safe-buffer "~5.1.0" ultron "~1.1.0" -ws@^6.1.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb" - integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA== - dependencies: - async-limiter "~1.0.0" - xml-name-validator@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-1.0.0.tgz#dcf82ee092322951ef8cc1ba596c9cbfd14a83f1" @@ -9275,13 +9234,6 @@ yargs@^7.1.0: y18n "^3.2.1" yargs-parser "^5.0.0" -yauzl@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" - integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU= - dependencies: - fd-slicer "~1.0.1" - yauzl@^2.2.1, yauzl@^2.3.1: version "2.9.1" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.9.1.tgz#a81981ea70a57946133883f029c5821a89359a7f" From afe912070e91fb5d33a66182788c934a933c19c8 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 4 Sep 2019 11:04:45 -0700 Subject: [PATCH 065/204] Stabilize extension terminals (vscode.Pseudoterminal) Fixes #78514 --- src/vs/vscode.d.ts | 172 +++++++++++++++++ src/vs/vscode.proposed.d.ts | 178 ------------------ .../workbench/api/common/extHost.api.impl.ts | 2 +- 3 files changed, 173 insertions(+), 179 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 8f84919720eff..875f9d9696ca4 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -6855,6 +6855,15 @@ declare module 'vscode' { */ export function createTerminal(options: TerminalOptions): Terminal; + /** + * Creates a [Terminal](#Terminal) where an extension controls its input and output. + * + * @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing + * the characteristics of the new terminal. + * @return A new Terminal. + */ + export function createTerminal(options: ExtensionTerminalOptions): Terminal; + /** * Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`. * This will allow you to contribute data to the [TreeView](#TreeView) and update if the data changes. @@ -7208,6 +7217,169 @@ declare module 'vscode' { hideFromUser?: boolean; } + /** + * Value-object describing what options a virtual process terminal should use. + */ + export interface ExtensionTerminalOptions { + /** + * A human-readable string which will be used to represent the terminal in the UI. + */ + name: string; + + /** + * An implementation of [Pseudoterminal](#Pseudoterminal) that allows an extension to + * control a terminal. + */ + pty: Pseudoterminal; + } + + /** + * Defines the interface of a terminal pty, enabling extensions to control a terminal. + */ + interface Pseudoterminal { + /** + * An event that when fired will write data to the terminal. Unlike + * [Terminal.sendText](#Terminal.sendText) which sends text to the underlying _process_ + * (the pty "slave"), this will write the text to the terminal itself (the pty "master"). + * + * **Example:** Write red text to the terminal + * ```typescript + * const writeEmitter = new vscode.EventEmitter(); + * const pty: vscode.Pseudoterminal = { + * onDidWrite: writeEmitter.event, + * open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'), + * close: () => {} + * }; + * vscode.window.createTerminal({ name: 'My terminal', pty }); + * ``` + * + * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk + * ```typescript + * writeEmitter.fire('\x1b[10;20H*'); + * ``` + */ + onDidWrite: Event; + + /** + * An event that when fired allows overriding the [dimensions](#Terminal.dimensions) of the + * terminal. Note that when set, the overridden dimensions will only take effect when they + * are lower than the actual dimensions of the terminal (ie. there will never be a scroll + * bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to + * the size of the panel). + * + * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows + * ```typescript + * const dimensionsEmitter = new vscode.EventEmitter(); + * const pty: vscode.Pseudoterminal = { + * onDidWrite: writeEmitter.event, + * onDidOverrideDimensions: dimensionsEmitter.event, + * open: () => { + * dimensionsEmitter.fire({ + * columns: 20, + * rows: 10 + * }); + * }, + * close: () => {} + * }; + * vscode.window.createTerminal({ name: 'My terminal', pty }); + * ``` + */ + onDidOverrideDimensions?: Event; + + /** + * An event that when fired will signal that the pty is closed and dispose of the terminal. + * + * A number can be used to provide an exit code for the terminal. Exit codes must be + * positive and a non-zero exit codes signals failure which shows a notification for a + * regular terminal and allows dependent tasks to proceed when used with the + * `CustomExecution2` API. + * + * **Example:** Exit the terminal when "y" is pressed, otherwise show a notification. + * ```typescript + * const writeEmitter = new vscode.EventEmitter(); + * const closeEmitter = new vscode.EventEmitter(); + * const pty: vscode.Pseudoterminal = { + * onDidWrite: writeEmitter.event, + * onDidClose: closeEmitter.event, + * open: () => writeEmitter.fire('Press y to exit successfully'), + * close: () => {}, + * handleInput: data => { + * if (data !== 'y') { + * vscode.window.showInformationMessage('Something went wrong'); + * } + * closeEmitter.fire(); + * } + * }; + * vscode.window.createTerminal({ name: 'Exit example', pty }); + */ + onDidClose?: Event; + + /** + * Implement to handle when the pty is open and ready to start firing events. + * + * @param initialDimensions The dimensions of the terminal, this will be undefined if the + * terminal panel has not been opened before this is called. + */ + open(initialDimensions: TerminalDimensions | undefined): void; + + /** + * Implement to handle when the terminal is closed by an act of the user. + */ + close(): void; + + /** + * Implement to handle incoming keystrokes in the terminal or when an extension calls + * [Terminal.sendText](#Terminal.sendText). `data` contains the keystrokes/text serialized into + * their corresponding VT sequence representation. + * + * @param data The incoming data. + * + * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to + * CRLF to go to a new line and move the cursor to the start of the line. + * ```typescript + * const writeEmitter = new vscode.EventEmitter(); + * const pty: vscode.Pseudoterminal = { + * onDidWrite: writeEmitter.event, + * open: () => {}, + * close: () => {}, + * handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data) + * }; + * vscode.window.createTerminal({ name: 'Local echo', pty }); + * ``` + */ + handleInput?(data: string): void; + + /** + * Implement to handle when the number of rows and columns that fit into the terminal panel + * changes, for example when font size changes or when the panel is resized. The initial + * state of a terminal's dimensions should be treated as `undefined` until this is triggered + * as the size of a terminal isn't know until it shows up in the user interface. + * + * When dimensions are overridden by + * [onDidOverrideDimensions](#Pseudoterminal.onDidOverrideDimensions), `setDimensions` will + * continue to be called with the regular panel dimensions, allowing the extension continue + * to react dimension changes. + * + * @param dimensions The new dimensions. + */ + setDimensions?(dimensions: TerminalDimensions): void; + } + + /** + * Represents the dimensions of a terminal. + */ + export interface TerminalDimensions { + /** + * The number of columns in the terminal. + */ + readonly columns: number; + + /** + * The number of rows in the terminal. + */ + readonly rows: number; + } + /** * A location in the editor at which progress information can be shown. It depends on the * location how progress is visually represented. diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index aa7cb2e45709e..1a53eed0c91d6 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -760,184 +760,6 @@ declare module 'vscode' { readonly onDidWriteData: Event; } - /** - * Represents the dimensions of a terminal. - */ - export interface TerminalDimensions { - /** - * The number of columns in the terminal. - */ - readonly columns: number; - - /** - * The number of rows in the terminal. - */ - readonly rows: number; - } - - //#endregion - - //#region Extension terminals - - export namespace window { - /** - * Creates a [Terminal](#Terminal) where an extension controls the terminal. - * - * @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing - * the characteristics of the new terminal. - * @return A new Terminal. - */ - export function createTerminal(options: ExtensionTerminalOptions): Terminal; - } - - /** - * Value-object describing what options a virtual process terminal should use. - */ - export interface ExtensionTerminalOptions { - /** - * A human-readable string which will be used to represent the terminal in the UI. - */ - name: string; - - /** - * An implementation of [Pseudoterminal](#Pseudoterminal) that allows an extension to - * control a terminal. - */ - pty: Pseudoterminal; - } - - /** - * Defines the interface of a terminal pty, enabling extensions to control a terminal. - */ - interface Pseudoterminal { - /** - * An event that when fired will write data to the terminal. Unlike - * [Terminal.sendText](#Terminal.sendText) which sends text to the underlying _process_ - * (the pty "slave"), this will write the text to the terminal itself (the pty "master"). - * - * **Example:** Write red text to the terminal - * ```typescript - * const writeEmitter = new vscode.EventEmitter(); - * const pty: vscode.Pseudoterminal = { - * onDidWrite: writeEmitter.event, - * open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'), - * close: () => {} - * }; - * vscode.window.createTerminal({ name: 'My terminal', pty }); - * ``` - * - * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk - * ```typescript - * writeEmitter.fire('\x1b[10;20H*'); - * ``` - */ - onDidWrite: Event; - - /** - * An event that when fired allows overriding the [dimensions](#Terminal.dimensions) of the - * terminal. Note that when set, the overridden dimensions will only take effect when they - * are lower than the actual dimensions of the terminal (ie. there will never be a scroll - * bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to - * the size of the panel). - * - * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows - * ```typescript - * const dimensionsEmitter = new vscode.EventEmitter(); - * const pty: vscode.Pseudoterminal = { - * onDidWrite: writeEmitter.event, - * onDidOverrideDimensions: dimensionsEmitter.event, - * open: () => { - * dimensionsEmitter.fire({ - * columns: 20, - * rows: 10 - * }); - * }, - * close: () => {} - * }; - * vscode.window.createTerminal({ name: 'My terminal', pty }); - * ``` - */ - onDidOverrideDimensions?: Event; - - /** - * An event that when fired will signal that the pty is closed and dispose of the terminal. - * - * A number can be used to provide an exit code for the terminal. Exit codes must be - * positive and a non-zero exit codes signals failure which shows a notification for a - * regular terminal and allows dependent tasks to proceed when used with the - * `CustomExecution2` API. - * - * **Example:** Exit the terminal when "y" is pressed, otherwise show a notification. - * ```typescript - * const writeEmitter = new vscode.EventEmitter(); - * const closeEmitter = new vscode.EventEmitter(); - * const pty: vscode.Pseudoterminal = { - * onDidWrite: writeEmitter.event, - * onDidClose: closeEmitter.event, - * open: () => writeEmitter.fire('Press y to exit successfully'), - * close: () => {}, - * handleInput: data => { - * if (data !== 'y') { - * vscode.window.showInformationMessage('Something went wrong'); - * } - * closeEmitter.fire(); - * } - * }; - * vscode.window.createTerminal({ name: 'Exit example', pty }); - */ - onDidClose?: Event; - - /** - * Implement to handle when the pty is open and ready to start firing events. - * - * @param initialDimensions The dimensions of the terminal, this will be undefined if the - * terminal panel has not been opened before this is called. - */ - open(initialDimensions: TerminalDimensions | undefined): void; - - /** - * Implement to handle when the terminal is closed by an act of the user. - */ - close(): void; - - /** - * Implement to handle incoming keystrokes in the terminal or when an extension calls - * [Terminal.sendText](#Terminal.sendText). `data` contains the keystrokes/text serialized into - * their corresponding VT sequence representation. - * - * @param data The incoming data. - * - * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to - * CRLF to go to a new line and move the cursor to the start of the line. - * ```typescript - * const writeEmitter = new vscode.EventEmitter(); - * const pty: vscode.Pseudoterminal = { - * onDidWrite: writeEmitter.event, - * open: () => {}, - * close: () => {}, - * handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data) - * }; - * vscode.window.createTerminal({ name: 'Local echo', pty }); - * ``` - */ - handleInput?(data: string): void; - - /** - * Implement to handle when the number of rows and columns that fit into the terminal panel - * changes, for example when font size changes or when the panel is resized. The initial - * state of a terminal's dimensions should be treated as `undefined` until this is triggered - * as the size of a terminal isn't know until it shows up in the user interface. - * - * When dimensions are overridden by - * [onDidOverrideDimensions](#Pseudoterminal.onDidOverrideDimensions), `setDimensions` will - * continue to be called with the regular panel dimensions, allowing the extension continue - * to react dimension changes. - * - * @param dimensions The new dimensions. - */ - setDimensions?(dimensions: TerminalDimensions): void; - } - //#endregion //#region Joh -> exclusive document filters diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 63aeff4ceeffc..79317b0233f78 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -512,7 +512,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I } return extHostTerminalService.createTerminalFromOptions(nameOrOptions); } - return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs); + return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs); }, registerTreeDataProvider(viewId: string, treeDataProvider: vscode.TreeDataProvider): vscode.Disposable { return extHostTreeViews.registerTreeDataProvider(viewId, treeDataProvider, extension); From 7edb8b1f6ad062a2b0b82ff03887dd885e96376a Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 11:22:46 -0700 Subject: [PATCH 066/204] strictPropInit for settings, #78168 --- .../preferences/browser/preferencesEditor.ts | 48 ++++++------ .../browser/preferencesRenderers.ts | 16 ++-- .../preferences/browser/preferencesWidgets.ts | 62 +++++++-------- .../preferences/browser/settingsEditor2.ts | 53 +++++++------ .../preferences/browser/settingsTreeModels.ts | 76 ++++++++++--------- .../preferences/browser/settingsWidgets.ts | 4 +- .../contrib/preferences/browser/tocTree.ts | 4 +- .../services/search/node/textSearchManager.ts | 2 +- 8 files changed, 138 insertions(+), 127 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts index 4e724b3d988dc..356f87830bd28 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts @@ -63,15 +63,15 @@ export class PreferencesEditor extends BaseEditor { private defaultSettingsEditorContextKey: IContextKey; private defaultSettingsJSONEditorContextKey: IContextKey; private searchFocusContextKey: IContextKey; - private headerContainer: HTMLElement; - private searchWidget: SearchWidget; - private sideBySidePreferencesWidget: SideBySidePreferencesWidget; - private preferencesRenderers: PreferencesRenderersController; + private headerContainer!: HTMLElement; + private searchWidget!: SearchWidget; + private sideBySidePreferencesWidget!: SideBySidePreferencesWidget; + private preferencesRenderers!: PreferencesRenderersController; private delayedFilterLogging: Delayer; private localSearchDelayer: Delayer; private remoteSearchThrottle: ThrottledDelayer; - private _lastReportedFilter: string; + private _lastReportedFilter: string | null = null; private lastFocusedWidget: SearchWidget | SideBySidePreferencesWidget | undefined = undefined; @@ -298,7 +298,7 @@ export class PreferencesEditor extends BaseEditor { return result; } - private reportFilteringUsed(filter: string, filterResult: IFilterResult | undefined): void { + private reportFilteringUsed(filter: string, filterResult: IFilterResult | null): void { if (filter && filter !== this._lastReportedFilter) { const metadata = filterResult && filterResult.metadata; const counts = filterResult && this._countById(filterResult.filteredGroups); @@ -354,20 +354,20 @@ interface IPreferencesCount { class PreferencesRenderersController extends Disposable { - private _defaultPreferencesRenderer: IPreferencesRenderer; + private _defaultPreferencesRenderer!: IPreferencesRenderer; private _defaultPreferencesRendererDisposables: IDisposable[] = []; - private _editablePreferencesRenderer: IPreferencesRenderer; + private _editablePreferencesRenderer!: IPreferencesRenderer; private _editablePreferencesRendererDisposables: IDisposable[] = []; - private _settingsNavigator: SettingsNavigator; - private _remoteFilterCancelToken: CancellationTokenSource | undefined; + private _settingsNavigator: SettingsNavigator | null = null; + private _remoteFilterCancelToken: CancellationTokenSource | null = null; private _prefsModelsForSearch = new Map(); - private _currentLocalSearchProvider: ISearchProvider; - private _currentRemoteSearchProvider: ISearchProvider | undefined; - private _lastQuery: string; - private _lastFilterResult: IFilterResult | undefined; + private _currentLocalSearchProvider: ISearchProvider | null = null; + private _currentRemoteSearchProvider: ISearchProvider | null = null; + private _lastQuery = ''; + private _lastFilterResult: IFilterResult | null = null; private readonly _onDidFilterResultsCountChange: Emitter = this._register(new Emitter()); readonly onDidFilterResultsCountChange: Event = this._onDidFilterResultsCountChange.event; @@ -382,7 +382,7 @@ class PreferencesRenderersController extends Disposable { super(); } - get lastFilterResult(): IFilterResult | undefined { + get lastFilterResult(): IFilterResult | null { return this._lastFilterResult; } @@ -445,16 +445,16 @@ class PreferencesRenderersController extends Disposable { if (this._remoteFilterCancelToken) { this._remoteFilterCancelToken.cancel(); this._remoteFilterCancelToken.dispose(); - this._remoteFilterCancelToken = undefined; + this._remoteFilterCancelToken = null; } - this._currentRemoteSearchProvider = (updateCurrentResults && this._currentRemoteSearchProvider) || this.preferencesSearchService.getRemoteSearchProvider(query); + this._currentRemoteSearchProvider = (updateCurrentResults && this._currentRemoteSearchProvider) || this.preferencesSearchService.getRemoteSearchProvider(query) || null; this._remoteFilterCancelToken = new CancellationTokenSource(); return this.filterOrSearchPreferences(query, this._currentRemoteSearchProvider!, 'nlpResult', nls.localize('nlpResult', "Natural Language Results"), 1, this._remoteFilterCancelToken.token, updateCurrentResults).then(() => { if (this._remoteFilterCancelToken) { this._remoteFilterCancelToken.dispose(); - this._remoteFilterCancelToken = undefined; + this._remoteFilterCancelToken = null; } }, err => { if (isPromiseCanceledError(err)) { @@ -489,11 +489,11 @@ class PreferencesRenderersController extends Disposable { let [editableFilterResult, defaultFilterResult] = results; if (!defaultFilterResult && editableContentOnly) { - defaultFilterResult = this.lastFilterResult; + defaultFilterResult = this.lastFilterResult!; } this.consolidateAndUpdate(defaultFilterResult, editableFilterResult); - this._lastFilterResult = defaultFilterResult; + this._lastFilterResult = withUndefinedAsNull(defaultFilterResult); return !!(defaultFilterResult && defaultFilterResult.exactMatch); }); @@ -766,7 +766,7 @@ class SideBySidePreferencesWidget extends Widget { private defaultPreferencesHeader: HTMLElement; private defaultPreferencesEditor: DefaultPreferencesEditor; - private editablePreferencesEditor: BaseEditor; + private editablePreferencesEditor: BaseEditor | null = null; private defaultPreferencesEditorContainer: HTMLElement; private editablePreferencesEditorContainer: HTMLElement; @@ -780,7 +780,7 @@ class SideBySidePreferencesWidget extends Widget { private splitview: SplitView; - private isVisible: boolean; + private isVisible = false; private group: IEditorGroup | undefined; get minimumWidth(): number { return this.splitview.minimumSize; } @@ -850,7 +850,7 @@ class SideBySidePreferencesWidget extends Widget { this.settingsTargetsWidget.settingsTarget = this.getSettingsTarget(editablePreferencesEditorInput.getResource()!); return Promise.all([ this.updateInput(this.defaultPreferencesEditor, defaultPreferencesEditorInput, DefaultSettingsEditorContribution.ID, editablePreferencesEditorInput.getResource()!, options, token), - this.updateInput(this.editablePreferencesEditor, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource()!, options, token) + this.updateInput(this.editablePreferencesEditor!, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource()!, options, token) ]) .then(([defaultPreferencesRenderer, editablePreferencesRenderer]) => { if (token.isCancellationRequested) { @@ -1078,7 +1078,7 @@ interface ISettingsEditorContribution extends editorCommon.IEditorContribution { abstract class AbstractSettingsEditorContribution extends Disposable implements ISettingsEditorContribution { - private preferencesRendererCreationPromise: Promise | null> | null; + private preferencesRendererCreationPromise: Promise | null> | null = null; constructor(protected editor: ICodeEditor, @IInstantiationService protected instantiationService: IInstantiationService, diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts index ccede6e64c68c..6eb21cf8e1ac4 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts @@ -56,7 +56,7 @@ export class UserSettingsRenderer extends Disposable implements IPreferencesRend private editSettingActionRenderer: EditSettingRenderer; private highlightMatchesRenderer: HighlightMatchesRenderer; private modelChangeDelayer: Delayer = new Delayer(200); - private associatedPreferencesModel: IPreferencesEditorModel; + private associatedPreferencesModel!: IPreferencesEditorModel; private readonly _onFocusPreference = this._register(new Emitter()); readonly onFocusPreference: Event = this._onFocusPreference.event; @@ -228,7 +228,7 @@ export class FolderSettingsRenderer extends UserSettingsRenderer implements IPre export class DefaultSettingsRenderer extends Disposable implements IPreferencesRenderer { - private _associatedPreferencesModel: IPreferencesEditorModel; + private _associatedPreferencesModel!: IPreferencesEditorModel; private settingHighlighter: SettingHighlighter; private settingsHeaderRenderer: DefaultSettingsHeaderRenderer; private settingsGroupTitleRenderer: SettingsGroupTitleRenderer; @@ -362,7 +362,7 @@ export interface HiddenAreasProvider { export class BracesHidingRenderer extends Disposable implements HiddenAreasProvider { private _result: IFilterResult | undefined; - private _settingsGroups: ISettingsGroup[]; + private _settingsGroups!: ISettingsGroup[]; constructor(private editor: ICodeEditor) { super(); @@ -444,9 +444,9 @@ export class SettingsGroupTitleRenderer extends Disposable implements HiddenArea private readonly _onHiddenAreasChanged = this._register(new Emitter()); readonly onHiddenAreasChanged: Event = this._onHiddenAreasChanged.event; - private settingsGroups: ISettingsGroup[]; + private settingsGroups!: ISettingsGroup[]; private hiddenGroups: ISettingsGroup[] = []; - private settingsGroupTitleWidgets: SettingsGroupTitleWidget[]; + private settingsGroupTitleWidgets!: SettingsGroupTitleWidget[]; private readonly renderDisposables = this._register(new DisposableStore()); constructor(private editor: ICodeEditor, @@ -648,7 +648,7 @@ class EditSettingRenderer extends Disposable { private editPreferenceWidgetForMouseMove: EditPreferenceWidget; private settingsGroups: ISettingsGroup[] = []; - associatedPreferencesModel: IPreferencesEditorModel; + associatedPreferencesModel!: IPreferencesEditorModel; private toggleEditPreferencesForMouseMoveDelayer: Delayer; private readonly _onUpdateSetting: Emitter<{ key: string, value: any, source: IIndexedSetting }> = new Emitter<{ key: string, value: any, source: IIndexedSetting }>(); @@ -915,7 +915,7 @@ class SettingHighlighter extends Disposable { private fixedHighlighter: RangeHighlightDecorations; private volatileHighlighter: RangeHighlightDecorations; - private highlightedSetting: ISetting; + private highlightedSetting!: ISetting; constructor(private editor: ICodeEditor, private readonly focusEventEmitter: Emitter, private readonly clearFocusEventEmitter: Emitter, @IInstantiationService instantiationService: IInstantiationService @@ -1090,7 +1090,7 @@ class UnsupportedSettingsRenderer extends Disposable { class WorkspaceConfigurationRenderer extends Disposable { private decorationIds: string[] = []; - private associatedSettingsEditorModel: IPreferencesEditorModel; + private associatedSettingsEditorModel!: IPreferencesEditorModel; private renderingDelayer: Delayer = new Delayer(200); constructor(private editor: ICodeEditor, private workspaceSettingsEditorModel: SettingsEditorModel, diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 66678cbfffb4c..f46b01947be3b 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -36,11 +36,11 @@ import { ISettingsGroup } from 'vs/workbench/services/preferences/common/prefere export class SettingsHeaderWidget extends Widget implements IViewZone { - private id: string; - private _domNode: HTMLElement; + private id!: string; + private _domNode!: HTMLElement; - protected titleContainer: HTMLElement; - private messageElement: HTMLElement; + protected titleContainer!: HTMLElement; + private messageElement!: HTMLElement; constructor(protected editor: ICodeEditor, private title: string) { super(); @@ -121,18 +121,18 @@ export class DefaultSettingsHeaderWidget extends SettingsHeaderWidget { export class SettingsGroupTitleWidget extends Widget implements IViewZone { - private id: string; - private _afterLineNumber: number; - private _domNode: HTMLElement; + private id!: string; + private _afterLineNumber!: number; + private _domNode!: HTMLElement; - private titleContainer: HTMLElement; - private icon: HTMLElement; - private title: HTMLElement; + private titleContainer!: HTMLElement; + private icon!: HTMLElement; + private title!: HTMLElement; private _onToggled = this._register(new Emitter()); readonly onToggled: Event = this._onToggled.event; - private previousPosition: Position; + private previousPosition: Position | null = null; constructor(private editor: ICodeEditor, public settingsGroup: ISettingsGroup) { super(); @@ -296,11 +296,11 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem { private _folder: IWorkspaceFolder | null; private _folderSettingCounts = new Map(); - private container: HTMLElement; - private anchorElement: HTMLElement; - private labelElement: HTMLElement; - private detailsElement: HTMLElement; - private dropDownElement: HTMLElement; + private container!: HTMLElement; + private anchorElement!: HTMLElement; + private labelElement!: HTMLElement; + private detailsElement!: HTMLElement; + private dropDownElement!: HTMLElement; constructor( action: IAction, @@ -468,14 +468,14 @@ export interface ISettingsTargetsWidgetOptions { export class SettingsTargetsWidget extends Widget { - private settingsSwitcherBar: ActionBar; - private userLocalSettings: Action; - private userRemoteSettings: Action; - private workspaceSettings: Action; - private folderSettings: FolderSettingsActionViewItem; + private settingsSwitcherBar!: ActionBar; + private userLocalSettings!: Action; + private userRemoteSettings!: Action; + private workspaceSettings!: Action; + private folderSettings!: FolderSettingsActionViewItem; private options: ISettingsTargetsWidgetOptions; - private _settingsTarget: SettingsTarget; + private _settingsTarget: SettingsTarget | null = null; private readonly _onDidTargetChange = this._register(new Emitter()); readonly onDidTargetChange: Event = this._onDidTargetChange.event; @@ -525,11 +525,11 @@ export class SettingsTargetsWidget extends Widget { this.settingsSwitcherBar.push([this.userLocalSettings, this.userRemoteSettings, this.workspaceSettings, folderSettingsAction]); } - get settingsTarget(): SettingsTarget { + get settingsTarget(): SettingsTarget | null { return this._settingsTarget; } - set settingsTarget(settingsTarget: SettingsTarget) { + set settingsTarget(settingsTarget: SettingsTarget | null) { this._settingsTarget = settingsTarget; this.userLocalSettings.checked = ConfigurationTarget.USER_LOCAL === this.settingsTarget; this.userRemoteSettings.checked = ConfigurationTarget.USER_REMOTE === this.settingsTarget; @@ -602,12 +602,12 @@ export interface SearchOptions extends IInputOptions { export class SearchWidget extends Widget { - domNode: HTMLElement; + domNode!: HTMLElement; - private countElement: HTMLElement; - private searchContainer: HTMLElement; - inputBox: InputBox; - private controlsDiv: HTMLElement; + private countElement!: HTMLElement; + private searchContainer!: HTMLElement; + inputBox!: InputBox; + private controlsDiv!: HTMLElement; private readonly _onDidChange: Emitter = this._register(new Emitter()); readonly onDidChange: Event = this._onDidChange.event; @@ -739,8 +739,8 @@ export class EditPreferenceWidget extends Disposable { static readonly GLYPH_MARGIN_CLASS_NAME = 'edit-preferences-widget'; - private _line: number; - private _preferences: T[]; + private _line: number = -1; + private _preferences: T[] = []; private _editPreferenceDecoration: string[]; diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index 9a49fcd142599..7e3bca1e76fb8 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -85,54 +85,55 @@ export class SettingsEditor2 extends BaseEditor { type === SettingValueType.Exclude; } - private defaultSettingsEditorModel: Settings2EditorModel; + // (!) Lots of props that are set once on the first render + private defaultSettingsEditorModel!: Settings2EditorModel; - private rootElement: HTMLElement; - private headerContainer: HTMLElement; - private searchWidget: SuggestEnabledInput; - private countElement: HTMLElement; - private settingsTargetsWidget: SettingsTargetsWidget; + private rootElement!: HTMLElement; + private headerContainer!: HTMLElement; + private searchWidget!: SuggestEnabledInput; + private countElement!: HTMLElement; + private settingsTargetsWidget!: SettingsTargetsWidget; - private settingsTreeContainer: HTMLElement; - private settingsTree: SettingsTree; - private settingRenderers: SettingTreeRenderers; - private tocTreeModel: TOCTreeModel; - private settingsTreeModel: SettingsTreeModel; - private noResultsMessage: HTMLElement; - private clearFilterLinkContainer: HTMLElement; + private settingsTreeContainer!: HTMLElement; + private settingsTree!: SettingsTree; + private settingRenderers!: SettingTreeRenderers; + private tocTreeModel!: TOCTreeModel; + private settingsTreeModel!: SettingsTreeModel; + private noResultsMessage!: HTMLElement; + private clearFilterLinkContainer!: HTMLElement; - private tocTreeContainer: HTMLElement; - private tocTree: TOCTree; + private tocTreeContainer!: HTMLElement; + private tocTree!: TOCTree; - private settingsAriaExtraLabelsContainer: HTMLElement; + private settingsAriaExtraLabelsContainer!: HTMLElement; private delayedFilterLogging: Delayer; private localSearchDelayer: Delayer; private remoteSearchThrottle: ThrottledDelayer; - private searchInProgress: CancellationTokenSource | null; + private searchInProgress: CancellationTokenSource | null = null; private settingFastUpdateDelayer: Delayer; private settingSlowUpdateDelayer: Delayer; - private pendingSettingUpdate: { key: string, value: any } | null; + private pendingSettingUpdate: { key: string, value: any } | null = null; private readonly viewState: ISettingsEditorViewState; - private _searchResultModel: SearchResultModel | null; + private _searchResultModel: SearchResultModel | null = null; private tocRowFocused: IContextKey; private inSettingsEditorContextKey: IContextKey; private searchFocusContextKey: IContextKey; private scheduledRefreshes: Map; - private lastFocusedSettingElement: string; + private lastFocusedSettingElement: string | null = null; /** Don't spam warnings */ - private hasWarnedMissingSettings: boolean; + private hasWarnedMissingSettings = false; private editorMemento: IEditorMemento; - private tocFocusedElement: SettingsTreeGroupElement | null; + private tocFocusedElement: SettingsTreeGroupElement | null = null; private settingsTreeScrollTop = 0; - private dimension: DOM.Dimension; + private dimension!: DOM.Dimension; constructor( @ITelemetryService telemetryService: ITelemetryService, @@ -463,7 +464,7 @@ export class SettingsEditor2 extends BaseEditor { return this.openSettingsFile(query.query); } - private openSettingsFile(query?: string): Promise { + private async openSettingsFile(query?: string): Promise { const currentSettingsTarget = this.settingsTargetsWidget.settingsTarget; const options: ISettingsEditorOptions = { query }; @@ -473,9 +474,11 @@ export class SettingsEditor2 extends BaseEditor { return this.preferencesService.openRemoteSettings(); } else if (currentSettingsTarget === ConfigurationTarget.WORKSPACE) { return this.preferencesService.openWorkspaceSettings(true, options); - } else { + } else if (URI.isUri(currentSettingsTarget)) { return this.preferencesService.openFolderSettings(currentSettingsTarget, true, options); } + + return undefined; } private createBody(parent: HTMLElement): void { diff --git a/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts b/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts index efe952907cd15..eb76fe7dbd481 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts @@ -33,6 +33,11 @@ export abstract class SettingsTreeElement { * Index assigned in display order, used for paging. */ index: number; + + constructor(_id: string, _index: number) { + this.id = _id; + this.index = _index; + } } export type SettingsTreeGroupChild = (SettingsTreeGroupElement | SettingsTreeSettingElement | SettingsTreeNewExtensionsElement); @@ -43,8 +48,8 @@ export class SettingsTreeGroupElement extends SettingsTreeElement { level: number; isFirstGroup: boolean; - private _childSettingKeys: Set; - private _children: SettingsTreeGroupChild[]; + private _childSettingKeys: Set = new Set(); + private _children: SettingsTreeGroupChild[] = []; get children(): SettingsTreeGroupChild[] { return this._children; @@ -61,6 +66,15 @@ export class SettingsTreeGroupElement extends SettingsTreeElement { }); } + constructor(_id: string, _index: number, count: number | undefined, label: string, level: number, isFirstGroup: boolean) { + super(_id, _index); + + this.count = count; + this.label = label; + this.level = level; + this.isFirstGroup = isFirstGroup; + } + /** * Returns whether this group contains the given child key (to a depth of 1 only) */ @@ -70,7 +84,9 @@ export class SettingsTreeGroupElement extends SettingsTreeElement { } export class SettingsTreeNewExtensionsElement extends SettingsTreeElement { - extensionIds: string[]; + constructor(_id: string, _index: number, public readonly extensionIds: string[]) { + super(_id, _index); + } } export class SettingsTreeSettingElement extends SettingsTreeElement { @@ -78,8 +94,8 @@ export class SettingsTreeSettingElement extends SettingsTreeElement { setting: ISetting; - private _displayCategory: string; - private _displayLabel: string; + private _displayCategory: string | null = null; + private _displayLabel: string | null = null; /** * scopeValue || defaultValue, for rendering convenience. @@ -99,19 +115,17 @@ export class SettingsTreeSettingElement extends SettingsTreeElement { /** * Whether the setting is configured in the selected scope. */ - isConfigured: boolean; + isConfigured = false; tags?: Set; - overriddenScopeList: string[]; - description: string; - valueType: SettingValueType; + overriddenScopeList: string[] = []; + description!: string; + valueType!: SettingValueType; constructor(setting: ISetting, parent: SettingsTreeGroupElement, index: number, inspectResult: IInspectResult) { - super(); - this.index = index; + super(sanitizeId(parent.id + '_' + setting.key), index); this.setting = setting; this.parent = parent; - this.id = sanitizeId(parent.id + '_' + setting.key); this.update(inspectResult); } @@ -121,7 +135,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement { this.initLabel(); } - return this._displayCategory; + return this._displayCategory!; } get displayLabel(): string { @@ -129,7 +143,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement { this.initLabel(); } - return this._displayLabel; + return this._displayLabel!; } private initLabel(): void { @@ -270,10 +284,10 @@ export class SettingsTreeSettingElement extends SettingsTreeElement { } export class SettingsTreeModel { - protected _root: SettingsTreeGroupElement; + protected _root!: SettingsTreeGroupElement; protected _treeElementsById = new Map(); private _treeElementsBySettingName = new Map(); - private _tocRoot: ITOCEntry; + private _tocRoot!: ITOCEntry; constructor( protected _viewState: ISettingsEditorViewState, @@ -320,13 +334,10 @@ export class SettingsTreeModel { } private createSettingsTreeGroupElement(tocEntry: ITOCEntry, parent?: SettingsTreeGroupElement): SettingsTreeGroupElement { - const element = new SettingsTreeGroupElement(); + const index = this._treeElementsById.size; - element.index = index; - element.id = tocEntry.id; - element.label = tocEntry.label; - element.parent = parent; - element.level = this.getDepth(element); + const depth = parent ? this.getDepth(parent) + 1 : 0; + const element = new SettingsTreeGroupElement(tocEntry.id, index, undefined, tocEntry.label, depth, false); const children: SettingsTreeGroupChild[] = []; if (tocEntry.settings) { @@ -482,9 +493,9 @@ export const enum SearchResultIdx { } export class SearchResultModel extends SettingsTreeModel { - private rawSearchResults: ISearchResult[]; - private cachedUniqueSearchResults: ISearchResult[] | undefined; - private newExtensionSearchResults: ISearchResult; + private rawSearchResults: ISearchResult[] | null = null; + private cachedUniqueSearchResults: ISearchResult[] | null = null; + private newExtensionSearchResults: ISearchResult | null = null; readonly id = 'searchResultModel'; @@ -526,11 +537,11 @@ export class SearchResultModel extends SettingsTreeModel { } getRawResults(): ISearchResult[] { - return this.rawSearchResults; + return this.rawSearchResults || []; } setResult(order: SearchResultIdx, result: ISearchResult | null): void { - this.cachedUniqueSearchResults = undefined; + this.cachedUniqueSearchResults = null; this.rawSearchResults = this.rawSearchResults || []; if (!result) { delete this.rawSearchResults[order]; @@ -554,17 +565,14 @@ export class SearchResultModel extends SettingsTreeModel { .filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget, isRemote) && child.matchesAnyExtension(this._viewState.extensionFilters)); if (this.newExtensionSearchResults && this.newExtensionSearchResults.filterMatches.length) { - const newExtElement = new SettingsTreeNewExtensionsElement(); - newExtElement.index = this._treeElementsById.size; - newExtElement.parent = this._root; - newExtElement.id = 'newExtensions'; - this._treeElementsById.set(newExtElement.id, newExtElement); - const resultExtensionIds = this.newExtensionSearchResults.filterMatches .map(result => (result.setting)) .filter(setting => setting.extensionName && setting.extensionPublisher) .map(setting => `${setting.extensionPublisher}.${setting.extensionName}`); - newExtElement.extensionIds = arrays.distinct(resultExtensionIds); + + const newExtElement = new SettingsTreeNewExtensionsElement('newExtensions', this._treeElementsById.size, arrays.distinct(resultExtensionIds)); + newExtElement.parent = this._root; + this._treeElementsById.set(newExtElement.id, newExtElement); this._root.children.push(newExtElement); } } diff --git a/src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts b/src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts index a52e919c7bf29..798a9b005146d 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts @@ -136,8 +136,8 @@ type EditKey = 'none' | 'create' | number; export class ListSettingListModel { private _dataItems: IListDataItem[] = []; - private _editKey: EditKey; - private _selectedIdx: number | null; + private _editKey: EditKey | null = null; + private _selectedIdx: number | null = null; get items(): IListViewItem[] { const items = this._dataItems.map((item, i) => { diff --git a/src/vs/workbench/contrib/preferences/browser/tocTree.ts b/src/vs/workbench/contrib/preferences/browser/tocTree.ts index 6a4df8af7d090..0576d491913eb 100644 --- a/src/vs/workbench/contrib/preferences/browser/tocTree.ts +++ b/src/vs/workbench/contrib/preferences/browser/tocTree.ts @@ -23,8 +23,8 @@ const $ = DOM.$; export class TOCTreeModel { - private _currentSearchModel: SearchResultModel | null; - private _settingsTreeRoot: SettingsTreeGroupElement; + private _currentSearchModel: SearchResultModel | null = null; + private _settingsTreeRoot!: SettingsTreeGroupElement; constructor( private _viewState: ISettingsEditorViewState, diff --git a/src/vs/workbench/services/search/node/textSearchManager.ts b/src/vs/workbench/services/search/node/textSearchManager.ts index 9d566a9bdabaa..e7586a912cdfa 100644 --- a/src/vs/workbench/services/search/node/textSearchManager.ts +++ b/src/vs/workbench/services/search/node/textSearchManager.ts @@ -199,7 +199,7 @@ export class TextSearchResultsCollector { private _batchedCollector: BatchedCollector; private _currentFolderIdx: number = -1; - private _currentUri: URI; + private _currentUri: URI | undefined; private _currentFileMatch: IFileMatch | null = null; constructor(private _onResult: (result: IFileMatch[]) => void) { From 6a7d6ea65eaabca3d7159a5fadd539ee7bb9766c Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 11:38:27 -0700 Subject: [PATCH 067/204] Don't log black text --- src/vs/base/common/console.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/base/common/console.ts b/src/vs/base/common/console.ts index 9b49ff985d4df..478e06077a648 100644 --- a/src/vs/base/common/console.ts +++ b/src/vs/base/common/console.ts @@ -114,9 +114,9 @@ export function log(entry: IRemoteConsoleLog, label: string): void { // First arg is a string if (typeof args[0] === 'string') { if (topFrame && isOneStringArg) { - consoleArgs = [`%c[${label}] %c${args[0]} %c${topFrame}`, color('blue'), color('black'), color('grey')]; + consoleArgs = [`%c[${label}] %c${args[0]} %c${topFrame}`, color('blue'), color(''), color('grey')]; } else { - consoleArgs = [`%c[${label}] %c${args[0]}`, color('blue'), color('black'), ...args.slice(1)]; + consoleArgs = [`%c[${label}] %c${args[0]}`, color('blue'), color(''), ...args.slice(1)]; } } @@ -139,4 +139,4 @@ export function log(entry: IRemoteConsoleLog, label: string): void { function color(color: string): string { return `color: ${color}`; -} \ No newline at end of file +} From b30aba88daf69784aa2085ba95eaac7c8be8411e Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Wed, 4 Sep 2019 11:47:53 -0700 Subject: [PATCH 068/204] fix the custom menu bar refs #78167 --- src/vs/base/browser/ui/splitview/splitview.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/base/browser/ui/splitview/splitview.css b/src/vs/base/browser/ui/splitview/splitview.css index c1b30bf9a3b1b..75e686cb5fcfc 100644 --- a/src/vs/base/browser/ui/splitview/splitview.css +++ b/src/vs/base/browser/ui/splitview/splitview.css @@ -30,7 +30,6 @@ .monaco-split-view2 > .split-view-container > .split-view-view { white-space: initial; position: absolute; - overflow: hidden; } .monaco-split-view2 > .split-view-container > .split-view-view:not(.visible) { From 5f36b0ea9ab48abc4be5a4b51124d0fede4d1630 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 14:32:15 -0700 Subject: [PATCH 069/204] Fix rawSearchService to handle maxResults=0 correctly Fix #79909 --- .../services/search/node/rawSearchService.ts | 2 +- .../search/test/node/rawSearchService.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/services/search/node/rawSearchService.ts b/src/vs/workbench/services/search/node/rawSearchService.ts index 2a27d205aac14..c0d0e6d635861 100644 --- a/src/vs/workbench/services/search/node/rawSearchService.ts +++ b/src/vs/workbench/services/search/node/rawSearchService.ts @@ -254,7 +254,7 @@ export class SearchService implements IRawSearchService { const query = prepareQuery(config.filePattern || ''); const compare = (matchA: IRawFileMatch, matchB: IRawFileMatch) => compareItemsByScore(matchA, matchB, query, true, FileMatchItemAccessor, scorerCache); - const maxResults = config.maxResults || Number.MAX_VALUE; + const maxResults = typeof config.maxResults === 'number' ? config.maxResults : Number.MAX_VALUE; return arrays.topAsync(results, compare, maxResults, 10000, token); } diff --git a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts index 4060adff5f03e..c0a85168b8029 100644 --- a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts +++ b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts @@ -185,6 +185,25 @@ suite('RawSearchService', () => { assert.strictEqual(result.results.length, 1, 'Result'); }); + test('Handles maxResults=0 correctly', async function () { + this.timeout(testTimeout); + const service = new RawSearchService(); + + const query: IFileQuery = { + type: QueryType.File, + folderQueries: MULTIROOT_QUERIES, + maxResults: 0, + sortByScore: true, + includePattern: { + '*.txt': true, + '*.js': true + }, + }; + + const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query)); + assert.strictEqual(result.results.length, 0, 'Result'); + }); + test('Multi-root with include pattern and exists', async function () { this.timeout(testTimeout); const service = new RawSearchService(); From 58c740aa4887e0f399259577e44cd23cb31fca6b Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 14:52:47 -0700 Subject: [PATCH 070/204] Remove workaround for #74875 --- test/smoke/src/areas/multiroot/multiroot.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/smoke/src/areas/multiroot/multiroot.test.ts b/test/smoke/src/areas/multiroot/multiroot.test.ts index d6c656bc43311..bfc70dbf8ca80 100644 --- a/test/smoke/src/areas/multiroot/multiroot.test.ts +++ b/test/smoke/src/areas/multiroot/multiroot.test.ts @@ -47,8 +47,7 @@ export function setup() { const app = this.app as Application; await app.workbench.quickopen.openQuickOpen('*.*'); - // TODO roblourens: Go to files finds welcome page: issue 74875 - await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 6 || names.length === 7); + await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 6); await app.workbench.quickopen.closeQuickOpen(); }); @@ -57,4 +56,4 @@ export function setup() { await app.code.waitForTitle(title => /smoketest \(Workspace\)/i.test(title)); }); }); -} \ No newline at end of file +} From cb6b17d6f36156cdbe48a6eaa8aac8895e95df4e Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 29 Aug 2019 17:23:16 -0700 Subject: [PATCH 071/204] Make DebugSession.name writable; fixes #79583 --- src/vs/vscode.d.ts | 5 +-- .../api/browser/mainThreadDebugService.ts | 10 ++++++ .../workbench/api/common/extHost.protocol.ts | 2 ++ .../workbench/api/node/extHostDebugService.ts | 16 ++++++++++ .../contrib/debug/browser/callStackView.ts | 1 + .../debug/browser/debugActionViewItems.ts | 8 ++++- .../contrib/debug/browser/debugSession.ts | 15 ++++++++- .../debug/browser/loadedScriptsView.ts | 32 +++++++++++-------- .../workbench/contrib/debug/common/debug.ts | 2 ++ .../contrib/debug/test/common/mockDebug.ts | 8 +++++ 10 files changed, 82 insertions(+), 17 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 4bf390ca0caa9..812ac85c81ef7 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -8687,9 +8687,10 @@ declare module 'vscode' { readonly type: string; /** - * The debug session's name from the [debug configuration](#DebugConfiguration). + * The debug session's name is initially taken from the [debug configuration](#DebugConfiguration). + * Any changes will be properly reflected in the UI. */ - readonly name: string; + name: string; /** * The workspace folder of this session or `undefined` for a folderless setup. diff --git a/src/vs/workbench/api/browser/mainThreadDebugService.ts b/src/vs/workbench/api/browser/mainThreadDebugService.ts index 2f0f5283bfd21..5fb712fd22858 100644 --- a/src/vs/workbench/api/browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/browser/mainThreadDebugService.ts @@ -35,6 +35,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDebugService); this._toDispose.add(debugService.onDidNewSession(session => { this._proxy.$acceptDebugSessionStarted(this.getSessionDto(session)); + this._toDispose.add(session.onDidChangeName(name => { + this._proxy.$acceptDebugSessionNameChanged(this.getSessionDto(session), name); + })); })); // Need to start listening early to new session events because a custom event can come while a session is initialising this._toDispose.add(debugService.onWillNewSession(session => { @@ -225,6 +228,13 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb }); } + public $setDebugSessionName(sessionId: DebugSessionUUID, name: string): void { + const session = this.debugService.getModel().getSession(sessionId); + if (session) { + session.setName(name); + } + } + public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): Promise { const session = this.debugService.getModel().getSession(sessionId, true); if (session) { diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index a6ac9b8086c7e..dc608272431e9 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -717,6 +717,7 @@ export interface MainThreadDebugServiceShape extends IDisposable { $unregisterDebugConfigurationProvider(handle: number): void; $unregisterDebugAdapterDescriptorFactory(handle: number): void; $startDebugging(folder: UriComponents | undefined, nameOrConfig: string | IDebugConfiguration, parentSessionID: string | undefined): Promise; + $setDebugSessionName(id: DebugSessionUUID, name: string): void; $customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): Promise; $appendDebugConsole(value: string): void; $startBreakpointEvents(): void; @@ -1263,6 +1264,7 @@ export interface ExtHostDebugServiceShape { $acceptDebugSessionActiveChanged(session: IDebugSessionDto | undefined): void; $acceptDebugSessionCustomEvent(session: IDebugSessionDto, event: any): void; $acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void; + $acceptDebugSessionNameChanged(session: IDebugSessionDto, name: string): void; } diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index c82f788a37098..bcb8c9810be6f 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -687,6 +687,13 @@ export class ExtHostDebugService implements IExtHostDebugService, ExtHostDebugSe this._onDidChangeActiveDebugSession.fire(this._activeDebugSession); } + public async $acceptDebugSessionNameChanged(sessionDto: IDebugSessionDto, name: string): Promise { + const session = await this.getSession(sessionDto); + if (session) { + session._acceptNameChanged(name); + } + } + public async $acceptDebugSessionCustomEvent(sessionDto: IDebugSessionDto, event: any): Promise { const session = await this.getSession(sessionDto); const ee: vscode.DebugSessionCustomEvent = { @@ -917,6 +924,15 @@ export class ExtHostDebugSession implements vscode.DebugSession { return this._name; } + public set name(name: string) { + this._name = name; + this._debugServiceProxy.$setDebugSessionName(this._id, name); + } + + _acceptNameChanged(name: string) { + this._name = name; + } + public get workspaceFolder(): vscode.WorkspaceFolder | undefined { return this._workspaceFolder; } diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index 46e90870f22b6..be89d1a269699 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -227,6 +227,7 @@ export class CallStackView extends ViewletPanel { })); this._register(this.debugService.onDidNewSession(s => { + this._register(s.onDidChangeName(() => this.tree.rerender(s))); if (s.parentSession) { // Auto expand sessions that have sub sessions this.parentSessionToExpand.add(s.parentSession); diff --git a/src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts b/src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts index 8e4b12fde6c89..1904bd302ad74 100644 --- a/src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts +++ b/src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts @@ -209,7 +209,13 @@ export class FocusSessionActionViewItem extends SelectActionViewItem { } })); - this._register(this.debugService.onDidNewSession(() => this.update())); + this._register(this.debugService.onDidNewSession(session => { + this._register(session.onDidChangeName(() => this.update())); + this.update(); + })); + this.getSessions().forEach(session => { + this._register(session.onDidChangeName(() => this.update())); + }); this._register(this.debugService.onDidEndSession(() => this.update())); this.update(); diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index 01151248238c7..73907b3ca15c0 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -55,6 +55,9 @@ export class DebugSession implements IDebugSession { private readonly _onDidChangeREPLElements = new Emitter(); + private name: string | undefined; + private readonly _onDidChangeName = new Emitter(); + constructor( private _configuration: { resolved: IConfig, unresolved: IConfig | undefined }, public root: IWorkspaceFolder, @@ -105,7 +108,13 @@ export class DebugSession implements IDebugSession { getLabel(): string { const includeRoot = this.workspaceContextService.getWorkspace().folders.length > 1; - return includeRoot && this.root ? `${this.configuration.name} (${resources.basenameOrAuthority(this.root.uri)})` : this.configuration.name; + const name = this.name || this.configuration.name; + return includeRoot && this.root ? `${name} (${resources.basenameOrAuthority(this.root.uri)})` : name; + } + + setName(name: string): void { + this.name = name; + this._onDidChangeName.fire(name); } get state(): State { @@ -144,6 +153,10 @@ export class DebugSession implements IDebugSession { return this._onDidChangeREPLElements.event; } + get onDidChangeName(): Event { + return this._onDidChangeName.event; + } + //---- DAP events get onDidCustomEvent(): Event { diff --git a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts index 6a70b78319ba4..742b41df2aac7 100644 --- a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts @@ -466,7 +466,21 @@ export class LoadedScriptsView extends ViewletPanel { } })); - const registerLoadedSourceListener = (session: IDebugSession) => { + const scheduleRefreshOnVisible = () => { + if (this.isBodyVisible()) { + this.changeScheduler.schedule(); + } else { + this.treeNeedsRefreshOnVisible = true; + } + }; + + const registerSessionListeners = (session: IDebugSession) => { + this._register(session.onDidChangeName(() => { + // Re-add session, this will trigger proper sorting and id recalculation. + root.remove(session.getId()); + root.add(session); + scheduleRefreshOnVisible(); + })); this._register(session.onDidLoadedSource(event => { let sessionRoot: SessionTreeItem; switch (event.reason) { @@ -474,11 +488,7 @@ export class LoadedScriptsView extends ViewletPanel { case 'changed': sessionRoot = root.add(session); sessionRoot.addPath(event.source); - if (this.isBodyVisible()) { - this.changeScheduler.schedule(); - } else { - this.treeNeedsRefreshOnVisible = true; - } + scheduleRefreshOnVisible(); if (event.reason === 'changed') { DebugContentProvider.refreshDebugContent(event.source.uri); } @@ -486,11 +496,7 @@ export class LoadedScriptsView extends ViewletPanel { case 'removed': sessionRoot = root.find(session); if (sessionRoot && sessionRoot.removePath(event.source)) { - if (this.isBodyVisible()) { - this.changeScheduler.schedule(); - } else { - this.treeNeedsRefreshOnVisible = true; - } + scheduleRefreshOnVisible(); } break; default: @@ -501,8 +507,8 @@ export class LoadedScriptsView extends ViewletPanel { })); }; - this._register(this.debugService.onDidNewSession(registerLoadedSourceListener)); - this.debugService.getModel().getSessions().forEach(registerLoadedSourceListener); + this._register(this.debugService.onDidNewSession(registerSessionListeners)); + this.debugService.getModel().getSessions().forEach(registerSessionListeners); this._register(this.debugService.onDidEndSession(session => { root.remove(session.getId()); diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 42a3576979723..6fe72895ba010 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -157,6 +157,8 @@ export interface IDebugSession extends ITreeElement { setSubId(subId: string | undefined): void; + setName(name: string): void; + readonly onDidChangeName: Event; getLabel(): string; getSourceForUri(modelUri: uri): Source | undefined; diff --git a/src/vs/workbench/contrib/debug/test/common/mockDebug.ts b/src/vs/workbench/contrib/debug/test/common/mockDebug.ts index bb10110ab92cc..4515e8afef4cc 100644 --- a/src/vs/workbench/contrib/debug/test/common/mockDebug.ts +++ b/src/vs/workbench/contrib/debug/test/common/mockDebug.ts @@ -180,6 +180,10 @@ export class MockSession implements IDebugSession { return 'mockname'; } + setName(name: string): void { + throw new Error('not implemented'); + } + getSourceForUri(modelUri: uri): Source { throw new Error('not implemented'); } @@ -204,6 +208,10 @@ export class MockSession implements IDebugSession { throw new Error('not implemented'); } + get onDidChangeName(): Event { + throw new Error('not implemented'); + } + setConfiguration(configuration: { resolved: IConfig, unresolved: IConfig }) { } getAllThreads(): IThread[] { From 2da473b000eb514669722f833498e872c46c446f Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Wed, 4 Sep 2019 15:14:52 -0700 Subject: [PATCH 072/204] make activity bar hide itself --- .../browser/parts/activitybar/activitybarPart.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index 5d56b84987b88..1afbdd3e69a9d 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -198,6 +198,8 @@ export class ActivitybarPart extends Part implements IActivityBarService { this.createGlobalActivityActionBar(globalActivities); + this.element.style.display = this.layoutService.isVisible(Parts.ACTIVITYBAR_PART) ? null : 'none'; + return content; } @@ -368,6 +370,12 @@ export class ActivitybarPart extends Part implements IActivityBarService { .map(v => v.id); } + setVisible(visible: boolean): void { + if (this.element) { + this.element.style.display = visible ? null : 'none'; + } + } + layout(width: number, height: number): void { if (!this.layoutService.isVisible(Parts.ACTIVITYBAR_PART)) { return; From 3ba84a8c070b1abcdcb6ca64f2dd6dfd48709078 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 15:56:46 -0700 Subject: [PATCH 073/204] Fix #80334 --- src/vs/workbench/services/history/browser/history.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index d568f30b17010..4e092146cc5fd 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -487,12 +487,12 @@ export class HistoryService extends Disposable implements IHistoryService { return; } - const history = this.ensureHistoryLoaded(); - const historyInput = this.preferResourceInput(input); // Remove any existing entry and add to the beginning this.removeFromHistory(input); + + const history = this.ensureHistoryLoaded(); history.unshift(historyInput); // Respect max entries setting From b0cb3ddcc2197a16aece7b053c0a069ea0744cf5 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 16:29:00 -0700 Subject: [PATCH 074/204] Fix #80251 --- .../contrib/search/common/searchModel.ts | 16 +++++++--------- .../search/test/common/searchModel.test.ts | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index e6205366550ee..4712e2c19e3c3 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -982,16 +982,7 @@ export class SearchModel extends Disposable { */ onFirstRenderStopwatch(duration => this.telemetryService.publicLog('searchResultsFirstRender', { duration })); - const onDoneStopwatch = Event.stopwatch(onDone); const start = Date.now(); - - /* __GDPR__ - "searchResultsFinished" : { - "duration" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true } - } - */ - onDoneStopwatch(duration => this.telemetryService.publicLog('searchResultsFinished', { duration })); - currentRequest.then( value => this.onSearchCompleted(value, Date.now() - start), e => this.onSearchError(e, Date.now() - start)); @@ -1000,6 +991,13 @@ export class SearchModel extends Disposable { } private onSearchCompleted(completed: ISearchComplete | null, duration: number): ISearchComplete | null { + /* __GDPR__ + "searchResultsFinished" : { + "duration" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true } + } + */ + this.telemetryService.publicLog('searchResultsFinished', { duration }); + if (!this._searchQuery) { throw new Error('onSearchCompleted must be called after a search is started'); } diff --git a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts index a834061021843..dc9e8347bfd71 100644 --- a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts @@ -158,7 +158,7 @@ suite('SearchModel', () => { const testObject: SearchModel = instantiationService.createInstance(SearchModel); await testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries }); - await timeout(0); // TODO@rob https://github.com/microsoft/vscode/issues/80251 + // await timeout(0); // TODO@rob https://github.com/microsoft/vscode/issues/80251 assert.ok(target.calledThrice); const data = target.args[0]; From e878c3e97c18e928a6d2565dd8a4204b1bd4c02f Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 5 Sep 2019 01:30:05 +0200 Subject: [PATCH 075/204] strict property init - markers --- .../contrib/markers/browser/markersPanel.ts | 63 +- .../markers/browser/markersPanelActions.ts | 45 +- .../markers/browser/markersTreeViewer.ts | 4 +- .../contrib/markers/browser/markersWidget.ts | 1050 ----------------- 4 files changed, 54 insertions(+), 1108 deletions(-) delete mode 100644 src/vs/workbench/contrib/markers/browser/markersWidget.ts diff --git a/src/vs/workbench/contrib/markers/browser/markersPanel.ts b/src/vs/workbench/contrib/markers/browser/markersPanel.ts index cea80184fe4b9..0399a75b19854 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanel.ts @@ -69,23 +69,21 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { private lastSelectedRelativeTop: number = 0; private currentActiveResource: URI | null = null; - private tree: WorkbenchObjectTree; - private treeLabels: ResourceLabels; - private rangeHighlightDecorations: RangeHighlightDecorations; - - private actions: IAction[]; - private collapseAllAction: IAction; - private filterAction: MarkersFilterAction; - private filterInputActionViewItem: MarkersFilterActionViewItem; - - private treeContainer: HTMLElement; - private messageBoxContainer: HTMLElement; - private ariaLabelElement: HTMLElement; + private readonly rangeHighlightDecorations: RangeHighlightDecorations; + private readonly filter: Filter; + + private tree!: WorkbenchObjectTree; + private treeContainer!: HTMLElement; + private messageBoxContainer!: HTMLElement; + private ariaLabelElement!: HTMLElement; + + private readonly collapseAllAction: IAction; + private readonly filterAction: MarkersFilterAction; + private filterInputActionViewItem: MarkersFilterActionViewItem | null = null; + private readonly panelState: MementoObject; private panelFoucusContextKey: IContextKey; - private filter: Filter; - private _onDidFilter = this._register(new Emitter()); readonly onDidFilter: Event = this._onDidFilter.event; private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined; @@ -114,12 +112,18 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']); this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables); this.setCurrentActiveEditor(); + + this.filter = new Filter(new FilterOptions()); + this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations)); + + // actions + this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => this.collapseAll()); + this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] }); } public create(parent: HTMLElement): void { super.create(parent); - this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations)); dom.addClass(parent, 'markers-panel'); @@ -128,7 +132,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { this.createArialLabelElement(container); this.createMessageBox(container); this.createTree(container); - this.createActions(); this.createListeners(); this.updateFilter(); @@ -178,10 +181,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } public getActions(): IAction[] { - if (!this.actions) { - this.createActions(); - } - return this.actions; + return [this.filterAction, this.collapseAllAction]; } public showQuickFixes(marker: Marker): void { @@ -306,15 +306,14 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { const onDidChangeRenderNodeCount = new Relay>(); - this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); + const treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); const virtualDelegate = new VirtualDelegate(this.markersViewModel); const renderers = [ - this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), + this.instantiationService.createInstance(ResourceMarkersRenderer, treeLabels, onDidChangeRenderNodeCount.event), this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel), this.instantiationService.createInstance(RelatedInformationRenderer) ]; - this.filter = new Filter(new FilterOptions()); const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); const identityProvider = { @@ -396,17 +395,12 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { })); } - private createActions(): void { - this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { - this.tree.collapseAll(); - this.tree.setSelection([]); - this.tree.setFocus([]); - this.tree.getHTMLElement().focus(); - this.tree.focusFirst(); - }); - - this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] }); - this.actions = [this.filterAction, this.collapseAllAction]; + private collapseAll(): void { + this.tree.collapseAll(); + this.tree.setSelection([]); + this.tree.setFocus([]); + this.tree.getHTMLElement().focus(); + this.tree.focusFirst(); } private createListeners(): void { @@ -423,7 +417,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { this.updateFilter(); } })); - this.actions.forEach(a => this._register(a)); } private onDidChangeModel(change: MarkerChangesEvent) { diff --git a/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts b/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts index f2747c02b15a6..c45dee82e5dbd 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanelActions.ts @@ -118,10 +118,9 @@ export interface IMarkerFilterController { export class MarkersFilterActionViewItem extends BaseActionViewItem { private delayedFilterUpdate: Delayer; - private container: HTMLElement; - private filterInputBox: HistoryInputBox; - private controlsContainer: HTMLInputElement; - private filterBadge: HTMLInputElement; + private container: HTMLElement | null = null; + private filterInputBox: HistoryInputBox | null = null; + private filterBadge: HTMLElement | null = null; private focusContextKey: IContextKey; constructor( @@ -172,13 +171,13 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { this.filterInputBox.inputElement.setAttribute('aria-labelledby', 'markers-panel-arialabel'); this._register(attachInputBoxStyler(this.filterInputBox, this.themeService)); this.filterInputBox.value = this.action.filterText; - this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox)))); + this._register(this.filterInputBox.onDidChange(filter => this.delayedFilterUpdate.trigger(() => this.onDidInputChange(this.filterInputBox!)))); this._register(this.action.onDidChange((event: IMarkersFilterActionChangeEvent) => { if (event.filterText) { - this.filterInputBox.value = this.action.filterText; + this.filterInputBox!.value = this.action.filterText; } })); - this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox))); + this._register(DOM.addStandardDisposableListener(this.filterInputBox.inputElement, DOM.EventType.KEY_DOWN, (e: any) => this.onInputKeyDown(e, this.filterInputBox!))); this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_DOWN, this.handleKeyboardEvent)); this._register(DOM.addStandardDisposableListener(container, DOM.EventType.KEY_UP, this.handleKeyboardEvent)); @@ -189,24 +188,24 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { } private createControls(container: HTMLElement): void { - this.controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls')); - this.createBadge(this.controlsContainer); - this.createFilesExcludeCheckbox(this.controlsContainer); + const controlsContainer = DOM.append(container, DOM.$('.markers-panel-filter-controls')); + this.createBadge(controlsContainer); + this.createFilesExcludeCheckbox(controlsContainer); } private createBadge(container: HTMLElement): void { - this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge')); + const filterBadge = this.filterBadge = DOM.append(container, DOM.$('.markers-panel-filter-badge')); this._register(attachStylerCallback(this.themeService, { badgeBackground, badgeForeground, contrastBorder }, colors => { const background = colors.badgeBackground ? colors.badgeBackground.toString() : null; const foreground = colors.badgeForeground ? colors.badgeForeground.toString() : null; const border = colors.contrastBorder ? colors.contrastBorder.toString() : null; - this.filterBadge.style.backgroundColor = background; + filterBadge.style.backgroundColor = background; - this.filterBadge.style.borderWidth = border ? '1px' : null; - this.filterBadge.style.borderStyle = border ? 'solid' : null; - this.filterBadge.style.borderColor = border; - this.filterBadge.style.color = foreground; + filterBadge.style.borderWidth = border ? '1px' : null; + filterBadge.style.borderStyle = border ? 'solid' : null; + filterBadge.style.borderColor = border; + filterBadge.style.color = foreground; })); this.updateBadge(); this._register(this.filterController.onDidFilter(() => this.updateBadge())); @@ -241,14 +240,18 @@ export class MarkersFilterActionViewItem extends BaseActionViewItem { } private updateBadge(): void { - const { total, filtered } = this.filterController.getFilterStats(); - DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0); - this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total); - this.adjustInputBox(); + if (this.filterBadge) { + const { total, filtered } = this.filterController.getFilterStats(); + DOM.toggleClass(this.filterBadge, 'hidden', total === filtered || filtered === 0); + this.filterBadge.textContent = localize('showing filtered problems', "Showing {0} of {1}", filtered, total); + this.adjustInputBox(); + } } private adjustInputBox(): void { - this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px'; + if (this.container && this.filterInputBox && this.filterBadge) { + this.filterInputBox.inputElement.style.paddingRight = DOM.hasClass(this.container, 'small') || DOM.hasClass(this.filterBadge, 'hidden') ? '25px' : '150px'; + } } // Action toolbar is swallowing some keys for action items which should not be for an input box diff --git a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts index 156c52dd12597..bf6546b0d72d6 100644 --- a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts @@ -510,7 +510,7 @@ export class MarkerViewModel extends Disposable { } } - private _quickFixAction: QuickFixAction; + private _quickFixAction: QuickFixAction | null = null; get quickFixAction(): QuickFixAction { if (!this._quickFixAction) { this._quickFixAction = this._register(this.instantiationService.createInstance(QuickFixAction, this.marker)); @@ -616,7 +616,7 @@ export class MarkersViewModel extends Disposable { private bulkUpdate: boolean = false; - private hoveredMarker: Marker | null; + private hoveredMarker: Marker | null = null; private hoverDelayer: Delayer = new Delayer(300); constructor( diff --git a/src/vs/workbench/contrib/markers/browser/markersWidget.ts b/src/vs/workbench/contrib/markers/browser/markersWidget.ts deleted file mode 100644 index 8508bffd29ed2..0000000000000 --- a/src/vs/workbench/contrib/markers/browser/markersWidget.ts +++ /dev/null @@ -1,1050 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import 'vs/css!./media/markers'; - -import { URI } from 'vs/base/common/uri'; -import * as dom from 'vs/base/browser/dom'; -import { IAction, IActionViewItem, Action } from 'vs/base/common/actions'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; -import Constants from 'vs/workbench/contrib/markers/browser/constants'; -import { Marker, ResourceMarkers, RelatedInformation, MarkersModel, MarkerChangesEvent } from 'vs/workbench/contrib/markers/browser/markersModel'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { MarkersFilterActionViewItem, MarkersFilterAction, IMarkersFilterActionChangeEvent } from 'vs/workbench/contrib/markers/browser/markersPanelActions'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import Messages from 'vs/workbench/contrib/markers/browser/messages'; -import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations'; -import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; -import { IMarkersWorkbenchService } from 'vs/workbench/contrib/markers/browser/markers'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; -import { localize } from 'vs/nls'; -import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { Iterator } from 'vs/base/common/iterator'; -import { ITreeElement, ITreeNode, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree'; -import { Relay, Event, Emitter } from 'vs/base/common/event'; -import { WorkbenchObjectTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService'; -import { FilterOptions } from 'vs/workbench/contrib/markers/browser/markersFilterOptions'; -import { IExpression } from 'vs/base/common/glob'; -import { deepClone } from 'vs/base/common/objects'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { FilterData, Filter, VirtualDelegate, ResourceMarkersRenderer, MarkerRenderer, RelatedInformationRenderer, TreeElement, MarkersTreeAccessibilityProvider, MarkersViewModel, ResourceDragAndDrop } from 'vs/workbench/contrib/markers/browser/markersTreeViewer'; -import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; -import { Separator, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; -import { IMenuService, MenuId } from 'vs/platform/actions/common/actions'; -import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; -import { KeyCode } from 'vs/base/common/keyCodes'; -import { domEvent } from 'vs/base/browser/event'; -import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle'; -import { ResourceLabels } from 'vs/workbench/browser/labels'; -import { IMarker } from 'vs/platform/markers/common/markers'; -import { withUndefinedAsNull } from 'vs/base/common/types'; -import { MementoObject } from 'vs/workbench/common/memento'; -import { Widget } from 'vs/base/browser/ui/widget'; -import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; - -function createModelIterator(model: MarkersModel): Iterator> { - const resourcesIt = Iterator.fromArray(model.resourceMarkers); - - return Iterator.map(resourcesIt, m => ({ element: m, children: createResourceMarkersIterator(m) })); -} - -function createResourceMarkersIterator(resourceMarkers: ResourceMarkers): Iterator> { - const markersIt = Iterator.fromArray(resourceMarkers.markers); - - return Iterator.map(markersIt, m => { - const relatedInformationIt = Iterator.from(m.relatedInformation); - const children = Iterator.map(relatedInformationIt, r => ({ element: r })); - - return { element: m, children }; - }); - -} - -class MarkersWidgetActions extends Disposable { - - readonly actions: IAction[]; - readonly collapseAllAction: IAction; - readonly filterAction: MarkersFilterAction; - - constructor( - tree: WorkbenchObjectTree, - panelState: MementoObject, - @IInstantiationService instantiationService: IInstantiationService - ) { - super(); - this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { - tree.collapseAll(); - tree.setSelection([]); - tree.setFocus([]); - tree.getHTMLElement().focus(); - tree.focusFirst(); - }); - - this.filterAction = instantiationService.createInstance(MarkersFilterAction, { filterText: panelState['filter'] || '', filterHistory: panelState['filterHistory'] || [], useFilesExclude: !!panelState['useFilesExclude'] }); - this.actions = [this.filterAction, this.collapseAllAction]; - } - -} - -class MarkersTreeWidget extends Disposable { - - private readonly treeContainer: HTMLElement; - private readonly tree: WorkbenchObjectTree; - - constructor( - parent: HTMLElement, - markersViewModel: MarkersViewModel, - @IInstantiationService private readonly instantiationService: IInstantiationService, - @IEditorService private readonly editorService: IEditorService, - @IConfigurationService private readonly configurationService: IConfigurationService, - @ITelemetryService private readonly telemetryService: ITelemetryService, - @IThemeService themeService: IThemeService, - @IMarkersWorkbenchService private readonly markersWorkbenchService: IMarkersWorkbenchService, - @IStorageService storageService: IStorageService, - @IContextKeyService contextKeyService: IContextKeyService, - @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, - @IContextMenuService private readonly contextMenuService: IContextMenuService, - @IMenuService private readonly menuService: IMenuService, - @IKeybindingService private readonly keybindingService: IKeybindingService, - ) { - super(); - - this.treeContainer = dom.append(parent, dom.$('.tree-container.show-file-icons')); - - const onDidChangeRenderNodeCount = new Relay>(); - - const virtualDelegate = new VirtualDelegate(markersViewModel); - const renderers = [ - this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), - this.instantiationService.createInstance(MarkerRenderer, markersViewModel), - this.instantiationService.createInstance(RelatedInformationRenderer) - ]; - this.filter = new Filter(new FilterOptions()); - const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); - - const identityProvider = { - getId(element: TreeElement) { - return element.id; - } - }; - - this.tree = this._register(this.instantiationService.createInstance(WorkbenchObjectTree, - 'MarkersPanel', - this.treeContainer, - virtualDelegate, - renderers, - { - filter: this.filter, - accessibilityProvider, - identityProvider, - dnd: new ResourceDragAndDrop(this.instantiationService), - expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0 - } - )); - - onDidChangeRenderNodeCount.input = this.tree.onDidChangeRenderNodeCount; - - const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService); - const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(this.tree.contextKeyService); - this._register(this.tree.onDidChangeFocus(focus => { - markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker)); - relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation)); - })); - const focusTracker = this._register(dom.trackFocus(this.tree.getHTMLElement())); - this._register(focusTracker.onDidBlur(() => { - markerFocusContextKey.set(false); - relatedInformationFocusContextKey.set(false); - })); - - const markersNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true })); - this._register(Event.debounce(markersNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => { - this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned); - })); - this._register(this.tree.onDidChangeCollapseState(({ node }) => { - const { element } = node; - if (element instanceof RelatedInformation && !node.collapsed) { - /* __GDPR__ - "problems.expandRelatedInformation" : { - "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, - "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } - } - */ - this.telemetryService.publicLog('problems.expandRelatedInformation', this.getTelemetryData(element.marker)); - } - })); - - this._register(this.tree.onContextMenu(this.onContextMenu, this)); - - this._register(this.configurationService.onDidChangeConfiguration(e => { - if (this.filterAction.useFilesExclude && e.affectsConfiguration('files.exclude')) { - this.updateFilter(); - } - })); - - // move focus to input, whenever a key is pressed in the panel container - this._register(domEvent(parent, 'keydown')(e => { - if (this.filterInputActionViewItem && this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) { - this.filterInputActionViewItem.focus(); - } - })); - - this._register(Event.any(this.tree.onDidChangeSelection, this.tree.onDidChangeFocus)(() => { - const elements = [...this.tree.getSelection(), ...this.tree.getFocus()]; - for (const element of elements) { - if (element instanceof Marker) { - const viewModel = markersViewModel.getViewModel(element); - if (viewModel) { - viewModel.showLightBulb(); - } - } - } - })); - - this._register(this.tree.onDidChangeSelection(() => { - let selection = this.tree.getSelection(); - if (selection && selection.length > 0) { - this.lastSelectedRelativeTop = this.tree.getRelativeTop(selection[0]) || 0; - } - })); - } - - public layout(dimension: dom.Dimension): void { - this.treeContainer.style.height = `${dimension.height}px`; - this.tree.layout(dimension.height, dimension.width); - } - - public isFoucsed(): boolean { - return this.tree.getHTMLElement() === document.activeElement; - } - - public focus(): void { - this.tree.getHTMLElement().focus(); - } - - refreshTree(markerOrChange?: Marker | MarkerChangesEvent): void { - if (markerOrChange) { - if (markerOrChange instanceof Marker) { - this.tree.rerender(markerOrChange); - } else { - if (markerOrChange.added.length || markerOrChange.removed.length) { - // Reset complete tree - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - } else { - // Update resource - for (const updated of markerOrChange.updated) { - this.tree.setChildren(updated, createResourceMarkersIterator(updated)); - } - } - } - } else { - // Reset complete tree - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - } - } - - toggleVisibility(show: boolean): void { - dom.toggleClass(this.treeContainer, 'hidden', !show); - } - - refilter(): void { - this.tree.refilter(); - } - - private isEmpty(): boolean { - const { total, filtered } = this.getFilterStats(); - return total === 0 || filtered === 0; - } - - private render(): void { - this.cachedFilterStats = undefined; - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - dom.toggleClass(this.treeContainer, 'hidden', this.isEmpty()); - this.renderMessage(); - } - - private revealMarkersForCurrentActiveEditor(focus: boolean = false): void { - let currentActiveResource = this.getResourceForCurrentActiveResource(); - if (currentActiveResource) { - if (!this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) { - this.tree.reveal(this.tree.getSelection()[0], this.lastSelectedRelativeTop); - if (focus) { - this.tree.setFocus(this.tree.getSelection()); - } - } else { - this.tree.expand(currentActiveResource); - this.tree.reveal(currentActiveResource, 0); - - if (focus) { - this.tree.setFocus([currentActiveResource]); - this.tree.setSelection([currentActiveResource]); - } - } - } else if (focus) { - this.tree.setSelection([]); - this.tree.focusFirst(); - } - } - - private hasSelectedMarkerFor(resource: ResourceMarkers): boolean { - let selectedElement = this.tree.getSelection(); - if (selectedElement && selectedElement.length > 0) { - if (selectedElement[0] instanceof Marker) { - if (resource.resource.toString() === (selectedElement[0]).marker.resource.toString()) { - return true; - } - } - } - return false; - } - - private highlightCurrentSelectedMarkerRange() { - const selections = this.tree.getSelection(); - - if (selections.length !== 1) { - return; - } - - const selection = selections[0]; - - if (!(selection instanceof Marker)) { - return; - } - - this.rangeHighlightDecorations.highlightRange(selection); - } - - private onContextMenu(e: ITreeContextMenuEvent): void { - const element = e.element; - if (!element) { - return; - } - - e.browserEvent.preventDefault(); - e.browserEvent.stopPropagation(); - - this.contextMenuService.showContextMenu({ - getAnchor: () => e.anchor!, - getActions: () => this.getMenuActions(element), - getActionViewItem: (action) => { - const keybinding = this.keybindingService.lookupKeybinding(action.id); - if (keybinding) { - return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() }); - } - return undefined; - }, - onHide: (wasCancelled?: boolean) => { - if (wasCancelled) { - this.tree.domFocus(); - } - } - }); - } - - private getMenuActions(element: TreeElement): IAction[] { - const result: IAction[] = []; - - if (element instanceof Marker) { - const viewModel = this.markersViewModel.getViewModel(element); - if (viewModel) { - const quickFixActions = viewModel.quickFixAction.quickFixes; - if (quickFixActions.length) { - result.push(...quickFixActions); - result.push(new Separator()); - } - } - } - - const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree.contextKeyService); - const groups = menu.getActions(); - menu.dispose(); - - for (let group of groups) { - const [, actions] = group; - result.push(...actions); - result.push(new Separator()); - } - - result.pop(); // remove last separator - return result; - } - - public getFocusElement() { - return this.tree.getFocus()[0]; - } - - public dispose(): void { - super.dispose(); - this.tree.dispose(); - this.markersViewModel.dispose(); - this.disposables = dispose(this.disposables); - } -} - - -export class MarkersWidget extends Widget { - - private lastSelectedRelativeTop: number = 0; - private currentActiveResource: URI | null = null; - - private readonly tree: WorkbenchObjectTree; - private readonly treeLabels: ResourceLabels; - private readonly rangeHighlightDecorations: RangeHighlightDecorations; - - private treeContainer: HTMLElement; - private messageBoxContainer: HTMLElement; - private ariaLabelElement: HTMLElement; - private readonly panelState: MementoObject; - private panelFoucusContextKey: IContextKey; - - private filter: Filter; - private filterInputActionViewItem: MarkersFilterActionViewItem | null = null; - - private _onDidFilter = this._register(new Emitter()); - readonly onDidFilter: Event = this._onDidFilter.event; - private cachedFilterStats: { total: number; filtered: number; } | undefined = undefined; - - private currentResourceGotAddedToMarkersData: boolean = false; - readonly markersViewModel: MarkersViewModel; - private disposables: IDisposable[] = []; - - constructor( - parent: HTMLElement, - @IInstantiationService private readonly instantiationService: IInstantiationService, - @IEditorService private readonly editorService: IEditorService, - @IConfigurationService private readonly configurationService: IConfigurationService, - @ITelemetryService private readonly telemetryService: ITelemetryService, - @IThemeService themeService: IThemeService, - @IMarkersWorkbenchService private readonly markersWorkbenchService: IMarkersWorkbenchService, - @IStorageService storageService: IStorageService, - @IContextKeyService contextKeyService: IContextKeyService, - @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, - @IContextMenuService private readonly contextMenuService: IContextMenuService, - @IMenuService private readonly menuService: IMenuService, - @IKeybindingService private readonly keybindingService: IKeybindingService, - ) { - super(); - - this.panelFoucusContextKey = Constants.MarkerPanelFocusContextKey.bindTo(contextKeyService); - this.panelState = this.getMemento(StorageScope.WORKSPACE); - this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']); - this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables); - this.setCurrentActiveEditor(); - - this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations)); - this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); - - this.createArialLabelElement(parent); - this.createMessageBox(parent); - this.tree = this.createTree(parent); - this.actions = this.createActions(); - this.createListeners(); - - this.updateFilter(); - - this._register(this.onDidFocus(() => this.panelFoucusContextKey.set(true))); - this._register(this.onDidBlur(() => this.panelFoucusContextKey.set(false))); - - this._register(this.onDidChangeVisibility(visible => { - if (visible) { - this.refreshPanel(); - } else { - this.rangeHighlightDecorations.removeHighlightRange(); - } - })); - - this.render(); - } - - public layout(dimension: dom.Dimension): void { - this.treeContainer.style.height = `${dimension.height}px`; - this.tree.layout(dimension.height, dimension.width); - if (this.filterInputActionViewItem) { - this.filterInputActionViewItem.toggleLayout(dimension.width < 1200); - } - } - - public focus(): void { - if (this.tree.getHTMLElement() === document.activeElement) { - return; - } - - if (this.isEmpty()) { - this.messageBoxContainer.focus(); - } else { - this.tree.getHTMLElement().focus(); - } - } - - public focusFilter(): void { - if (this.filterInputActionViewItem) { - this.filterInputActionViewItem.focus(); - } - } - - public getActions(): IAction[] { - return this.actions; - } - - public showQuickFixes(marker: Marker): void { - const viewModel = this.markersViewModel.getViewModel(marker); - if (viewModel) { - viewModel.quickFixAction.run(); - } - } - - public openFileAtElement(element: any, preserveFocus: boolean, sideByside: boolean, pinned: boolean): boolean { - const { resource, selection, event, data } = element instanceof Marker ? { resource: element.resource, selection: element.range, event: 'problems.selectDiagnostic', data: this.getTelemetryData(element.marker) } : - element instanceof RelatedInformation ? { resource: element.raw.resource, selection: element.raw, event: 'problems.selectRelatedInformation', data: this.getTelemetryData(element.marker) } : { resource: null, selection: null, event: null, data: null }; - if (resource && selection && event) { - /* __GDPR__ - "problems.selectDiagnostic" : { - "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, - "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } - } - */ - /* __GDPR__ - "problems.selectRelatedInformation" : { - "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, - "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } - } - */ - this.telemetryService.publicLog(event, data); - this.editorService.openEditor({ - resource, - options: { - selection, - preserveFocus, - pinned, - revealIfVisible: true - }, - }, sideByside ? SIDE_GROUP : ACTIVE_GROUP).then(editor => { - if (editor && preserveFocus) { - this.rangeHighlightDecorations.highlightRange({ resource, range: selection }, editor.getControl()); - } else { - this.rangeHighlightDecorations.removeHighlightRange(); - } - }); - return true; - } else { - this.rangeHighlightDecorations.removeHighlightRange(); - } - return false; - } - - private refreshPanel(markerOrChange?: Marker | MarkerChangesEvent): void { - if (this.isVisible()) { - this.cachedFilterStats = undefined; - - if (markerOrChange) { - if (markerOrChange instanceof Marker) { - this.tree.rerender(markerOrChange); - } else { - if (markerOrChange.added.length || markerOrChange.removed.length) { - // Reset complete tree - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - } else { - // Update resource - for (const updated of markerOrChange.updated) { - this.tree.setChildren(updated, createResourceMarkersIterator(updated)); - } - } - } - } else { - // Reset complete tree - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - } - - const { total, filtered } = this.getFilterStats(); - dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); - this.renderMessage(); - this._onDidFilter.fire(); - } - } - - private onDidChangeViewState(marker?: Marker): void { - this.refreshPanel(marker); - } - - private updateFilter() { - this.cachedFilterStats = undefined; - this.filter.options = new FilterOptions(this.filterAction.filterText, this.getFilesExcludeExpressions()); - this.tree.refilter(); - this._onDidFilter.fire(); - - const { total, filtered } = this.getFilterStats(); - dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); - this.renderMessage(); - } - - private getFilesExcludeExpressions(): { root: URI, expression: IExpression }[] | IExpression { - if (!this.filterAction.useFilesExclude) { - return []; - } - - const workspaceFolders = this.workspaceContextService.getWorkspace().folders; - return workspaceFolders.length - ? workspaceFolders.map(workspaceFolder => ({ root: workspaceFolder.uri, expression: this.getFilesExclude(workspaceFolder.uri) })) - : this.getFilesExclude(); - } - - private getFilesExclude(resource?: URI): IExpression { - return deepClone(this.configurationService.getValue('files.exclude', { resource })) || {}; - } - - private createMessageBox(parent: HTMLElement): void { - this.messageBoxContainer = dom.append(parent, dom.$('.message-box-container')); - this.messageBoxContainer.setAttribute('aria-labelledby', 'markers-panel-arialabel'); - } - - private createArialLabelElement(parent: HTMLElement): void { - this.ariaLabelElement = dom.append(parent, dom.$('')); - this.ariaLabelElement.setAttribute('id', 'markers-panel-arialabel'); - this.ariaLabelElement.setAttribute('aria-live', 'polite'); - } - - private createTree(parent: HTMLElement): WorkbenchObjectTree { - this.treeContainer = dom.append(parent, dom.$('.tree-container.show-file-icons')); - - const onDidChangeRenderNodeCount = new Relay>(); - - const virtualDelegate = new VirtualDelegate(this.markersViewModel); - const renderers = [ - this.instantiationService.createInstance(ResourceMarkersRenderer, this.treeLabels, onDidChangeRenderNodeCount.event), - this.instantiationService.createInstance(MarkerRenderer, this.markersViewModel), - this.instantiationService.createInstance(RelatedInformationRenderer) - ]; - this.filter = new Filter(new FilterOptions()); - const accessibilityProvider = this.instantiationService.createInstance(MarkersTreeAccessibilityProvider); - - const identityProvider = { - getId(element: TreeElement) { - return element.id; - } - }; - - const tree = this.instantiationService.createInstance(WorkbenchObjectTree, - 'MarkersPanel', - this.treeContainer, - virtualDelegate, - renderers, - { - filter: this.filter, - accessibilityProvider, - identityProvider, - dnd: new ResourceDragAndDrop(this.instantiationService), - expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0 - } - ); - - onDidChangeRenderNodeCount.input = tree.onDidChangeRenderNodeCount; - - const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(tree.contextKeyService); - const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(tree.contextKeyService); - this._register(tree.onDidChangeFocus(focus => { - markerFocusContextKey.set(focus.elements.some(e => e instanceof Marker)); - relatedInformationFocusContextKey.set(focus.elements.some(e => e instanceof RelatedInformation)); - })); - const focusTracker = this._register(dom.trackFocus(tree.getHTMLElement())); - this._register(focusTracker.onDidBlur(() => { - markerFocusContextKey.set(false); - relatedInformationFocusContextKey.set(false); - })); - - const markersNavigator = this._register(new TreeResourceNavigator2(tree, { openOnFocus: true })); - this._register(Event.debounce(markersNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => { - this.openFileAtElement(options.element, !!options.editorOptions.preserveFocus, options.sideBySide, !!options.editorOptions.pinned); - })); - this._register(tree.onDidChangeCollapseState(({ node }) => { - const { element } = node; - if (element instanceof RelatedInformation && !node.collapsed) { - /* __GDPR__ - "problems.expandRelatedInformation" : { - "source": { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" }, - "code" : { "classification": "PublicNonPersonalData", "purpose": "FeatureInsight" } - } - */ - this.telemetryService.publicLog('problems.expandRelatedInformation', this.getTelemetryData(element.marker)); - } - })); - - this._register(tree.onContextMenu(this.onContextMenu, this)); - - this._register(this.configurationService.onDidChangeConfiguration(e => { - if (this.filterAction.useFilesExclude && e.affectsConfiguration('files.exclude')) { - this.updateFilter(); - } - })); - - // move focus to input, whenever a key is pressed in the panel container - this._register(domEvent(parent, 'keydown')(e => { - if (this.filterInputActionViewItem && this.keybindingService.mightProducePrintableCharacter(new StandardKeyboardEvent(e))) { - this.filterInputActionViewItem.focus(); - } - })); - - this._register(Event.any(tree.onDidChangeSelection, tree.onDidChangeFocus)(() => { - const elements = [...tree.getSelection(), ...tree.getFocus()]; - for (const element of elements) { - if (element instanceof Marker) { - const viewModel = this.markersViewModel.getViewModel(element); - if (viewModel) { - viewModel.showLightBulb(); - } - } - } - })); - - return tree; - } - - private createActions(): IAction[] { - this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => { - this.tree.collapseAll(); - this.tree.setSelection([]); - this.tree.setFocus([]); - this.tree.getHTMLElement().focus(); - this.tree.focusFirst(); - }); - - this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] }); - return [this.filterAction, this.collapseAllAction]; - } - - private createListeners(): void { - this._register(Event.any(this.markersWorkbenchService.markersModel.onDidChange, this.editorService.onDidActiveEditorChange)(changes => { - if (changes) { - this.onDidChangeModel(changes); - } else { - this.onActiveEditorChanged(); - } - })); - this._register(this.tree.onDidChangeSelection(() => this.onSelected())); - this._register(this.filterAction.onDidChange((event: IMarkersFilterActionChangeEvent) => { - if (event.filterText || event.useFilesExclude) { - this.updateFilter(); - } - })); - this.actions.forEach(a => this._register(a)); - } - - private onDidChangeModel(change: MarkerChangesEvent) { - const resourceMarkers = [...change.added, ...change.removed, ...change.updated]; - const resources: URI[] = []; - for (const { resource } of resourceMarkers) { - this.markersViewModel.remove(resource); - const resourceMarkers = this.markersWorkbenchService.markersModel.getResourceMarkers(resource); - if (resourceMarkers) { - for (const marker of resourceMarkers.markers) { - this.markersViewModel.add(marker); - } - } - resources.push(resource); - } - this.currentResourceGotAddedToMarkersData = this.currentResourceGotAddedToMarkersData || this.isCurrentResourceGotAddedToMarkersData(resources); - this.refreshPanel(change); - this.updateRangeHighlights(); - if (this.currentResourceGotAddedToMarkersData) { - this.autoReveal(); - this.currentResourceGotAddedToMarkersData = false; - } - } - - private isCurrentResourceGotAddedToMarkersData(changedResources: URI[]) { - const currentlyActiveResource = this.currentActiveResource; - if (!currentlyActiveResource) { - return false; - } - const resourceForCurrentActiveResource = this.getResourceForCurrentActiveResource(); - if (resourceForCurrentActiveResource) { - return false; - } - return changedResources.some(r => r.toString() === currentlyActiveResource.toString()); - } - - private onActiveEditorChanged(): void { - this.setCurrentActiveEditor(); - this.autoReveal(); - } - - private setCurrentActiveEditor(): void { - const activeEditor = this.editorService.activeEditor; - this.currentActiveResource = activeEditor ? withUndefinedAsNull(activeEditor.getResource()) : null; - } - - private onSelected(): void { - let selection = this.tree.getSelection(); - if (selection && selection.length > 0) { - this.lastSelectedRelativeTop = this.tree.getRelativeTop(selection[0]) || 0; - } - } - - private isEmpty(): boolean { - const { total, filtered } = this.getFilterStats(); - return total === 0 || filtered === 0; - } - - private render(): void { - this.cachedFilterStats = undefined; - this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - dom.toggleClass(this.treeContainer, 'hidden', this.isEmpty()); - this.renderMessage(); - } - - private renderMessage(): void { - dom.clearNode(this.messageBoxContainer); - const { total, filtered } = this.getFilterStats(); - - if (filtered === 0) { - this.messageBoxContainer.style.display = 'block'; - this.messageBoxContainer.setAttribute('tabIndex', '0'); - if (total > 0) { - if (this.filter.options.filter) { - this.renderFilteredByFilterMessage(this.messageBoxContainer); - } else { - this.renderFilteredByFilesExcludeMessage(this.messageBoxContainer); - } - } else { - this.renderNoProblemsMessage(this.messageBoxContainer); - } - } else { - this.messageBoxContainer.style.display = 'none'; - if (filtered === total) { - this.ariaLabelElement.setAttribute('aria-label', localize('No problems filtered', "Showing {0} problems", total)); - } else { - this.ariaLabelElement.setAttribute('aria-label', localize('problems filtered', "Showing {0} of {1} problems", filtered, total)); - } - this.messageBoxContainer.removeAttribute('tabIndex'); - } - } - - private renderFilteredByFilesExcludeMessage(container: HTMLElement) { - const span1 = dom.append(container, dom.$('span')); - span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILE_EXCLUSIONS_FILTER; - const link = dom.append(container, dom.$('a.messageAction')); - link.textContent = localize('disableFilesExclude', "Disable Files Exclude Filter."); - link.setAttribute('tabIndex', '0'); - dom.addStandardDisposableListener(link, dom.EventType.CLICK, () => this.filterAction.useFilesExclude = false); - dom.addStandardDisposableListener(link, dom.EventType.KEY_DOWN, (e: IKeyboardEvent) => { - if (e.equals(KeyCode.Enter) || e.equals(KeyCode.Space)) { - this.filterAction.useFilesExclude = false; - e.stopPropagation(); - } - }); - this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_FILE_EXCLUSIONS_FILTER); - } - - private renderFilteredByFilterMessage(container: HTMLElement) { - const span1 = dom.append(container, dom.$('span')); - span1.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS; - const link = dom.append(container, dom.$('a.messageAction')); - link.textContent = localize('clearFilter', "Clear Filter"); - link.setAttribute('tabIndex', '0'); - const span2 = dom.append(container, dom.$('span')); - span2.textContent = '.'; - dom.addStandardDisposableListener(link, dom.EventType.CLICK, () => this.filterAction.filterText = ''); - dom.addStandardDisposableListener(link, dom.EventType.KEY_DOWN, (e: IKeyboardEvent) => { - if (e.equals(KeyCode.Enter) || e.equals(KeyCode.Space)) { - this.filterAction.filterText = ''; - e.stopPropagation(); - } - }); - this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_FILTERS); - } - - private renderNoProblemsMessage(container: HTMLElement) { - const span = dom.append(container, dom.$('span')); - span.textContent = Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT; - this.ariaLabelElement.setAttribute('aria-label', Messages.MARKERS_PANEL_NO_PROBLEMS_BUILT); - } - - private autoReveal(focus: boolean = false): void { - let autoReveal = this.configurationService.getValue('problems.autoReveal'); - if (typeof autoReveal === 'boolean' && autoReveal) { - this.revealMarkersForCurrentActiveEditor(focus); - } - } - - private revealMarkersForCurrentActiveEditor(focus: boolean = false): void { - let currentActiveResource = this.getResourceForCurrentActiveResource(); - if (currentActiveResource) { - if (!this.tree.isCollapsed(currentActiveResource) && this.hasSelectedMarkerFor(currentActiveResource)) { - this.tree.reveal(this.tree.getSelection()[0], this.lastSelectedRelativeTop); - if (focus) { - this.tree.setFocus(this.tree.getSelection()); - } - } else { - this.tree.expand(currentActiveResource); - this.tree.reveal(currentActiveResource, 0); - - if (focus) { - this.tree.setFocus([currentActiveResource]); - this.tree.setSelection([currentActiveResource]); - } - } - } else if (focus) { - this.tree.setSelection([]); - this.tree.focusFirst(); - } - } - - private getResourceForCurrentActiveResource(): ResourceMarkers | null { - return this.currentActiveResource ? this.markersWorkbenchService.markersModel.getResourceMarkers(this.currentActiveResource) : null; - } - - private hasSelectedMarkerFor(resource: ResourceMarkers): boolean { - let selectedElement = this.tree.getSelection(); - if (selectedElement && selectedElement.length > 0) { - if (selectedElement[0] instanceof Marker) { - if (resource.resource.toString() === (selectedElement[0]).marker.resource.toString()) { - return true; - } - } - } - return false; - } - - private updateRangeHighlights() { - this.rangeHighlightDecorations.removeHighlightRange(); - if (this.tree.getHTMLElement() === document.activeElement) { - this.highlightCurrentSelectedMarkerRange(); - } - } - - private highlightCurrentSelectedMarkerRange() { - const selections = this.tree.getSelection(); - - if (selections.length !== 1) { - return; - } - - const selection = selections[0]; - - if (!(selection instanceof Marker)) { - return; - } - - this.rangeHighlightDecorations.highlightRange(selection); - } - - private onContextMenu(e: ITreeContextMenuEvent): void { - const element = e.element; - if (!element) { - return; - } - - e.browserEvent.preventDefault(); - e.browserEvent.stopPropagation(); - - this.contextMenuService.showContextMenu({ - getAnchor: () => e.anchor!, - getActions: () => this.getMenuActions(element), - getActionViewItem: (action) => { - const keybinding = this.keybindingService.lookupKeybinding(action.id); - if (keybinding) { - return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() }); - } - return undefined; - }, - onHide: (wasCancelled?: boolean) => { - if (wasCancelled) { - this.tree.domFocus(); - } - } - }); - } - - private getMenuActions(element: TreeElement): IAction[] { - const result: IAction[] = []; - - if (element instanceof Marker) { - const viewModel = this.markersViewModel.getViewModel(element); - if (viewModel) { - const quickFixActions = viewModel.quickFixAction.quickFixes; - if (quickFixActions.length) { - result.push(...quickFixActions); - result.push(new Separator()); - } - } - } - - const menu = this.menuService.createMenu(MenuId.ProblemsPanelContext, this.tree.contextKeyService); - const groups = menu.getActions(); - menu.dispose(); - - for (let group of groups) { - const [, actions] = group; - result.push(...actions); - result.push(new Separator()); - } - - result.pop(); // remove last separator - return result; - } - - public getFocusElement() { - return this.tree.getFocus()[0]; - } - - public getActionViewItem(action: IAction): IActionViewItem | undefined { - if (action.id === MarkersFilterAction.ID) { - this.filterInputActionViewItem = this.instantiationService.createInstance(MarkersFilterActionViewItem, this.filterAction, this); - return this.filterInputActionViewItem; - } - return super.getActionViewItem(action); - } - - getFilterOptions(): FilterOptions { - return this.filter.options; - } - - getFilterStats(): { total: number; filtered: number; } { - if (!this.cachedFilterStats) { - this.cachedFilterStats = this.computeFilterStats(); - } - - return this.cachedFilterStats; - } - - private computeFilterStats(): { total: number; filtered: number; } { - const root = this.tree.getNode(); - let total = 0; - let filtered = 0; - - for (const resourceMarkerNode of root.children) { - for (const markerNode of resourceMarkerNode.children) { - total++; - - if (resourceMarkerNode.visible && markerNode.visible) { - filtered++; - } - } - } - - return { total, filtered }; - } - - private getTelemetryData({ source, code }: IMarker): any { - return { source, code }; - } - - protected saveState(): void { - this.panelState['filter'] = this.filterAction.filterText; - this.panelState['filterHistory'] = this.filterAction.filterHistory; - this.panelState['useFilesExclude'] = this.filterAction.useFilesExclude; - this.panelState['multiline'] = this.markersViewModel.multiline; - - super.saveState(); - } - - public dispose(): void { - super.dispose(); - this.tree.dispose(); - this.markersViewModel.dispose(); - this.disposables = dispose(this.disposables); - } -} From e08ba900222c53c39840e95d9123cf486bd37af6 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 16:30:05 -0700 Subject: [PATCH 076/204] :lipstick: --- src/vs/workbench/contrib/search/test/common/searchModel.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts index dc9e8347bfd71..38d90f655d00d 100644 --- a/src/vs/workbench/contrib/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/contrib/search/test/common/searchModel.test.ts @@ -158,7 +158,6 @@ suite('SearchModel', () => { const testObject: SearchModel = instantiationService.createInstance(SearchModel); await testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries }); - // await timeout(0); // TODO@rob https://github.com/microsoft/vscode/issues/80251 assert.ok(target.calledThrice); const data = target.args[0]; From a92857ee4ed8e780f6f842f0b67bf6dfb9384a63 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 5 Sep 2019 01:35:27 +0200 Subject: [PATCH 077/204] clean up dispose --- .../contrib/markers/browser/markersPanel.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/contrib/markers/browser/markersPanel.ts b/src/vs/workbench/contrib/markers/browser/markersPanel.ts index 0399a75b19854..a7a4f2ba43243 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanel.ts @@ -40,7 +40,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { KeyCode } from 'vs/base/common/keyCodes'; import { domEvent } from 'vs/base/browser/event'; -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { ResourceLabels } from 'vs/workbench/browser/labels'; import { IMarker } from 'vs/platform/markers/common/markers'; import { withUndefinedAsNull } from 'vs/base/common/types'; @@ -90,7 +89,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { private currentResourceGotAddedToMarkersData: boolean = false; readonly markersViewModel: MarkersViewModel; - private disposables: IDisposable[] = []; constructor( @IInstantiationService private readonly instantiationService: IInstantiationService, @@ -109,16 +107,16 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { super(Constants.MARKERS_PANEL_ID, telemetryService, themeService, storageService); this.panelFoucusContextKey = Constants.MarkerPanelFocusContextKey.bindTo(contextKeyService); this.panelState = this.getMemento(StorageScope.WORKSPACE); - this.markersViewModel = instantiationService.createInstance(MarkersViewModel, this.panelState['multiline']); - this.markersViewModel.onDidChange(this.onDidChangeViewState, this, this.disposables); + this.markersViewModel = this._register(instantiationService.createInstance(MarkersViewModel, this.panelState['multiline'])); + this._register(this.markersViewModel.onDidChange(marker => this.onDidChangeViewState(marker))); this.setCurrentActiveEditor(); this.filter = new Filter(new FilterOptions()); this.rangeHighlightDecorations = this._register(this.instantiationService.createInstance(RangeHighlightDecorations)); // actions - this.collapseAllAction = new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => this.collapseAll()); - this.filterAction = this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] }); + this.collapseAllAction = this._register(new Action('vs.tree.collapse', localize('collapseAll', "Collapse All"), 'monaco-tree-action collapse-all', true, async () => this.collapseAll())); + this.filterAction = this._register(this.instantiationService.createInstance(MarkersFilterAction, { filterText: this.panelState['filter'] || '', filterHistory: this.panelState['filterHistory'] || [], useFilesExclude: !!this.panelState['useFilesExclude'] })); } public create(parent: HTMLElement): void { @@ -322,7 +320,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } }; - this.tree = this.instantiationService.createInstance(WorkbenchObjectTree, + this.tree = this._register(this.instantiationService.createInstance(WorkbenchObjectTree, 'MarkersPanel', this.treeContainer, virtualDelegate, @@ -334,7 +332,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { dnd: new ResourceDragAndDrop(this.instantiationService), expandOnlyOnTwistieClick: (e: TreeElement) => e instanceof Marker && e.relatedInformation.length > 0 } - ); + )); onDidChangeRenderNodeCount.input = this.tree.onDidChangeRenderNodeCount; @@ -728,10 +726,4 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { super.saveState(); } - public dispose(): void { - super.dispose(); - this.tree.dispose(); - this.markersViewModel.dispose(); - this.disposables = dispose(this.disposables); - } } From d25a7dd5a25e4b6f685b09899827c35d3ed56586 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 16:59:01 -0700 Subject: [PATCH 078/204] Better fix for #80251 --- .../contrib/search/common/searchModel.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/search/common/searchModel.ts b/src/vs/workbench/contrib/search/common/searchModel.ts index 4712e2c19e3c3..4596fe3173a60 100644 --- a/src/vs/workbench/contrib/search/common/searchModel.ts +++ b/src/vs/workbench/contrib/search/common/searchModel.ts @@ -987,17 +987,17 @@ export class SearchModel extends Disposable { value => this.onSearchCompleted(value, Date.now() - start), e => this.onSearchError(e, Date.now() - start)); - return currentRequest; + return currentRequest.finally(() => { + /* __GDPR__ + "searchResultsFinished" : { + "duration" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true } + } + */ + this.telemetryService.publicLog('searchResultsFinished', { duration: Date.now() - start }); + }); } private onSearchCompleted(completed: ISearchComplete | null, duration: number): ISearchComplete | null { - /* __GDPR__ - "searchResultsFinished" : { - "duration" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true } - } - */ - this.telemetryService.publicLog('searchResultsFinished', { duration }); - if (!this._searchQuery) { throw new Error('onSearchCompleted must be called after a search is started'); } From 7edc8f786e065edbc9540f1e19ebd9220b9e0cf9 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 4 Sep 2019 17:28:59 -0700 Subject: [PATCH 079/204] Fix #80304 - wait for remote window to actually connect before running tests --- test/smoke/src/application.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/smoke/src/application.ts b/test/smoke/src/application.ts index f7510ca502c01..315bd951f7aef 100644 --- a/test/smoke/src/application.ts +++ b/test/smoke/src/application.ts @@ -142,7 +142,7 @@ export class Application { await this.code.waitForElement('.monaco-workbench'); if (this.remote) { - await this.code.waitForElement('.monaco-workbench .statusbar-item[id="status.host"]'); + await this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="status.host"]', ' TestResolver'); } // wait a bit, since focus might be stolen off widgets From f2ccbad2de2a3c7adff7d708d8fd82181d080d0b Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 09:59:47 +0200 Subject: [PATCH 080/204] fixes #80362 --- src/vs/editor/contrib/referenceSearch/referencesWidget.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/referenceSearch/referencesWidget.ts b/src/vs/editor/contrib/referenceSearch/referencesWidget.ts index cc6b12bca846f..26eca18fb1116 100644 --- a/src/vs/editor/contrib/referenceSearch/referencesWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/referencesWidget.ts @@ -383,8 +383,11 @@ export class ReferenceWidget extends PeekViewWidget { }); this._tree.onDidOpen(e => { const aside = (e.browserEvent instanceof MouseEvent) && (e.browserEvent.ctrlKey || e.browserEvent.metaKey || e.browserEvent.altKey); - const goto = !e.browserEvent || ((e.browserEvent instanceof MouseEvent) && e.browserEvent.detail === 2); - + let goto = !e.browserEvent || ((e.browserEvent instanceof MouseEvent) && e.browserEvent.detail === 2); + if (e.browserEvent instanceof KeyboardEvent) { + // todo@joh make this a command + goto = true; + } if (aside) { onEvent(e.elements[0], 'side'); } else if (goto) { From e85f2a3b8d0c12d092e44a674487124a7b19b6a8 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 5 Sep 2019 10:02:15 +0200 Subject: [PATCH 081/204] :lipstick: --- .../contrib/markers/browser/markersPanel.ts | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/markers/browser/markersPanel.ts b/src/vs/workbench/contrib/markers/browser/markersPanel.ts index a7a4f2ba43243..bbc4392c7f74a 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanel.ts @@ -25,9 +25,9 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { localize } from 'vs/nls'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { Iterator } from 'vs/base/common/iterator'; -import { ITreeElement, ITreeNode, ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree'; +import { ITreeElement, ITreeNode, ITreeContextMenuEvent, ITreeRenderer } from 'vs/base/browser/ui/tree/tree'; import { Relay, Event, Emitter } from 'vs/base/common/event'; -import { WorkbenchObjectTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService'; +import { WorkbenchObjectTree, TreeResourceNavigator2, IListService } from 'vs/platform/list/browser/listService'; import { FilterOptions } from 'vs/workbench/contrib/markers/browser/markersFilterOptions'; import { IExpression } from 'vs/base/common/glob'; import { deepClone } from 'vs/base/common/objects'; @@ -44,6 +44,9 @@ import { ResourceLabels } from 'vs/workbench/browser/labels'; import { IMarker } from 'vs/platform/markers/common/markers'; import { withUndefinedAsNull } from 'vs/base/common/types'; import { MementoObject } from 'vs/workbench/common/memento'; +import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; +import { IObjectTreeOptions } from 'vs/base/browser/ui/tree/objectTree'; +import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; function createModelIterator(model: MarkersModel): Iterator> { const resourcesIt = Iterator.fromArray(model.resourceMarkers); @@ -71,8 +74,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { private readonly rangeHighlightDecorations: RangeHighlightDecorations; private readonly filter: Filter; - private tree!: WorkbenchObjectTree; - private treeContainer!: HTMLElement; + private tree!: MarkersTree; private messageBoxContainer!: HTMLElement; private ariaLabelElement!: HTMLElement; @@ -153,7 +155,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } public layout(dimension: dom.Dimension): void { - this.treeContainer.style.height = `${dimension.height}px`; this.tree.layout(dimension.height, dimension.width); if (this.filterInputActionViewItem) { this.filterInputActionViewItem.toggleLayout(dimension.width < 1200); @@ -252,7 +253,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } const { total, filtered } = this.getFilterStats(); - dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); + this.tree.toggleVisibility(total === 0 || filtered === 0); this.renderMessage(); this._onDidFilter.fire(); } @@ -269,7 +270,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { this._onDidFilter.fire(); const { total, filtered } = this.getFilterStats(); - dom.toggleClass(this.treeContainer, 'hidden', total === 0 || filtered === 0); + this.tree.toggleVisibility(total === 0 || filtered === 0); this.renderMessage(); } @@ -300,8 +301,6 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } private createTree(parent: HTMLElement): void { - this.treeContainer = dom.append(parent, dom.$('.tree-container.show-file-icons')); - const onDidChangeRenderNodeCount = new Relay>(); const treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); @@ -320,9 +319,9 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } }; - this.tree = this._register(this.instantiationService.createInstance(WorkbenchObjectTree, + this.tree = this._register(this.instantiationService.createInstance(MarkersTree, 'MarkersPanel', - this.treeContainer, + dom.append(parent, dom.$('.tree-container.show-file-icons')), virtualDelegate, renderers, { @@ -476,7 +475,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { private render(): void { this.cachedFilterStats = undefined; this.tree.setChildren(null, createModelIterator(this.markersWorkbenchService.markersModel)); - dom.toggleClass(this.treeContainer, 'hidden', this.isEmpty()); + this.tree.toggleVisibility(this.isEmpty()); this.renderMessage(); } @@ -727,3 +726,32 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { } } + +class MarkersTree extends WorkbenchObjectTree { + + constructor( + user: string, + readonly container: HTMLElement, + delegate: IListVirtualDelegate, + renderers: ITreeRenderer[], + options: IObjectTreeOptions, + @IContextKeyService contextKeyService: IContextKeyService, + @IListService listService: IListService, + @IThemeService themeService: IThemeService, + @IConfigurationService configurationService: IConfigurationService, + @IKeybindingService keybindingService: IKeybindingService, + @IAccessibilityService accessibilityService: IAccessibilityService + ) { + super(user, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService); + } + + layout(height: number, width: number): void { + this.container.style.height = `${height}px`; + super.layout(height, width); + } + + toggleVisibility(hide: boolean): void { + dom.toggleClass(this.container, 'hidden', hide); + } + +} From bfa3db2f07286a3d45a80befb037c632bc8d5fda Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 10:46:54 +0200 Subject: [PATCH 082/204] Allow one-off global tasks if they have a cwd Fixes #78817 --- .../tasks/browser/terminalTaskSystem.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 354af73184045..e268caeeab693 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -60,7 +60,7 @@ interface ActiveTerminalData { class VariableResolver { - constructor(public workspaceFolder: IWorkspaceFolder, public taskSystemInfo: TaskSystemInfo | undefined, private _values: Map, private _service: IConfigurationResolverService | undefined) { + constructor(public workspaceFolder: IWorkspaceFolder | undefined, public taskSystemInfo: TaskSystemInfo | undefined, private _values: Map, private _service: IConfigurationResolverService | undefined) { } resolve(value: string): string { return value.replace(/\$\{(.*?)\}/g, (match: string, variable: string) => { @@ -389,7 +389,7 @@ export class TerminalTaskSystem implements ITaskSystem { } } - private resolveVariablesFromSet(taskSystemInfo: TaskSystemInfo | undefined, workspaceFolder: IWorkspaceFolder, task: CustomTask | ContributedTask, variables: Set): Promise { + private resolveVariablesFromSet(taskSystemInfo: TaskSystemInfo | undefined, workspaceFolder: IWorkspaceFolder | undefined, task: CustomTask | ContributedTask, variables: Set): Promise { let isProcess = task.command && task.command.runtime === RuntimeType.Process; let options = task.command && task.command.options ? task.command.options : undefined; let cwd = options ? options.cwd : undefined; @@ -406,7 +406,7 @@ export class TerminalTaskSystem implements ITaskSystem { } let resolvedVariables: Promise; - if (taskSystemInfo) { + if (taskSystemInfo && workspaceFolder) { let resolveSet: ResolveSet = { variables }; @@ -463,10 +463,7 @@ export class TerminalTaskSystem implements ITaskSystem { private executeCommand(task: CustomTask | ContributedTask, trigger: string): Promise { const workspaceFolder = this.currentTask.workspaceFolder = task.getWorkspaceFolder(); - if (workspaceFolder === undefined) { - return Promise.reject(new Error(`Must have workspace folder${task._label}`)); - } - const systemInfo = this.currentTask.systemInfo = this.taskSystemInfoResolver(workspaceFolder); + const systemInfo: TaskSystemInfo | undefined = this.currentTask.systemInfo = workspaceFolder ? this.taskSystemInfoResolver(workspaceFolder) : undefined; let variables = new Set(); this.collectTaskVariables(variables, task); @@ -515,7 +512,7 @@ export class TerminalTaskSystem implements ITaskSystem { } } - private async executeInTerminal(task: CustomTask | ContributedTask, trigger: string, resolver: VariableResolver, workspaceFolder: IWorkspaceFolder): Promise { + private async executeInTerminal(task: CustomTask | ContributedTask, trigger: string, resolver: VariableResolver, workspaceFolder: IWorkspaceFolder | undefined): Promise { let terminal: ITerminalInstance | undefined = undefined; let executedCommand: string | undefined = undefined; let error: TaskError | undefined = undefined; @@ -761,7 +758,7 @@ export class TerminalTaskSystem implements ITaskSystem { }); } - private createTerminalName(task: CustomTask | ContributedTask, workspaceFolder: IWorkspaceFolder): string { + private createTerminalName(task: CustomTask | ContributedTask): string { const needsFolderQualification = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE; return nls.localize('TerminalTaskSystem.terminalName', 'Task - {0}', needsFolderQualification ? task.getQualifiedLabel() : task.configurationProperties.name); } @@ -774,11 +771,11 @@ export class TerminalTaskSystem implements ITaskSystem { return URI.from({ scheme: Schemas.file, path: this.environmentService.userHome }); } - private async createShellLaunchConfig(task: CustomTask | ContributedTask, workspaceFolder: IWorkspaceFolder, variableResolver: VariableResolver, platform: Platform.Platform, options: CommandOptions, command: CommandString, args: CommandString[], waitOnExit: boolean | string): Promise { + private async createShellLaunchConfig(task: CustomTask | ContributedTask, workspaceFolder: IWorkspaceFolder | undefined, variableResolver: VariableResolver, platform: Platform.Platform, options: CommandOptions, command: CommandString, args: CommandString[], waitOnExit: boolean | string): Promise { let shellLaunchConfig: IShellLaunchConfig; let isShellCommand = task.command.runtime === RuntimeType.Shell; let needsFolderQualification = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE; - let terminalName = this.createTerminalName(task, workspaceFolder); + let terminalName = this.createTerminalName(task); let originalCommand = task.command.name; if (isShellCommand) { const defaultConfig = await this.terminalInstanceService.getDefaultShellAndArgs(true, platform); @@ -846,7 +843,7 @@ export class TerminalTaskSystem implements ITaskSystem { shellArgs.push(commandLine); shellLaunchConfig.args = windowsShellArgs ? shellArgs.join(' ') : shellArgs; if (task.command.presentation && task.command.presentation.echo) { - if (needsFolderQualification) { + if (needsFolderQualification && workspaceFolder) { shellLaunchConfig.initialText = `\x1b[1m> Executing task in folder ${workspaceFolder.name}: ${commandLine} <\x1b[0m\n`; } else { shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${commandLine} <\x1b[0m\n`; @@ -875,7 +872,7 @@ export class TerminalTaskSystem implements ITaskSystem { } return args.join(' '); }; - if (needsFolderQualification) { + if (needsFolderQualification && workspaceFolder) { shellLaunchConfig.initialText = `\x1b[1m> Executing task in folder ${workspaceFolder.name}: ${shellLaunchConfig.executable} ${getArgsToEcho(shellLaunchConfig.args)} <\x1b[0m\n`; } else { shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${shellLaunchConfig.executable} ${getArgsToEcho(shellLaunchConfig.args)} <\x1b[0m\n`; @@ -886,7 +883,6 @@ export class TerminalTaskSystem implements ITaskSystem { if (options.cwd) { let cwd = options.cwd; if (!path.isAbsolute(cwd)) { - let workspaceFolder = task.getWorkspaceFolder(); if (workspaceFolder && (workspaceFolder.uri.scheme === 'file')) { cwd = path.join(workspaceFolder.uri.fsPath, cwd); } @@ -900,7 +896,7 @@ export class TerminalTaskSystem implements ITaskSystem { return shellLaunchConfig; } - private async createTerminal(task: CustomTask | ContributedTask, resolver: VariableResolver, workspaceFolder: IWorkspaceFolder): Promise<[ITerminalInstance | undefined, string | undefined, TaskError | undefined]> { + private async createTerminal(task: CustomTask | ContributedTask, resolver: VariableResolver, workspaceFolder: IWorkspaceFolder | undefined): Promise<[ITerminalInstance | undefined, string | undefined, TaskError | undefined]> { let platform = resolver.taskSystemInfo ? resolver.taskSystemInfo.platform : Platform.platform; let options = this.resolveOptions(resolver, task.command.options); @@ -929,7 +925,7 @@ export class TerminalTaskSystem implements ITaskSystem { this.currentTask.shellLaunchConfig = launchConfigs = { isExtensionTerminal: true, waitOnExit, - name: this.createTerminalName(task, workspaceFolder), + name: this.createTerminalName(task), initialText: task.command.presentation && task.command.presentation.echo ? `\x1b[1m> Executing task: ${task._label} <\x1b[0m\n` : undefined }; } else { From 191ecb92f865b05d76d21b197d2a57e132797e66 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 5 Sep 2019 07:30:24 +0200 Subject: [PATCH 083/204] Revert "Fix rawSearchService to handle maxResults=0 correctly" This reverts commit 5f36b0ea9ab48abc4be5a4b51124d0fede4d1630. --- .../services/search/node/rawSearchService.ts | 2 +- .../search/test/node/rawSearchService.test.ts | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/vs/workbench/services/search/node/rawSearchService.ts b/src/vs/workbench/services/search/node/rawSearchService.ts index c0d0e6d635861..2a27d205aac14 100644 --- a/src/vs/workbench/services/search/node/rawSearchService.ts +++ b/src/vs/workbench/services/search/node/rawSearchService.ts @@ -254,7 +254,7 @@ export class SearchService implements IRawSearchService { const query = prepareQuery(config.filePattern || ''); const compare = (matchA: IRawFileMatch, matchB: IRawFileMatch) => compareItemsByScore(matchA, matchB, query, true, FileMatchItemAccessor, scorerCache); - const maxResults = typeof config.maxResults === 'number' ? config.maxResults : Number.MAX_VALUE; + const maxResults = config.maxResults || Number.MAX_VALUE; return arrays.topAsync(results, compare, maxResults, 10000, token); } diff --git a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts index c0a85168b8029..4060adff5f03e 100644 --- a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts +++ b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts @@ -185,25 +185,6 @@ suite('RawSearchService', () => { assert.strictEqual(result.results.length, 1, 'Result'); }); - test('Handles maxResults=0 correctly', async function () { - this.timeout(testTimeout); - const service = new RawSearchService(); - - const query: IFileQuery = { - type: QueryType.File, - folderQueries: MULTIROOT_QUERIES, - maxResults: 0, - sortByScore: true, - includePattern: { - '*.txt': true, - '*.js': true - }, - }; - - const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query)); - assert.strictEqual(result.results.length, 0, 'Result'); - }); - test('Multi-root with include pattern and exists', async function () { this.timeout(testTimeout); const service = new RawSearchService(); From 2adf01f2af44d27520775c9c1c89e457766ed847 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 11:13:42 +0200 Subject: [PATCH 084/204] Convert more editor options --- .../common/config/commonEditorConfig.ts | 77 +- src/vs/editor/common/config/editorOptions.ts | 692 ++++++++---------- .../services/editorWorkerServiceImpl.ts | 3 +- .../common/standalone/standaloneEnums.ts | 132 ++-- .../contrib/codeAction/lightBulbWidget.ts | 2 +- .../editor/contrib/contextmenu/contextmenu.ts | 2 +- src/vs/editor/contrib/find/findController.ts | 20 +- src/vs/editor/contrib/find/findWidget.ts | 14 +- src/vs/editor/contrib/folding/folding.ts | 10 +- .../goToDefinition/goToDefinitionCommands.ts | 3 +- src/vs/editor/contrib/hover/hover.ts | 5 +- .../editor/contrib/hover/modesContentHover.ts | 5 +- .../parameterHints/parameterHintsModel.ts | 7 +- .../editor/contrib/suggest/completionModel.ts | 4 +- src/vs/editor/contrib/suggest/suggestModel.ts | 16 +- .../editor/contrib/suggest/suggestWidget.ts | 25 +- .../suggest/test/completionModel.test.ts | 31 +- .../editor/contrib/suggest/wordContextKey.ts | 5 +- src/vs/editor/contrib/suggest/wordDistance.ts | 3 +- .../common/config/commonEditorConfig.test.ts | 4 +- src/vs/monaco.d.ts | 264 ++++--- .../api/browser/mainThreadSaveParticipant.ts | 5 +- .../contrib/snippets/browser/tabCompletion.ts | 5 +- 23 files changed, 649 insertions(+), 685 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 3e48ce0e7b86f..686808bbd1cf4 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; -import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, IValidatedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, EditorOptionsValidator, EDITOR_DEFAULTS, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -116,59 +116,76 @@ export class EditorConfiguration2 { * Compatibility with old options */ function migrateOptions(options: IEditorOptions): void { - let wordWrap = options.wordWrap; + const wordWrap = options.wordWrap; if (wordWrap === true) { options.wordWrap = 'on'; } else if (wordWrap === false) { options.wordWrap = 'off'; } - let lineNumbers = options.lineNumbers; + const lineNumbers = options.lineNumbers; if (lineNumbers === true) { options.lineNumbers = 'on'; } else if (lineNumbers === false) { options.lineNumbers = 'off'; } - let autoClosingBrackets = options.autoClosingBrackets; + const autoClosingBrackets = options.autoClosingBrackets; if (autoClosingBrackets === false) { options.autoClosingBrackets = 'never'; options.autoClosingQuotes = 'never'; options.autoSurround = 'never'; } - let cursorBlinking = options.cursorBlinking; + const cursorBlinking = options.cursorBlinking; if (cursorBlinking === 'visible') { options.cursorBlinking = 'solid'; } - let renderWhitespace = options.renderWhitespace; + const renderWhitespace = options.renderWhitespace; if (renderWhitespace === true) { options.renderWhitespace = 'boundary'; } else if (renderWhitespace === false) { options.renderWhitespace = 'none'; } - let renderLineHighlight = options.renderLineHighlight; + const renderLineHighlight = options.renderLineHighlight; if (renderLineHighlight === true) { options.renderLineHighlight = 'line'; } else if (renderLineHighlight === false) { options.renderLineHighlight = 'none'; } - let acceptSuggestionOnEnter = options.acceptSuggestionOnEnter; + const acceptSuggestionOnEnter = options.acceptSuggestionOnEnter; if (acceptSuggestionOnEnter === true) { options.acceptSuggestionOnEnter = 'on'; } else if (acceptSuggestionOnEnter === false) { options.acceptSuggestionOnEnter = 'off'; } + + const tabCompletion = options.tabCompletion; + if (tabCompletion === false) { + options.tabCompletion = 'off'; + } else if (tabCompletion === true) { + options.tabCompletion = 'onlySnippets'; + } + + const hover = options.hover; + if (hover === true) { + options.hover = { + enabled: true + }; + } else if (hover === false) { + options.hover = { + enabled: false + }; + } } export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { public readonly isSimpleWidget: boolean; protected _rawOptions: IEditorOptions; - protected _validatedOptions: IValidatedEditorOptions; public editor!: InternalEditorOptions; private _isDominatedByLongLines: boolean; private _lineNumbersDigitCount: number; @@ -194,8 +211,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {}); this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {}); - this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); - this._rawOptions2 = EditorConfiguration2.readOptions(options); this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); @@ -237,7 +252,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed } private _computeInternalOptions(): [InternalEditorOptions, ComputedEditorOptions] { - const opts = this._validatedOptions; const partialEnv = this._getEnvConfiguration(); const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget); const env: IEnvironmentalOptions = { @@ -252,7 +266,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed tabFocusMode: TabFocus.getTabFocusMode(), accessibilitySupport: partialEnv.accessibilitySupport }; - const r = InternalEditorOptionsFactory.createInternalEditorOptions(env, opts); + const r = InternalEditorOptionsFactory.createInternalEditorOptions(env); const r2 = EditorConfiguration2.computeOptions(this._validatedOptions2, env); return [r, r2]; } @@ -308,7 +322,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed this._rawOptions = objects.mixin(this._rawOptions, newOptions || {}); this._rawOptions2 = EditorConfiguration2.mixOptions(this._rawOptions2, newOptions); - this._validatedOptions = EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS); this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); this._recomputeOptions(); @@ -491,32 +504,32 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.hover.enabled': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.hover.enabled, + 'default': EditorOptions.hover.defaultValue.enabled, 'description': nls.localize('hover.enabled', "Controls whether the hover is shown.") }, 'editor.hover.delay': { 'type': 'number', - 'default': EDITOR_DEFAULTS.contribInfo.hover.delay, + 'default': EditorOptions.hover.defaultValue.delay, 'description': nls.localize('hover.delay', "Controls the delay in milliseconds after which the hover is shown.") }, 'editor.hover.sticky': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.hover.sticky, + 'default': EditorOptions.hover.defaultValue.sticky, 'description': nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.") }, 'editor.find.seedSearchStringFromSelection': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection, + 'default': EditorOptions.find.defaultValue.seedSearchStringFromSelection, 'description': nls.localize('find.seedSearchStringFromSelection', "Controls whether the search string in the Find Widget is seeded from the editor selection.") }, 'editor.find.autoFindInSelection': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.find.autoFindInSelection, + 'default': EditorOptions.find.defaultValue.autoFindInSelection, 'description': nls.localize('find.autoFindInSelection', "Controls whether the find operation is carried out on selected text or the entire file in the editor.") }, 'editor.find.globalFindClipboard': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.find.globalFindClipboard, + 'default': EditorOptions.find.defaultValue.globalFindClipboard, 'description': nls.localize('find.globalFindClipboard', "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."), 'included': platform.isMacintosh }, @@ -635,7 +648,7 @@ const editorConfiguration: IConfigurationNode = { } } ], - 'default': EDITOR_DEFAULTS.contribInfo.quickSuggestions, + 'default': EditorOptions.quickSuggestions.defaultValue, 'description': nls.localize('quickSuggestions', "Controls whether suggestions should automatically show up while typing.") }, 'editor.quickSuggestionsDelay': { @@ -646,12 +659,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.parameterHints.enabled': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.parameterHints.enabled, + 'default': EditorOptions.parameterHints.defaultValue.enabled, 'description': nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.") }, 'editor.parameterHints.cycle': { 'type': 'boolean', - 'default': EDITOR_DEFAULTS.contribInfo.parameterHints.cycle, + 'default': EditorOptions.parameterHints.defaultValue.cycle, 'description': nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.") }, 'editor.autoClosingBrackets': { @@ -746,7 +759,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('snippetSuggestions.inline', "Show snippets suggestions with other suggestions."), nls.localize('snippetSuggestions.none', "Do not show snippet suggestions."), ], - 'default': EDITOR_DEFAULTS.contribInfo.suggest.snippets, + 'default': EditorOptions.snippetSuggestions.defaultValue, 'description': nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.") }, 'editor.emptySelectionClipboard': { @@ -761,7 +774,7 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.wordBasedSuggestions': { 'type': 'boolean', - 'default': EditorOptions.wordBasedSuggestions.defaultValue, + 'default': true, 'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.") }, 'editor.suggestSelection': { @@ -820,12 +833,12 @@ const editorConfiguration: IConfigurationNode = { }, 'editor.suggest.showIcons': { type: 'boolean', - default: EDITOR_DEFAULTS.contribInfo.suggest.showIcons, + default: EditorOptions.suggest.defaultValue.showIcons, description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.") }, 'editor.suggest.maxVisibleSuggestions': { type: 'number', - default: EDITOR_DEFAULTS.contribInfo.suggest.maxVisibleSuggestions, + default: EditorOptions.suggest.defaultValue.maxVisibleSuggestions, minimum: 1, maximum: 15, description: nls.localize('suggest.maxVisibleSuggestions', "Controls how many suggestions IntelliSense will show before showing a scrollbar (maximum 15).") @@ -971,7 +984,7 @@ const editorConfiguration: IConfigurationNode = { description: nls.localize('editor.gotoLocation.multiple', "Controls the behavior of 'Go To' commands, like Go To Definition, when multiple target locations exist."), type: 'string', enum: ['peek', 'gotoAndPeek', 'goto'], - default: EDITOR_DEFAULTS.contribInfo.gotoLocation.multiple, + default: EditorOptions.gotoLocation.defaultValue.multiple, enumDescriptions: [ nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'), nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a peek view'), @@ -1087,13 +1100,13 @@ const editorConfiguration: IConfigurationNode = { 'editor.foldingStrategy': { 'type': 'string', 'enum': ['auto', 'indentation'], - 'default': EDITOR_DEFAULTS.contribInfo.foldingStrategy, + 'default': EditorOptions.foldingStrategy.defaultValue, 'markdownDescription': nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges. `auto` uses a language specific folding strategy, if available. `indentation` uses the indentation based folding strategy.") }, 'editor.showFoldingControls': { 'type': 'string', 'enum': ['always', 'mouseover'], - 'default': EDITOR_DEFAULTS.contribInfo.showFoldingControls, + 'default': EditorOptions.showFoldingControls.defaultValue, 'description': nls.localize('showFoldingControls', "Controls whether the fold controls on the gutter are automatically hidden.") }, 'editor.matchBrackets': { @@ -1177,12 +1190,12 @@ const editorConfiguration: IConfigurationNode = { 'additionalProperties': { 'type': 'boolean' }, - 'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSave, + 'default': {}, 'description': nls.localize('codeActionsOnSave', "Code action kinds to be run on save.") }, 'editor.codeActionsOnSaveTimeout': { 'type': 'number', - 'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSaveTimeout, + 'default': 750, 'description': nls.localize('codeActionsOnSaveTimeout', "Timeout in milliseconds after which the code actions that are run on save are cancelled.") }, 'editor.selectionClipboard': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 09af97936c7a2..873bb5575e7f1 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -217,7 +217,7 @@ export interface ISuggestOptions { /** * Max suggestions to show in suggestions. Defaults to 12. */ - maxVisibleSuggestions?: boolean; + maxVisibleSuggestions?: number; /** * Names of suggestion types to filter. */ @@ -231,11 +231,10 @@ export interface IGotoLocationOptions { multiple?: 'peek' | 'gotoAndPeek' | 'goto'; } -/** - * Configuration map for codeActionsOnSave - */ -export interface ICodeActionsOnSaveOptions { - [kind: string]: boolean; +export interface IQuickSuggestionsOptions { + other: boolean; + comments: boolean; + strings: boolean; } /** @@ -528,7 +527,7 @@ export interface IEditorOptions { * Enable quick suggestions (shadow suggestions) * Defaults to true. */ - quickSuggestions?: boolean | { other: boolean, comments: boolean, strings: boolean }; + quickSuggestions?: boolean | IQuickSuggestionsOptions; /** * Quick suggestions show delay (in ms) * Defaults to 10 (ms) @@ -604,10 +603,6 @@ export interface IEditorOptions { * Syntax highlighting is copied. */ copyWithSyntaxHighlighting?: boolean; - /** - * Enable word based suggestions. Defaults to 'true' - */ - wordBasedSuggestions?: boolean; /** * The history mode for suggestions. */ @@ -625,7 +620,7 @@ export interface IEditorOptions { /** * Enable tab completion. */ - tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets'; + tabCompletion?: 'on' | 'off' | 'onlySnippets'; /** * Enable selection highlight. * Defaults to true. @@ -645,10 +640,6 @@ export interface IEditorOptions { * Control the behavior and rendering of the code action lightbulb. */ lightbulb?: IEditorLightbulbOptions; - /** - * Code action kinds to be run on save. - */ - codeActionsOnSave?: ICodeActionsOnSaveOptions; /** * Timeout for running code actions on save. */ @@ -903,68 +894,6 @@ function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'l } } -export interface InternalEditorFindOptions { - readonly seedSearchStringFromSelection: boolean; - readonly autoFindInSelection: boolean; - readonly addExtraSpaceOnTop: boolean; - /** - * @internal - */ - readonly globalFindClipboard: boolean; -} - -export interface InternalEditorHoverOptions { - readonly enabled: boolean; - readonly delay: number; - readonly sticky: boolean; -} - -export interface InternalGoToLocationOptions { - readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; -} - -export interface InternalSuggestOptions { - readonly filterGraceful: boolean; - readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; - readonly snippetsPreventQuickSuggestions: boolean; - readonly localityBonus: boolean; - readonly shareSuggestSelections: boolean; - readonly showIcons: boolean; - readonly maxVisibleSuggestions: number; - readonly filteredTypes: Record; -} - -export interface InternalParameterHintOptions { - readonly enabled: boolean; - readonly cycle: boolean; -} - -export interface EditorContribOptions { - readonly hover: InternalEditorHoverOptions; - readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean }; - readonly parameterHints: InternalParameterHintOptions; - readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; - readonly suggestFontSize: number; - readonly suggestLineHeight: number; - readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; - readonly suggest: InternalSuggestOptions; - readonly gotoLocation: InternalGoToLocationOptions; - readonly foldingStrategy: 'auto' | 'indentation'; - readonly showFoldingControls: 'always' | 'mouseover'; - readonly find: InternalEditorFindOptions; - readonly codeActionsOnSave: ICodeActionsOnSaveOptions; - readonly codeActionsOnSaveTimeout: number; -} - -/** - * Validated configuration options for the editor. - * This is a 1 to 1 validated/parsed version of IEditorOptions merged on top of the defaults. - * @internal - */ -export interface IValidatedEditorOptions { - readonly contribInfo: EditorContribOptions; -} - /** * Internal configuration options (transformed or computed) for the editor. */ @@ -976,7 +905,6 @@ export class InternalEditorOptions { // ---- grouped options readonly fontInfo: FontInfo; - readonly contribInfo: EditorContribOptions; /** * @internal @@ -985,12 +913,10 @@ export class InternalEditorOptions { pixelRatio: number; lineHeight: number; fontInfo: FontInfo; - contribInfo: EditorContribOptions; }) { this.pixelRatio = source.pixelRatio; this.lineHeight = source.lineHeight | 0; this.fontInfo = source.fontInfo; - this.contribInfo = source.contribInfo; } /** @@ -1001,7 +927,6 @@ export class InternalEditorOptions { this.pixelRatio === other.pixelRatio && this.lineHeight === other.lineHeight && this.fontInfo.equals(other.fontInfo) - && InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo) ); } @@ -1019,111 +944,8 @@ export class InternalEditorOptions { pixelRatio: (this.pixelRatio !== newOpts.pixelRatio), lineHeight: (this.lineHeight !== newOpts.lineHeight), fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), - contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo)) }; } - - /** - * @internal - */ - private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean { - return ( - a.seedSearchStringFromSelection === b.seedSearchStringFromSelection - && a.autoFindInSelection === b.autoFindInSelection - && a.globalFindClipboard === b.globalFindClipboard - && a.addExtraSpaceOnTop === b.addExtraSpaceOnTop - ); - } - - /** - * @internal - */ - private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean { - return ( - a.enabled === b.enabled - && a.cycle === b.cycle - ); - } - - /** - * @internal - */ - private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean { - return ( - a.enabled === b.enabled - && a.delay === b.delay - && a.sticky === b.sticky - ); - } - - /** - * @internal - */ - private static _equalsSuggestOptions(a: InternalSuggestOptions, b: InternalSuggestOptions): any { - if (a === b) { - return true; - } else if (!a || !b) { - return false; - } else { - return a.filterGraceful === b.filterGraceful - && a.snippets === b.snippets - && a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions - && a.localityBonus === b.localityBonus - && a.shareSuggestSelections === b.shareSuggestSelections - && a.showIcons === b.showIcons - && a.maxVisibleSuggestions === b.maxVisibleSuggestions - && objects.equals(a.filteredTypes, b.filteredTypes); - } - } - - private static _equalsGotoLocationOptions(a: InternalGoToLocationOptions | undefined, b: InternalGoToLocationOptions | undefined): boolean { - if (a === b) { - return true; - } else if (!a || !b) { - return false; - } else { - return a.multiple === b.multiple; - } - } - - /** - * @internal - */ - private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean { - return ( - this._equalsHoverOptions(a.hover, b.hover) - && InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions) - && this._equalsParameterHintOptions(a.parameterHints, b.parameterHints) - && a.suggestSelection === b.suggestSelection - && a.suggestFontSize === b.suggestFontSize - && a.suggestLineHeight === b.suggestLineHeight - && a.tabCompletion === b.tabCompletion - && this._equalsSuggestOptions(a.suggest, b.suggest) - && InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation) - && a.foldingStrategy === b.foldingStrategy - && a.showFoldingControls === b.showFoldingControls - && this._equalFindOptions(a.find, b.find) - && objects.equals(a.codeActionsOnSave, b.codeActionsOnSave) - && a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout - ); - } - - private static _equalsQuickSuggestions(a: boolean | { other: boolean, comments: boolean, strings: boolean }, b: boolean | { other: boolean, comments: boolean, strings: boolean }): boolean { - if (typeof a === 'boolean') { - if (typeof b !== 'boolean') { - return false; - } - return a === b; - } - if (typeof b === 'boolean') { - return false; - } - return ( - a.comments === b.comments - && a.other === b.other - && a.strings === b.strings - ); - } } /** @@ -1134,7 +956,6 @@ export interface IConfigurationChangedEvent { readonly pixelRatio: boolean; readonly lineHeight: boolean; readonly fontInfo: boolean; - readonly contribInfo: boolean; } export interface IEnvironmentalOptions { @@ -1150,7 +971,7 @@ export interface IEnvironmentalOptions { readonly accessibilitySupport: AccessibilitySupport; } -function _boolean(value: any, defaultValue: T): boolean | T { +function _boolean(value: any, defaultValue: boolean): boolean { if (typeof value === 'undefined') { return defaultValue; } @@ -1161,21 +982,6 @@ function _boolean(value: any, defaultValue: T): boolean | T { return Boolean(value); } -function _booleanMap(value: { [key: string]: boolean } | undefined, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } { - if (!value) { - return defaultValue; - } - - const out = Object.create(null); - for (const k of Object.keys(value)) { - const v = value[k]; - if (typeof v === 'boolean') { - out[k] = v; - } - } - return out; -} - function _string(value: any, defaultValue: string): string { if (typeof value !== 'string') { return defaultValue; @@ -1254,134 +1060,16 @@ function _scrollbarVisibilityFromString(visibility: string | undefined, defaultV } } -/** - * @internal - */ -export class EditorOptionsValidator { - - /** - * Validate raw editor options. - * i.e. since they can be defined by the user, they might be invalid. - */ - public static validate(opts: IEditorOptions, defaults: IValidatedEditorOptions): IValidatedEditorOptions { - const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo); - return { - contribInfo: contribInfo, - }; - } - - private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions { - if (typeof opts !== 'object') { - return defaults; - } - - return { - seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection), - autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection), - globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard), - addExtraSpaceOnTop: _boolean(opts.addExtraSpaceOnTop, defaults.addExtraSpaceOnTop) - }; - } - - private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions | undefined, defaults: InternalParameterHintOptions): InternalParameterHintOptions { - if (typeof opts !== 'object') { - return defaults; - } - - return { - enabled: _boolean(opts.enabled, defaults.enabled), - cycle: _boolean(opts.cycle, defaults.cycle) - }; - } - - private static _sanitizeHoverOpts(_opts: boolean | IEditorHoverOptions | undefined, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions { - let opts: IEditorHoverOptions; - if (typeof _opts === 'boolean') { - opts = { - enabled: _opts - }; - } else if (typeof _opts === 'object') { - opts = _opts; - } else { - return defaults; - } - - return { - enabled: _boolean(opts.enabled, defaults.enabled), - delay: _clampedInt(opts.delay, defaults.delay, 0, 10000), - sticky: _boolean(opts.sticky, defaults.sticky) - }; - } - - private static _sanitizeSuggestOpts(opts: IEditorOptions, defaults: InternalSuggestOptions): InternalSuggestOptions { - const suggestOpts = opts.suggest || {}; - return { - filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful), - snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']), - snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful), - localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus), - shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections), - showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons), - maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 15), - filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null) - }; - } - - private static _sanitizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions { - const gotoOpts = opts.gotoLocation || {}; - return { - multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(gotoOpts.multiple, defaults.multiple, ['peek', 'gotoAndPeek', 'goto']) - }; - } - - private static _sanitizeTabCompletionOpts(opts: boolean | 'on' | 'off' | 'onlySnippets' | undefined, defaults: 'on' | 'off' | 'onlySnippets'): 'on' | 'off' | 'onlySnippets' { - if (opts === false) { - return 'off'; - } else if (opts === true) { - return 'onlySnippets'; - } else { - return _stringSet<'on' | 'off' | 'onlySnippets'>(opts, defaults, ['on', 'off', 'onlySnippets']); - } - } - - private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions { - let quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean }; - if (typeof opts.quickSuggestions === 'object') { - quickSuggestions = { other: true, ...opts.quickSuggestions }; - } else { - quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions); - } - const find = this._sanitizeFindOpts(opts.find, defaults.find); - return { - hover: this._sanitizeHoverOpts(opts.hover, defaults.hover), - quickSuggestions: quickSuggestions, - parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints), - suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']), - suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000), - suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000), - tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion), - suggest: this._sanitizeSuggestOpts(opts, defaults.suggest), - gotoLocation: this._sanitizeGotoLocationOpts(opts, defaults.gotoLocation), - foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']), - showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']), - find: find, - codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}), - codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000) - }; - } -} - /** * @internal */ export class InternalEditorOptionsFactory { - public static createInternalEditorOptions(env: IEnvironmentalOptions, opts: IValidatedEditorOptions) { + public static createInternalEditorOptions(env: IEnvironmentalOptions) { return new InternalEditorOptions({ pixelRatio: env.pixelRatio, lineHeight: env.fontInfo.lineHeight, fontInfo: env.fontInfo, - contribInfo: opts.contribInfo, }); } } @@ -1448,55 +1136,6 @@ export const EDITOR_MODEL_DEFAULTS = { largeFileOptimizations: true }; -/** - * @internal - */ -export const EDITOR_DEFAULTS: IValidatedEditorOptions = { - contribInfo: { - hover: { - enabled: true, - delay: 300, - sticky: true - }, - quickSuggestions: { - other: true, - comments: false, - strings: false - }, - parameterHints: { - enabled: true, - cycle: false - }, - suggestSelection: 'recentlyUsed', - suggestFontSize: 0, - suggestLineHeight: 0, - tabCompletion: 'off', - suggest: { - filterGraceful: true, - snippets: 'inline', - snippetsPreventQuickSuggestions: true, - localityBonus: false, - shareSuggestSelections: false, - showIcons: true, - maxVisibleSuggestions: 12, - filteredTypes: Object.create(null) - }, - gotoLocation: { - multiple: 'peek' - }, - foldingStrategy: 'auto', - showFoldingControls: 'mouseover', - find: { - seedSearchStringFromSelection: true, - autoFindInSelection: false, - globalFindClipboard: false, - addExtraSpaceOnTop: true - }, - codeActionsOnSave: {}, - codeActionsOnSaveTimeout: 750 - }, -}; - /** * @internal */ @@ -1565,6 +1204,9 @@ export class ChangedEditorOptions { this._values[id] = value; } } + +//#region IEditorOption + /** * @internal */ @@ -1600,16 +1242,6 @@ export interface IEditorOption[] = []; - -function registerEditorOption(option: IEditorOption): IEditorOption { - editorOptionsRegistry[option.id] = option; - return option; -} - /** * @internal */ @@ -1724,6 +1356,7 @@ class EditorPassthroughOption> extends BaseEditorOption { + public validate(input: IEditorHoverOptions | undefined): InternalEditorHoverOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled), + delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000), + sticky: _boolean(input.sticky, this.defaultValue.sticky) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorHoverOptions): InternalEditorHoverOptions { + return value; + } + public equals(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean { + return ( + a.enabled === b.enabled + && a.delay === b.delay + && a.sticky === b.sticky + ); + } +} + +//#endregion + +//#region quickSuggestions + +export type ValidQuickSuggestionsOptions = boolean | Readonly>; + +class EditorQuickSuggestions> extends BaseEditorOption { + public readonly defaultValue: Readonly>; + constructor(id: K1, name: K2, defaultValue: Readonly>) { + super(id, name, defaultValue); + } + public validate(input: boolean | IQuickSuggestionsOptions | undefined): ValidQuickSuggestionsOptions { + if (typeof input === 'boolean') { + return input; + } + if (typeof input === 'object') { + return { + other: _boolean(input.other, this.defaultValue.other), + comments: _boolean(input.comments, this.defaultValue.comments), + strings: _boolean(input.strings, this.defaultValue.strings), + }; + } + return this.defaultValue; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidQuickSuggestionsOptions): ValidQuickSuggestionsOptions { + return value; + } + public equals(a: ValidQuickSuggestionsOptions, b: ValidQuickSuggestionsOptions): boolean { + if (typeof a === 'boolean') { + if (typeof b !== 'boolean') { + return false; + } + return a === b; + } + if (typeof b === 'boolean') { + return false; + } + return ( + a.comments === b.comments + && a.other === b.other + && a.strings === b.strings + ); + } +} + +//#endregion + //#region accessibilitySupport class EditorAccessibilitySupportOption> extends BaseEditorOption { @@ -2029,6 +1740,161 @@ class EditorScrollbar>; + +export interface InternalSuggestOptions { + readonly filterGraceful: boolean; + readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; + readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + readonly shareSuggestSelections: boolean; + readonly showIcons: boolean; + readonly maxVisibleSuggestions: number; + readonly filteredTypes: Record; +} + +class EditorSuggest> extends BaseEditorOption { + public validate(input: ISuggestOptions | undefined): ValidSuggestOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful), + snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful), + localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus), + shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections), + showIcons: _boolean(input.showIcons, this.defaultValue.showIcons), + maxVisibleSuggestions: _clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15), + filteredTypes: isObject(input.filteredTypes) ? input.filteredTypes : Object.create(null) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidSuggestOptions): InternalSuggestOptions { + const snippetSuggestions = options.get(EditorOption.snippetSuggestions); + return { + filterGraceful: value.filterGraceful, + snippets: snippetSuggestions, + snippetsPreventQuickSuggestions: value.snippetsPreventQuickSuggestions, + localityBonus: value.localityBonus, + shareSuggestSelections: value.shareSuggestSelections, + showIcons: value.showIcons, + maxVisibleSuggestions: value.maxVisibleSuggestions, + filteredTypes: value.filteredTypes, + }; + } + public equals(a: InternalSuggestOptions, b: InternalSuggestOptions): boolean { + return ( + a.filterGraceful === b.filterGraceful + && a.snippets === b.snippets + && a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions + && a.localityBonus === b.localityBonus + && a.shareSuggestSelections === b.shareSuggestSelections + && a.showIcons === b.showIcons + && a.maxVisibleSuggestions === b.maxVisibleSuggestions + && objects.equals(a.filteredTypes, b.filteredTypes) + ); + } +} + +//#endregion + +//#region parameterHints + +export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; +} + +class EditorParameterHints> extends BaseEditorOption { + public validate(input: IEditorParameterHintOptions | undefined): InternalParameterHintOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled), + cycle: _boolean(input.cycle, this.defaultValue.cycle) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalParameterHintOptions): InternalParameterHintOptions { + return value; + } + public equals(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean { + return ( + a.enabled === b.enabled + && a.cycle === b.cycle + ); + } +} + +//#endregion + +//#region find + +export interface InternalEditorFindOptions { + readonly seedSearchStringFromSelection: boolean; + readonly autoFindInSelection: boolean; + readonly addExtraSpaceOnTop: boolean; + /** + * @internal + */ + readonly globalFindClipboard: boolean; +} + +class EditorFind> extends BaseEditorOption { + public validate(input: IEditorFindOptions | undefined): InternalEditorFindOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection), + autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection), + globalFindClipboard: _boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard), + addExtraSpaceOnTop: _boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorFindOptions): InternalEditorFindOptions { + return value; + } + public equals(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean { + return ( + a.seedSearchStringFromSelection === b.seedSearchStringFromSelection + && a.autoFindInSelection === b.autoFindInSelection + && a.globalFindClipboard === b.globalFindClipboard + && a.addExtraSpaceOnTop === b.addExtraSpaceOnTop + ); + } +} + +//#endregion + +//#region gotoLocation + +export interface InternalGoToLocationOptions { + readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; +} + +class EditorGoToLocation> extends BaseEditorOption { + public validate(input: IGotoLocationOptions | undefined): InternalGoToLocationOptions { + if (typeof input !== 'object') { + return this.defaultValue; + } + return { + multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalGoToLocationOptions): InternalGoToLocationOptions { + return value; + } + public equals(a: InternalGoToLocationOptions, b: InternalGoToLocationOptions): boolean { + return ( + a.multiple === b.multiple + ); + } +} + +//#endregion + //#region layoutInfo /** @@ -2467,6 +2333,16 @@ function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): return 'altKey'; } +/** + * @internal + */ +export const editorOptionsRegistry: IEditorOption[] = []; + +function registerEditorOption(option: IEditorOption): IEditorOption { + editorOptionsRegistry[option.id] = option; + return option; +} + export const enum EditorOption { acceptSuggestionOnCommitCharacter, acceptSuggestionOnEnter, @@ -2491,14 +2367,18 @@ export const enum EditorOption { emptySelectionClipboard, extraEditorClassName, fastScrollSensitivity, + find, fixedOverflowWidgets, folding, + foldingStrategy, fontLigatures, formatOnPaste, formatOnType, glyphMargin, + gotoLocation, hideCursorInOverviewRuler, highlightActiveIndentGuide, + hover, inDiffEditor, lightbulb, lineDecorationsWidth, @@ -2515,6 +2395,8 @@ export const enum EditorOption { occurrencesHighlight, overviewRulerBorder, overviewRulerLanes, + parameterHints, + quickSuggestions, quickSuggestionsDelay, readOnly, renderControlCharacters, @@ -2531,12 +2413,17 @@ export const enum EditorOption { selectionClipboard, selectionHighlight, selectOnLineNumbers, + showFoldingControls, showUnused, + snippetSuggestions, smoothScrolling, stopRenderingLineAfter, + suggestFontSize, + suggestLineHeight, suggestOnTriggerCharacters, + suggestSelection, + tabCompletion, useTabStops, - wordBasedSuggestions, wordSeparators, wordWrap, wordWrapBreakAfterCharacters, @@ -2550,6 +2437,7 @@ export const enum EditorOption { disableMonospaceOptimizations, editorClassName, tabFocusMode, + suggest, layoutInfo, wrappingInfo, } @@ -2578,14 +2466,29 @@ export const EditorOptions = { emptySelectionClipboard: registerEditorOption(new EditorEmptySelectionClipboard(EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true)), extraEditorClassName: registerEditorOption(new EditorStringOption(EditorOption.extraEditorClassName, 'extraEditorClassName', '')), fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))), + find: registerEditorOption(new EditorFind(EditorOption.find, 'find', { + seedSearchStringFromSelection: true, + autoFindInSelection: false, + globalFindClipboard: false, + addExtraSpaceOnTop: true + })), fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)), folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), + foldingStrategy: registerEditorOption(new EditorEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto', ['auto', 'indentation'], (x: 'auto' | 'indentation') => x)), fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)), formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), + gotoLocation: registerEditorOption(new EditorGoToLocation(EditorOption.gotoLocation, 'gotoLocation', { + multiple: 'peek' + })), hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)), highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)), + hover: registerEditorOption(new EditorHover(EditorOption.hover, 'hover', { + enabled: true, + delay: 300, + sticky: true + })), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', { enabled: true @@ -2610,6 +2513,15 @@ export const EditorOptions = { occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)), overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)), overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)), + parameterHints: registerEditorOption(new EditorParameterHints(EditorOption.parameterHints, 'parameterHints', { + enabled: true, + cycle: false + })), + quickSuggestions: registerEditorOption(new EditorQuickSuggestions(EditorOption.quickSuggestions, 'quickSuggestions', { + other: true, + comments: false, + strings: false + })), quickSuggestionsDelay: registerEditorOption(new EditorIntOption(EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay', 10, 0, Constants.MAX_SAFE_SMALL_INTEGER)), readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)), renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)), @@ -2638,12 +2550,17 @@ export const EditorOptions = { selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), + showFoldingControls: registerEditorOption(new EditorEnumOption(EditorOption.showFoldingControls, 'showFoldingControls', 'mouseover', ['always', 'mouseover'], (x: 'always' | 'mouseover') => x)), showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)), + snippetSuggestions: registerEditorOption(new EditorEnumOption(EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline', ['top', 'bottom', 'inline', 'none'], x => x)), smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)), stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)), + suggestFontSize: registerEditorOption(new EditorIntOption(EditorOption.suggestFontSize, 'suggestFontSize', 0, 0, 1000)), + suggestLineHeight: registerEditorOption(new EditorIntOption(EditorOption.suggestLineHeight, 'suggestLineHeight', 0, 0, 1000)), suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)), + suggestSelection: registerEditorOption(new EditorEnumOption(EditorOption.suggestSelection, 'suggestSelection', 'recentlyUsed', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'], (x: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix') => x)), + tabCompletion: registerEditorOption(new EditorEnumOption(EditorOption.tabCompletion, 'tabCompletion', 'off', ['on', 'off', 'onlySnippets'], (x: 'on' | 'off' | 'onlySnippets') => x)), useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)), - wordBasedSuggestions: registerEditorOption(new EditorBooleanOption(EditorOption.wordBasedSuggestions, 'wordBasedSuggestions', true)), wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)), wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], (x: 'off' | 'on' | 'wordWrapColumn' | 'bounded') => x)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), @@ -2653,11 +2570,20 @@ export const EditorOptions = { wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)), wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), - // Leave these at the end! + // Leave these at the end (because they have dependencies!) ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])), disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])), editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])), tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), + suggest: registerEditorOption(new EditorSuggest(EditorOption.suggest, 'suggest', { + filterGraceful: true, + snippetsPreventQuickSuggestions: true, + localityBonus: false, + shareSuggestSelections: false, + showIcons: true, + maxVisibleSuggestions: 12, + filteredTypes: Object.create(null) + }, [EditorOption.snippetSuggestions])), layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])), wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), }; diff --git a/src/vs/editor/common/services/editorWorkerServiceImpl.ts b/src/vs/editor/common/services/editorWorkerServiceImpl.ts index 34001e406087a..9267a035826bf 100644 --- a/src/vs/editor/common/services/editorWorkerServiceImpl.ts +++ b/src/vs/editor/common/services/editorWorkerServiceImpl.ts @@ -8,7 +8,6 @@ import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from import { URI } from 'vs/base/common/uri'; import { SimpleWorkerClient, logOnceWebWorkerWarning, IWorkerClient } from 'vs/base/common/worker/simpleWorker'; import { DefaultWorkerFactory } from 'vs/base/worker/defaultWorkerFactory'; -import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -146,7 +145,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider { } provideCompletionItems(model: ITextModel, position: Position): Promise | undefined { - const { wordBasedSuggestions } = this._configurationService.getValue(model.uri, position, 'editor'); + const { wordBasedSuggestions } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean }>(model.uri, position, 'editor'); if (!wordBasedSuggestions) { return undefined; } diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 8393a6c1ec6bb..6410d3b438bce 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -463,66 +463,78 @@ export enum EditorOption { emptySelectionClipboard = 20, extraEditorClassName = 21, fastScrollSensitivity = 22, - fixedOverflowWidgets = 23, - folding = 24, - fontLigatures = 25, - formatOnPaste = 26, - formatOnType = 27, - glyphMargin = 28, - hideCursorInOverviewRuler = 29, - highlightActiveIndentGuide = 30, - inDiffEditor = 31, - lightbulb = 32, - lineDecorationsWidth = 33, - lineNumbers = 34, - lineNumbersMinChars = 35, - links = 36, - matchBrackets = 37, - minimap = 38, - mouseStyle = 39, - mouseWheelScrollSensitivity = 40, - mouseWheelZoom = 41, - multiCursorMergeOverlapping = 42, - multiCursorModifier = 43, - occurrencesHighlight = 44, - overviewRulerBorder = 45, - overviewRulerLanes = 46, - quickSuggestionsDelay = 47, - readOnly = 48, - renderControlCharacters = 49, - renderIndentGuides = 50, - renderFinalNewline = 51, - renderLineHighlight = 52, - renderWhitespace = 53, - revealHorizontalRightPadding = 54, - roundedSelection = 55, - rulers = 56, - scrollbar = 57, - scrollBeyondLastColumn = 58, - scrollBeyondLastLine = 59, - selectionClipboard = 60, - selectionHighlight = 61, - selectOnLineNumbers = 62, - showUnused = 63, - smoothScrolling = 64, - stopRenderingLineAfter = 65, - suggestOnTriggerCharacters = 66, - useTabStops = 67, - wordBasedSuggestions = 68, - wordSeparators = 69, - wordWrap = 70, - wordWrapBreakAfterCharacters = 71, - wordWrapBreakBeforeCharacters = 72, - wordWrapBreakObtrusiveCharacters = 73, - wordWrapColumn = 74, - wordWrapMinified = 75, - wrappingIndent = 76, - ariaLabel = 77, - disableMonospaceOptimizations = 78, - editorClassName = 79, - tabFocusMode = 80, - layoutInfo = 81, - wrappingInfo = 82 + find = 23, + fixedOverflowWidgets = 24, + folding = 25, + foldingStrategy = 26, + fontLigatures = 27, + formatOnPaste = 28, + formatOnType = 29, + glyphMargin = 30, + gotoLocation = 31, + hideCursorInOverviewRuler = 32, + highlightActiveIndentGuide = 33, + hover = 34, + inDiffEditor = 35, + lightbulb = 36, + lineDecorationsWidth = 37, + lineNumbers = 38, + lineNumbersMinChars = 39, + links = 40, + matchBrackets = 41, + minimap = 42, + mouseStyle = 43, + mouseWheelScrollSensitivity = 44, + mouseWheelZoom = 45, + multiCursorMergeOverlapping = 46, + multiCursorModifier = 47, + occurrencesHighlight = 48, + overviewRulerBorder = 49, + overviewRulerLanes = 50, + parameterHints = 51, + quickSuggestions = 52, + quickSuggestionsDelay = 53, + readOnly = 54, + renderControlCharacters = 55, + renderIndentGuides = 56, + renderFinalNewline = 57, + renderLineHighlight = 58, + renderWhitespace = 59, + revealHorizontalRightPadding = 60, + roundedSelection = 61, + rulers = 62, + scrollbar = 63, + scrollBeyondLastColumn = 64, + scrollBeyondLastLine = 65, + selectionClipboard = 66, + selectionHighlight = 67, + selectOnLineNumbers = 68, + showFoldingControls = 69, + showUnused = 70, + snippetSuggestions = 71, + smoothScrolling = 72, + stopRenderingLineAfter = 73, + suggestFontSize = 74, + suggestLineHeight = 75, + suggestOnTriggerCharacters = 76, + suggestSelection = 77, + tabCompletion = 78, + useTabStops = 79, + wordSeparators = 80, + wordWrap = 81, + wordWrapBreakAfterCharacters = 82, + wordWrapBreakBeforeCharacters = 83, + wordWrapBreakObtrusiveCharacters = 84, + wordWrapColumn = 85, + wordWrapMinified = 86, + wrappingIndent = 87, + ariaLabel = 88, + disableMonospaceOptimizations = 89, + editorClassName = 90, + tabFocusMode = 91, + suggest = 92, + layoutInfo = 93, + wrappingInfo = 94 } /** diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index a43dabec6f0b8..3987b9a5eeee1 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -107,7 +107,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget { })); this._register(this._editor.onDidChangeConfiguration(e => { // hide when told to do so - if (e.contribInfo && !this._editor.getOption(EditorOption.lightbulb).enabled) { + if (e.hasChanged(EditorOption.lightbulb) && !this._editor.getOption(EditorOption.lightbulb).enabled) { this.hide(); } })); diff --git a/src/vs/editor/contrib/contextmenu/contextmenu.ts b/src/vs/editor/contrib/contextmenu/contextmenu.ts index 65fbdef07bbee..e88f633d4cab0 100644 --- a/src/vs/editor/contrib/contextmenu/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/contextmenu.ts @@ -148,7 +148,7 @@ export class ContextMenuController implements IEditorContribution { } // Disable hover - const oldHoverSetting = this._editor.getConfiguration().contribInfo.hover; + const oldHoverSetting = this._editor.getOption(EditorOption.hover); this._editor.updateOptions({ hover: { enabled: false diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index 631d9041902ab..f5c7305872f3c 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -121,7 +121,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd if (shouldRestartFind) { this._start({ forceRevealReplace: false, - seedSearchStringFromSelection: false && this._editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection, + seedSearchStringFromSelection: false && this._editor.getOption(EditorOption.find).seedSearchStringFromSelection, seedSearchStringFromGlobalClipboard: false, shouldFocus: FindStartFocusAction.NoFocusChange, shouldAnimate: false, @@ -353,7 +353,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd } public getGlobalBufferTerm(): string { - if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard + if (this._editor.getOption(EditorOption.find).globalFindClipboard && this._clipboardService && this._editor.hasModel() && !this._editor.getModel().isTooLargeForSyncing() @@ -364,7 +364,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd } public setGlobalBufferTerm(text: string) { - if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard + if (this._editor.getOption(EditorOption.find).globalFindClipboard && this._clipboardService && this._editor.hasModel() && !this._editor.getModel().isTooLargeForSyncing() @@ -399,7 +399,7 @@ export class FindController extends CommonFindController implements IFindControl this._createFindWidget(); } - if (!this._widget!.getPosition() && this._editor.getConfiguration().contribInfo.find.autoFindInSelection) { + if (!this._widget!.getPosition() && this._editor.getOption(EditorOption.find).autoFindInSelection) { // not visible yet so we need to set search scope if `editor.find.autoFindInSelection` is `true` opts.updateSearchScope = true; } @@ -457,8 +457,8 @@ export class StartFindAction extends EditorAction { if (controller) { controller.start({ forceRevealReplace: false, - seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection, - seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.globalFindClipboard, + seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection, + seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).globalFindClipboard, shouldFocus: FindStartFocusAction.FocusFindInput, shouldAnimate: true, updateSearchScope: false @@ -508,7 +508,7 @@ export abstract class MatchFindAction extends EditorAction { if (controller && !this._run(controller)) { controller.start({ forceRevealReplace: false, - seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection, + seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(EditorOption.find).seedSearchStringFromSelection, seedSearchStringFromGlobalClipboard: true, shouldFocus: FindStartFocusAction.NoFocusChange, shouldAnimate: true, @@ -620,7 +620,7 @@ export abstract class SelectionMatchFindAction extends EditorAction { if (!this._run(controller)) { controller.start({ forceRevealReplace: false, - seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection, + seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection, seedSearchStringFromGlobalClipboard: false, shouldFocus: FindStartFocusAction.NoFocusChange, shouldAnimate: true, @@ -709,7 +709,7 @@ export class StartFindReplaceAction extends EditorAction { // we only seed search string from selection when the current selection is single line and not empty, // + the find input is not focused let seedSearchStringFromSelection = !currentSelection.isEmpty() - && currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection + && currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getOption(EditorOption.find).seedSearchStringFromSelection && !findInputFocused; /* * if the existing search string in find widget is empty and we don't seed search string from selection, it means the Find Input is still empty, so we should focus the Find Input instead of Replace Input. @@ -726,7 +726,7 @@ export class StartFindReplaceAction extends EditorAction { controller.start({ forceRevealReplace: true, seedSearchStringFromSelection: seedSearchStringFromSelection, - seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection, + seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).seedSearchStringFromSelection, shouldFocus: shouldFocus, shouldAnimate: true, updateSearchScope: false diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index 4245ed4343f23..9a399ea3aebc1 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -192,8 +192,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this.updateAccessibilitySupport(); } - if (e.contribInfo) { - const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop; + if (e.hasChanged(EditorOption.find)) { + const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop; if (addExtraSpaceOnTop && !this._viewZone) { this._viewZone = new FindWidgetViewZone(0); this._showViewZone(); @@ -239,7 +239,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas })); this._codeEditor.addOverlayWidget(this); - if (this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop) { + if (this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop) { this._viewZone = new FindWidgetViewZone(0); // Put it before the first line then users can scroll beyond the first line. } @@ -467,7 +467,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas const selection = this._codeEditor.getSelection(); const isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false; - if (isSelection && this._codeEditor.getConfiguration().contribInfo.find.autoFindInSelection) { + if (isSelection && this._codeEditor.getOption(EditorOption.find).autoFindInSelection) { this._toggleSelectionFind.checked = true; } else { this._toggleSelectionFind.checked = false; @@ -488,7 +488,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._codeEditor.layoutOverlayWidget(this); let adjustEditorScrollTop = true; - if (this._codeEditor.getConfiguration().contribInfo.find.seedSearchStringFromSelection && selection) { + if (this._codeEditor.getOption(EditorOption.find).seedSearchStringFromSelection && selection) { const domNode = this._codeEditor.getDomNode(); if (domNode) { const editorCoords = dom.getDomNodePagePosition(domNode); @@ -535,7 +535,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas } private _layoutViewZone() { - const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop; + const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop; if (!addExtraSpaceOnTop) { this._removeViewZone(); @@ -563,7 +563,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas return; } - const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop; + const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop; if (!addExtraSpaceOnTop) { return; diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 648461cd08249..4ab5ce4decc7a 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -89,8 +89,8 @@ export class FoldingController extends Disposable implements IEditorContribution this.editor = editor; const options = this.editor.getOptions(); this._isEnabled = options.get(EditorOption.folding); - this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover'; - this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation'; + this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover'; + this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation'; this.foldingModel = null; this.hiddenRangeModel = null; @@ -110,7 +110,7 @@ export class FoldingController extends Disposable implements IEditorContribution this._register(this.editor.onDidChangeModel(() => this.onModelChanged())); this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.contribInfo || e.hasChanged(EditorOption.folding)) { + if (e.hasChanged(EditorOption.folding) || e.hasChanged(EditorOption.showFoldingControls) || e.hasChanged(EditorOption.foldingStrategy)) { let oldIsEnabled = this._isEnabled; const options = this.editor.getOptions(); this._isEnabled = options.get(EditorOption.folding); @@ -119,13 +119,13 @@ export class FoldingController extends Disposable implements IEditorContribution this.onModelChanged(); } let oldShowFoldingControls = this._autoHideFoldingControls; - this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover'; + this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover'; if (oldShowFoldingControls !== this._autoHideFoldingControls) { this.foldingDecorationProvider.autoHideFoldingControls = this._autoHideFoldingControls; this.onModelContentChanged(); } let oldUseFoldingProviders = this._useFoldingProviders; - this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation'; + this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation'; if (oldUseFoldingProviders !== this._useFoldingProviders) { this.onFoldingStrategyChanged(); } diff --git a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts index baad3f0bb1713..6e29856e81ef1 100644 --- a/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts +++ b/src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts @@ -30,6 +30,7 @@ import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefiniti import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState'; import { ISymbolNavigationService } from 'vs/editor/contrib/goToDefinition/goToDefinitionResultsNavigation'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class DefinitionActionConfig { @@ -137,7 +138,7 @@ export class DefinitionAction extends EditorAction { const msg = model.getAriaMessage(); alert(msg); - const { gotoLocation } = editor.getConfiguration().contribInfo; + const gotoLocation = editor.getOption(EditorOption.gotoLocation); if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) { this._openInPeek(editorService, editor, model); diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index e03c5464e516f..b89e96001d37a 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -75,7 +75,7 @@ export class ModesHoverController implements IEditorContribution { this._hookEvents(); this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.contribInfo) { + if (e.hasChanged(EditorOption.hover)) { this._hideWidgets(); this._unhookEvents(); this._hookEvents(); @@ -86,7 +86,7 @@ export class ModesHoverController implements IEditorContribution { private _hookEvents(): void { const hideWidgetsEventHandler = () => this._hideWidgets(); - const hoverOpts = this._editor.getConfiguration().contribInfo.hover; + const hoverOpts = this._editor.getOption(EditorOption.hover); this._isHoverEnabled = hoverOpts.enabled; this._isHoverSticky = hoverOpts.sticky; if (this._isHoverEnabled) { @@ -147,7 +147,6 @@ export class ModesHoverController implements IEditorContribution { } private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void { - // const this._editor.getConfiguration().contribInfo.hover.sticky; let targetType = mouseEvent.target.type; if (this._isMouseDown && this._hoverClicked && this.contentWidget.isColorPickerVisible()) { diff --git a/src/vs/editor/contrib/hover/modesContentHover.ts b/src/vs/editor/contrib/hover/modesContentHover.ts index d42f5153a1d09..76bb60097fd1e 100644 --- a/src/vs/editor/contrib/hover/modesContentHover.ts +++ b/src/vs/editor/contrib/hover/modesContentHover.ts @@ -37,6 +37,7 @@ import { QuickFixAction, QuickFixController } from 'vs/editor/contrib/codeAction import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const $ = dom.$; @@ -222,7 +223,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget { result => this._withResult(result, true), null, result => this._withResult(result, false), - this._editor.getConfiguration().contribInfo.hover.delay + this._editor.getOption(EditorOption.hover).delay ); this._register(dom.addStandardDisposableListener(this.getDomNode(), dom.EventType.FOCUS, () => { @@ -234,7 +235,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget { dom.removeClass(this.getDomNode(), 'colorpicker-hover'); })); this._register(editor.onDidChangeConfiguration((e) => { - this._hoverOperation.setHoverTime(this._editor.getConfiguration().contribInfo.hover.delay); + this._hoverOperation.setHoverTime(this._editor.getOption(EditorOption.hover).delay); })); } diff --git a/src/vs/editor/contrib/parameterHints/parameterHintsModel.ts b/src/vs/editor/contrib/parameterHints/parameterHintsModel.ts index 21cf0393170ea..6c3c9cb9ae628 100644 --- a/src/vs/editor/contrib/parameterHints/parameterHintsModel.ts +++ b/src/vs/editor/contrib/parameterHints/parameterHintsModel.ts @@ -12,6 +12,7 @@ import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursor import { CharacterSet } from 'vs/editor/common/core/characterClassifier'; import * as modes from 'vs/editor/common/modes'; import { provideSignatureHelp } from 'vs/editor/contrib/parameterHints/provideSignatureHelp'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface TriggerContext { readonly triggerKind: modes.SignatureHelpTriggerKind; @@ -125,7 +126,7 @@ export class ParameterHintsModel extends Disposable { const length = this.state.hints.signatures.length; const activeSignature = this.state.hints.activeSignature; const last = (activeSignature % length) === (length - 1); - const cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle; + const cycle = this.editor.getOption(EditorOption.parameterHints).cycle; // If there is only one signature, or we're on last signature of list if ((length < 2 || last) && !cycle) { @@ -144,7 +145,7 @@ export class ParameterHintsModel extends Disposable { const length = this.state.hints.signatures.length; const activeSignature = this.state.hints.activeSignature; const first = activeSignature === 0; - const cycle = this.editor.getConfiguration().contribInfo.parameterHints.cycle; + const cycle = this.editor.getOption(EditorOption.parameterHints).cycle; // If there is only one signature, or we're on first signature of list if ((length < 2 || first) && !cycle) { @@ -271,7 +272,7 @@ export class ParameterHintsModel extends Disposable { } private onEditorConfigurationChange(): void { - this.triggerOnType = this.editor.getConfiguration().contribInfo.parameterHints.enabled; + this.triggerOnType = this.editor.getOption(EditorOption.parameterHints).enabled; if (!this.triggerOnType) { this.cancel(); diff --git a/src/vs/editor/contrib/suggest/completionModel.ts b/src/vs/editor/contrib/suggest/completionModel.ts index 9a806ddf3dee0..0796b12bb9d9f 100644 --- a/src/vs/editor/contrib/suggest/completionModel.ts +++ b/src/vs/editor/contrib/suggest/completionModel.ts @@ -6,7 +6,7 @@ import { fuzzyScore, fuzzyScoreGracefulAggressive, FuzzyScorer, FuzzyScore, anyScore } from 'vs/base/common/filters'; import { CompletionItemProvider, CompletionItemKind } from 'vs/editor/common/modes'; import { CompletionItem } from './suggest'; -import { InternalSuggestOptions, EDITOR_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { InternalSuggestOptions } from 'vs/editor/common/config/editorOptions'; import { WordDistance } from 'vs/editor/contrib/suggest/wordDistance'; import { CharCode } from 'vs/base/common/charCode'; import { compareIgnoreCase } from 'vs/base/common/strings'; @@ -60,7 +60,7 @@ export class CompletionModel { column: number, lineContext: LineContext, wordDistance: WordDistance, - options: InternalSuggestOptions = EDITOR_DEFAULTS.contribInfo.suggest + options: InternalSuggestOptions ) { this._items = items; this._column = column; diff --git a/src/vs/editor/contrib/suggest/suggestModel.ts b/src/vs/editor/contrib/suggest/suggestModel.ts index 0d0bbe19f4d44..bd5416bddc600 100644 --- a/src/vs/editor/contrib/suggest/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/suggestModel.ts @@ -278,7 +278,7 @@ export class SuggestModel implements IDisposable { if (this._state === State.Idle) { - if (this._editor.getConfiguration().contribInfo.quickSuggestions === false) { + if (this._editor.getOption(EditorOption.quickSuggestions) === false) { // not enabled return; } @@ -288,7 +288,7 @@ export class SuggestModel implements IDisposable { return; } - if (this._editor.getConfiguration().contribInfo.suggest.snippetsPreventQuickSuggestions && SnippetController2.get(this._editor).isInSnippet()) { + if (this._editor.getOption(EditorOption.suggest).snippetsPreventQuickSuggestions && SnippetController2.get(this._editor).isInSnippet()) { // no quick suggestion when in snippet mode return; } @@ -308,7 +308,7 @@ export class SuggestModel implements IDisposable { const model = this._editor.getModel(); const pos = this._editor.getPosition(); // validate enabled now - const { quickSuggestions } = this._editor.getConfiguration().contribInfo; + const quickSuggestions = this._editor.getOption(EditorOption.quickSuggestions); if (quickSuggestions === false) { return; } else if (quickSuggestions === true) { @@ -388,10 +388,10 @@ export class SuggestModel implements IDisposable { this._requestToken = new CancellationTokenSource(); // kind filter and snippet sort rules - const { contribInfo } = this._editor.getConfiguration(); + const suggestOptions = this._editor.getOption(EditorOption.suggest); let itemKindFilter = new Set(); let snippetSortOrder = SnippetSortOrder.Inline; - switch (contribInfo.suggest.snippets) { + switch (suggestOptions.snippets) { case 'top': snippetSortOrder = SnippetSortOrder.Top; break; @@ -408,9 +408,9 @@ export class SuggestModel implements IDisposable { } // kind filter - for (const key in contribInfo.suggest.filteredTypes) { + for (const key in suggestOptions.filteredTypes) { const kind = completionKindFromString(key, true); - if (typeof kind !== 'undefined' && contribInfo.suggest.filteredTypes[key] === false) { + if (typeof kind !== 'undefined' && suggestOptions.filteredTypes[key] === false) { itemKindFilter.add(kind); } } @@ -450,7 +450,7 @@ export class SuggestModel implements IDisposable { characterCountDelta: ctx.column - this._context!.column }, wordDistance, - this._editor.getConfiguration().contribInfo.suggest + this._editor.getOption(EditorOption.suggest) ); // store containers so that they can be disposed later diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 4bb095d5d419a..3a9a8eec06f57 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -16,7 +16,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser'; import { Context as SuggestContext, CompletionItem } from './suggest'; import { CompletionModel } from './completionModel'; @@ -125,9 +125,10 @@ class Renderer implements IListRenderer const configureFont = () => { const configuration = this.editor.getConfiguration(); + const options = this.editor.getOptions(); const fontFamily = configuration.fontInfo.fontFamily; - const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize; - const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight; + const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize; + const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight; const fontWeight = configuration.fontInfo.fontWeight; const fontSizePx = `${fontSize}px`; const lineHeightPx = `${lineHeight}px`; @@ -145,7 +146,7 @@ class Renderer implements IListRenderer configureFont(); data.disposables.add(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) - .filter(e => e.fontInfo || e.contribInfo) + .filter(e => e.fontInfo || e.hasChanged(EditorOption.suggestFontSize) || e.hasChanged(EditorOption.suggestLineHeight)) .on(configureFont, null)); return data; @@ -390,9 +391,10 @@ class SuggestionDetails { private configureFont() { const configuration = this.editor.getConfiguration(); + const options = this.editor.getOptions(); const fontFamily = configuration.fontInfo.fontFamily; - const fontSize = configuration.contribInfo.suggestFontSize || configuration.fontInfo.fontSize; - const lineHeight = configuration.contribInfo.suggestLineHeight || configuration.fontInfo.lineHeight; + const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize; + const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight; const fontWeight = configuration.fontInfo.fontWeight; const fontSizePx = `${fontSize}px`; const lineHeightPx = `${lineHeight}px`; @@ -500,7 +502,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate toggleClass(this.element, 'no-icons', !this.editor.getConfiguration().contribInfo.suggest.showIcons); + const applyIconStyle = () => toggleClass(this.element, 'no-icons', !this.editor.getOption(EditorOption.suggest).showIcons); applyIconStyle(); let renderer = instantiationService.createInstance(Renderer, this, this.editor, triggerKeybindingLabel); @@ -521,7 +523,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate this.onListSelection(e))); this.toDispose.add(this.list.onFocusChange(e => this.onListFocus(e))); this.toDispose.add(this.editor.onDidChangeCursorSelection(() => this.onCursorSelectionChanged())); - this.toDispose.add(this.editor.onDidChangeConfiguration(e => e.contribInfo && applyIconStyle())); + this.toDispose.add(this.editor.onDidChangeConfiguration(e => e.hasChanged(EditorOption.suggest) && applyIconStyle())); this.suggestWidgetVisible = SuggestContext.Visible.bindTo(contextKeyService); @@ -1051,7 +1053,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate e.contribInfo && this._update())); + this._register(this._editor.onDidChangeConfiguration(e => e.hasChanged(EditorOption.tabCompletion) && this._update())); this._update(); } @@ -34,7 +35,7 @@ export class WordContextKey extends Disposable { private _update(): void { // only update this when tab completions are enabled - const enabled = this._editor.getConfiguration().contribInfo.tabCompletion === 'on'; + const enabled = this._editor.getOption(EditorOption.tabCompletion) === 'on'; if (this._enabled === enabled) { return; } diff --git a/src/vs/editor/contrib/suggest/wordDistance.ts b/src/vs/editor/contrib/suggest/wordDistance.ts index c076d21a0b364..5b7ea2cb945fb 100644 --- a/src/vs/editor/contrib/suggest/wordDistance.ts +++ b/src/vs/editor/contrib/suggest/wordDistance.ts @@ -10,6 +10,7 @@ import { IPosition } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { CompletionItem, CompletionItemKind } from 'vs/editor/common/modes'; import { BracketSelectionRangeProvider } from 'vs/editor/contrib/smartSelect/bracketSelections'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export abstract class WordDistance { @@ -19,7 +20,7 @@ export abstract class WordDistance { static create(service: IEditorWorkerService, editor: ICodeEditor): Promise { - if (!editor.getConfiguration().contribInfo.suggest.localityBonus) { + if (!editor.getOption(EditorOption.suggest).localityBonus) { return Promise.resolve(WordDistance.None); } diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index a105d7b2c293b..fe76a97d60e1f 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -186,8 +186,8 @@ suite('Common Editor Config', () => { }); let config = new TestConfiguration({ hover: hoverOptions }); - assert.equal(config.editor.contribInfo.hover.enabled, true); + assert.equal(config.options.get(EditorOption.hover).enabled, true); config.updateOptions({ hover: { enabled: false } }); - assert.equal(config.editor.contribInfo.hover.enabled, false); + assert.equal(config.options.get(EditorOption.hover).enabled, false); }); }); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 8c02338f8dacd..ee94ff2b4bcb1 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2611,7 +2611,7 @@ declare namespace monaco.editor { /** * Max suggestions to show in suggestions. Defaults to 12. */ - maxVisibleSuggestions?: boolean; + maxVisibleSuggestions?: number; /** * Names of suggestion types to filter. */ @@ -2625,11 +2625,10 @@ declare namespace monaco.editor { multiple?: 'peek' | 'gotoAndPeek' | 'goto'; } - /** - * Configuration map for codeActionsOnSave - */ - export interface ICodeActionsOnSaveOptions { - [kind: string]: boolean; + export interface IQuickSuggestionsOptions { + other: boolean; + comments: boolean; + strings: boolean; } /** @@ -2921,11 +2920,7 @@ declare namespace monaco.editor { * Enable quick suggestions (shadow suggestions) * Defaults to true. */ - quickSuggestions?: boolean | { - other: boolean; - comments: boolean; - strings: boolean; - }; + quickSuggestions?: boolean | IQuickSuggestionsOptions; /** * Quick suggestions show delay (in ms) * Defaults to 10 (ms) @@ -3001,10 +2996,6 @@ declare namespace monaco.editor { * Syntax highlighting is copied. */ copyWithSyntaxHighlighting?: boolean; - /** - * Enable word based suggestions. Defaults to 'true' - */ - wordBasedSuggestions?: boolean; /** * The history mode for suggestions. */ @@ -3022,7 +3013,7 @@ declare namespace monaco.editor { /** * Enable tab completion. */ - tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets'; + tabCompletion?: 'on' | 'off' | 'onlySnippets'; /** * Enable selection highlight. * Defaults to true. @@ -3042,10 +3033,6 @@ declare namespace monaco.editor { * Control the behavior and rendering of the code action lightbulb. */ lightbulb?: IEditorLightbulbOptions; - /** - * Code action kinds to be run on save. - */ - codeActionsOnSave?: ICodeActionsOnSaveOptions; /** * Timeout for running code actions on save. */ @@ -3262,59 +3249,6 @@ declare namespace monaco.editor { UnderlineThin = 6 } - export interface InternalEditorFindOptions { - readonly seedSearchStringFromSelection: boolean; - readonly autoFindInSelection: boolean; - readonly addExtraSpaceOnTop: boolean; - } - - export interface InternalEditorHoverOptions { - readonly enabled: boolean; - readonly delay: number; - readonly sticky: boolean; - } - - export interface InternalGoToLocationOptions { - readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; - } - - export interface InternalSuggestOptions { - readonly filterGraceful: boolean; - readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; - readonly snippetsPreventQuickSuggestions: boolean; - readonly localityBonus: boolean; - readonly shareSuggestSelections: boolean; - readonly showIcons: boolean; - readonly maxVisibleSuggestions: number; - readonly filteredTypes: Record; - } - - export interface InternalParameterHintOptions { - readonly enabled: boolean; - readonly cycle: boolean; - } - - export interface EditorContribOptions { - readonly hover: InternalEditorHoverOptions; - readonly quickSuggestions: boolean | { - other: boolean; - comments: boolean; - strings: boolean; - }; - readonly parameterHints: InternalParameterHintOptions; - readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; - readonly suggestFontSize: number; - readonly suggestLineHeight: number; - readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; - readonly suggest: InternalSuggestOptions; - readonly gotoLocation: InternalGoToLocationOptions; - readonly foldingStrategy: 'auto' | 'indentation'; - readonly showFoldingControls: 'always' | 'mouseover'; - readonly find: InternalEditorFindOptions; - readonly codeActionsOnSave: ICodeActionsOnSaveOptions; - readonly codeActionsOnSaveTimeout: number; - } - /** * Internal configuration options (transformed or computed) for the editor. */ @@ -3323,7 +3257,6 @@ declare namespace monaco.editor { readonly pixelRatio: number; readonly lineHeight: number; readonly fontInfo: FontInfo; - readonly contribInfo: EditorContribOptions; } /** @@ -3334,7 +3267,6 @@ declare namespace monaco.editor { readonly pixelRatio: boolean; readonly lineHeight: boolean; readonly fontInfo: boolean; - readonly contribInfo: boolean; } export interface IEnvironmentalOptions { @@ -3383,6 +3315,14 @@ declare namespace monaco.editor { readonly maxColumn: number; } + export interface InternalEditorHoverOptions { + readonly enabled: boolean; + readonly delay: number; + readonly sticky: boolean; + } + + export type ValidQuickSuggestionsOptions = boolean | Readonly>; + export type ValidEditorLightbulbOptions = Required; export interface InternalEditorScrollbarOptions { @@ -3399,6 +3339,34 @@ declare namespace monaco.editor { readonly verticalSliderSize: number; } + export type ValidSuggestOptions = Readonly>; + + export interface InternalSuggestOptions { + readonly filterGraceful: boolean; + readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; + readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + readonly shareSuggestSelections: boolean; + readonly showIcons: boolean; + readonly maxVisibleSuggestions: number; + readonly filteredTypes: Record; + } + + export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; + } + + export interface InternalEditorFindOptions { + readonly seedSearchStringFromSelection: boolean; + readonly autoFindInSelection: boolean; + readonly addExtraSpaceOnTop: boolean; + } + + export interface InternalGoToLocationOptions { + readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; + } + /** * A description for the overview ruler position. */ @@ -3542,66 +3510,78 @@ declare namespace monaco.editor { emptySelectionClipboard = 20, extraEditorClassName = 21, fastScrollSensitivity = 22, - fixedOverflowWidgets = 23, - folding = 24, - fontLigatures = 25, - formatOnPaste = 26, - formatOnType = 27, - glyphMargin = 28, - hideCursorInOverviewRuler = 29, - highlightActiveIndentGuide = 30, - inDiffEditor = 31, - lightbulb = 32, - lineDecorationsWidth = 33, - lineNumbers = 34, - lineNumbersMinChars = 35, - links = 36, - matchBrackets = 37, - minimap = 38, - mouseStyle = 39, - mouseWheelScrollSensitivity = 40, - mouseWheelZoom = 41, - multiCursorMergeOverlapping = 42, - multiCursorModifier = 43, - occurrencesHighlight = 44, - overviewRulerBorder = 45, - overviewRulerLanes = 46, - quickSuggestionsDelay = 47, - readOnly = 48, - renderControlCharacters = 49, - renderIndentGuides = 50, - renderFinalNewline = 51, - renderLineHighlight = 52, - renderWhitespace = 53, - revealHorizontalRightPadding = 54, - roundedSelection = 55, - rulers = 56, - scrollbar = 57, - scrollBeyondLastColumn = 58, - scrollBeyondLastLine = 59, - selectionClipboard = 60, - selectionHighlight = 61, - selectOnLineNumbers = 62, - showUnused = 63, - smoothScrolling = 64, - stopRenderingLineAfter = 65, - suggestOnTriggerCharacters = 66, - useTabStops = 67, - wordBasedSuggestions = 68, - wordSeparators = 69, - wordWrap = 70, - wordWrapBreakAfterCharacters = 71, - wordWrapBreakBeforeCharacters = 72, - wordWrapBreakObtrusiveCharacters = 73, - wordWrapColumn = 74, - wordWrapMinified = 75, - wrappingIndent = 76, - ariaLabel = 77, - disableMonospaceOptimizations = 78, - editorClassName = 79, - tabFocusMode = 80, - layoutInfo = 81, - wrappingInfo = 82 + find = 23, + fixedOverflowWidgets = 24, + folding = 25, + foldingStrategy = 26, + fontLigatures = 27, + formatOnPaste = 28, + formatOnType = 29, + glyphMargin = 30, + gotoLocation = 31, + hideCursorInOverviewRuler = 32, + highlightActiveIndentGuide = 33, + hover = 34, + inDiffEditor = 35, + lightbulb = 36, + lineDecorationsWidth = 37, + lineNumbers = 38, + lineNumbersMinChars = 39, + links = 40, + matchBrackets = 41, + minimap = 42, + mouseStyle = 43, + mouseWheelScrollSensitivity = 44, + mouseWheelZoom = 45, + multiCursorMergeOverlapping = 46, + multiCursorModifier = 47, + occurrencesHighlight = 48, + overviewRulerBorder = 49, + overviewRulerLanes = 50, + parameterHints = 51, + quickSuggestions = 52, + quickSuggestionsDelay = 53, + readOnly = 54, + renderControlCharacters = 55, + renderIndentGuides = 56, + renderFinalNewline = 57, + renderLineHighlight = 58, + renderWhitespace = 59, + revealHorizontalRightPadding = 60, + roundedSelection = 61, + rulers = 62, + scrollbar = 63, + scrollBeyondLastColumn = 64, + scrollBeyondLastLine = 65, + selectionClipboard = 66, + selectionHighlight = 67, + selectOnLineNumbers = 68, + showFoldingControls = 69, + showUnused = 70, + snippetSuggestions = 71, + smoothScrolling = 72, + stopRenderingLineAfter = 73, + suggestFontSize = 74, + suggestLineHeight = 75, + suggestOnTriggerCharacters = 76, + suggestSelection = 77, + tabCompletion = 78, + useTabStops = 79, + wordSeparators = 80, + wordWrap = 81, + wordWrapBreakAfterCharacters = 82, + wordWrapBreakBeforeCharacters = 83, + wordWrapBreakObtrusiveCharacters = 84, + wordWrapColumn = 85, + wordWrapMinified = 86, + wrappingIndent = 87, + ariaLabel = 88, + disableMonospaceOptimizations = 89, + editorClassName = 90, + tabFocusMode = 91, + suggest = 92, + layoutInfo = 93, + wrappingInfo = 94 } export const EditorOptions: { @@ -3628,14 +3608,18 @@ declare namespace monaco.editor { emptySelectionClipboard: IEditorOption; extraEditorClassName: IEditorOption; fastScrollSensitivity: IEditorOption; + find: IEditorOption; fixedOverflowWidgets: IEditorOption; folding: IEditorOption; + foldingStrategy: IEditorOption; fontLigatures: IEditorOption; formatOnPaste: IEditorOption; formatOnType: IEditorOption; glyphMargin: IEditorOption; + gotoLocation: IEditorOption; hideCursorInOverviewRuler: IEditorOption; highlightActiveIndentGuide: IEditorOption; + hover: IEditorOption; inDiffEditor: IEditorOption; lightbulb: IEditorOption; lineDecorationsWidth: IEditorOption; @@ -3652,6 +3636,8 @@ declare namespace monaco.editor { occurrencesHighlight: IEditorOption; overviewRulerBorder: IEditorOption; overviewRulerLanes: IEditorOption; + parameterHints: IEditorOption; + quickSuggestions: IEditorOption; quickSuggestionsDelay: IEditorOption; readOnly: IEditorOption; renderControlCharacters: IEditorOption; @@ -3668,12 +3654,17 @@ declare namespace monaco.editor { selectionClipboard: IEditorOption; selectionHighlight: IEditorOption; selectOnLineNumbers: IEditorOption; + showFoldingControls: IEditorOption; showUnused: IEditorOption; + snippetSuggestions: IEditorOption; smoothScrolling: IEditorOption; stopRenderingLineAfter: IEditorOption; + suggestFontSize: IEditorOption; + suggestLineHeight: IEditorOption; suggestOnTriggerCharacters: IEditorOption; + suggestSelection: IEditorOption; + tabCompletion: IEditorOption; useTabStops: IEditorOption; - wordBasedSuggestions: IEditorOption; wordSeparators: IEditorOption; wordWrap: IEditorOption; wordWrapBreakAfterCharacters: IEditorOption; @@ -3686,6 +3677,7 @@ declare namespace monaco.editor { disableMonospaceOptimizations: IEditorOption; editorClassName: IEditorOption; tabFocusMode: IEditorOption; + suggest: IEditorOption; layoutInfo: IEditorOption; wrappingInfo: IEditorOption; }; diff --git a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts index 1bd75108c5af1..8827222e22cac 100644 --- a/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/browser/mainThreadSaveParticipant.ts @@ -10,7 +10,6 @@ import { IActiveCodeEditor } from 'vs/editor/browser/editorBrowser'; import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { trimTrailingWhitespace } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand'; -import { ICodeActionsOnSaveOptions } from 'vs/editor/common/config/editorOptions'; import { EditOperation } from 'vs/editor/common/core/editOperation'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -34,6 +33,10 @@ import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textF import { ISaveParticipant, SaveReason, IResolvedTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles'; import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../common/extHost.protocol'; +export interface ICodeActionsOnSaveOptions { + [kind: string]: boolean; +} + export interface ISaveParticipantParticipant extends ISaveParticipant { // progressMessage: string; } diff --git a/src/vs/workbench/contrib/snippets/browser/tabCompletion.ts b/src/vs/workbench/contrib/snippets/browser/tabCompletion.ts index 569598138e8e3..20f06e31a9e8f 100644 --- a/src/vs/workbench/contrib/snippets/browser/tabCompletion.ts +++ b/src/vs/workbench/contrib/snippets/browser/tabCompletion.ts @@ -19,6 +19,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { Snippet } from './snippetsFile'; import { SnippetCompletion } from './snippetCompletionProvider'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class TabCompletionController implements editorCommon.IEditorContribution { @@ -42,7 +43,7 @@ export class TabCompletionController implements editorCommon.IEditorContribution ) { this._hasSnippets = TabCompletionController.ContextKey.bindTo(contextKeyService); this._configListener = this._editor.onDidChangeConfiguration(e => { - if (e.contribInfo) { + if (e.hasChanged(EditorOption.tabCompletion)) { this._update(); } }); @@ -59,7 +60,7 @@ export class TabCompletionController implements editorCommon.IEditorContribution } private _update(): void { - const enabled = this._editor.getConfiguration().contribInfo.tabCompletion === 'onlySnippets'; + const enabled = this._editor.getOption(EditorOption.tabCompletion) === 'onlySnippets'; if (this._enabled !== enabled) { this._enabled = enabled; if (!this._enabled) { From 33f336c612e30d779aaa71d28effbb36b3ff577e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 5 Sep 2019 11:16:09 +0200 Subject: [PATCH 085/204] Revert "Revert "Fix rawSearchService to handle maxResults=0 correctly"" This reverts commit 191ecb92f865b05d76d21b197d2a57e132797e66. --- .../services/search/node/rawSearchService.ts | 2 +- .../search/test/node/rawSearchService.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/services/search/node/rawSearchService.ts b/src/vs/workbench/services/search/node/rawSearchService.ts index 2a27d205aac14..c0d0e6d635861 100644 --- a/src/vs/workbench/services/search/node/rawSearchService.ts +++ b/src/vs/workbench/services/search/node/rawSearchService.ts @@ -254,7 +254,7 @@ export class SearchService implements IRawSearchService { const query = prepareQuery(config.filePattern || ''); const compare = (matchA: IRawFileMatch, matchB: IRawFileMatch) => compareItemsByScore(matchA, matchB, query, true, FileMatchItemAccessor, scorerCache); - const maxResults = config.maxResults || Number.MAX_VALUE; + const maxResults = typeof config.maxResults === 'number' ? config.maxResults : Number.MAX_VALUE; return arrays.topAsync(results, compare, maxResults, 10000, token); } diff --git a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts index 4060adff5f03e..c0a85168b8029 100644 --- a/src/vs/workbench/services/search/test/node/rawSearchService.test.ts +++ b/src/vs/workbench/services/search/test/node/rawSearchService.test.ts @@ -185,6 +185,25 @@ suite('RawSearchService', () => { assert.strictEqual(result.results.length, 1, 'Result'); }); + test('Handles maxResults=0 correctly', async function () { + this.timeout(testTimeout); + const service = new RawSearchService(); + + const query: IFileQuery = { + type: QueryType.File, + folderQueries: MULTIROOT_QUERIES, + maxResults: 0, + sortByScore: true, + includePattern: { + '*.txt': true, + '*.js': true + }, + }; + + const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query)); + assert.strictEqual(result.results.length, 0, 'Result'); + }); + test('Multi-root with include pattern and exists', async function () { this.timeout(testTimeout); const service = new RawSearchService(); From 3fa5e013d12bdc4baf4e61880081985e2b4ef0b0 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 11:18:08 +0200 Subject: [PATCH 086/204] Show Create tasks.json file from template in workspaces Fixes #80221 --- src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts index 2f8360d29be2c..9fc55917fc8ca 100644 --- a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts +++ b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts @@ -2152,7 +2152,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer return taskPromise.then((taskMap) => { type EntryType = (IQuickPickItem & { task: Task; }) | (IQuickPickItem & { folder: IWorkspaceFolder; }); let entries: QuickPickInput[] = []; - if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) { + if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY) { let tasks = taskMap.all(); let needsCreateOrOpen: boolean = true; if (tasks.length > 0) { From 9e3942707e2743f313119122ec2fe71c8e6aa430 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 11:24:36 +0200 Subject: [PATCH 087/204] Add test for eventing --- .../test/common/config/commonEditorConfig.test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index fe76a97d60e1f..f2ab0bbbd41e3 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorHoverOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOption, IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; @@ -190,4 +190,15 @@ suite('Common Editor Config', () => { config.updateOptions({ hover: { enabled: false } }); assert.equal(config.options.get(EditorOption.hover).enabled, false); }); + + test('does not emit event when nothing changes', () => { + const config = new TestConfiguration({ glyphMargin: true, roundedSelection: false }); + let event: IConfigurationChangedEvent | null = null; + config.onDidChange(e => event = e); + assert.equal(config.options.get(EditorOption.glyphMargin), true); + + config.updateOptions({ glyphMargin: true }); + config.updateOptions({ roundedSelection: false }); + assert.equal(event, null); + }); }); From cc4bc4e17e46cb1eecfff1d991cece5e79006140 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 5 Sep 2019 11:40:20 +0200 Subject: [PATCH 088/204] debt - clean up strict init --- src/vs/workbench/common/editor/editorGroup.ts | 8 ++-- .../quickopen/browser/commandsHandler.ts | 2 +- src/vs/workbench/electron-browser/window.ts | 10 ++--- .../services/history/browser/history.ts | 38 ++++++++++--------- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/vs/workbench/common/editor/editorGroup.ts b/src/vs/workbench/common/editor/editorGroup.ts index 3eb62c882cd1d..a1447c830ca6b 100644 --- a/src/vs/workbench/common/editor/editorGroup.ts +++ b/src/vs/workbench/common/editor/editorGroup.ts @@ -88,7 +88,7 @@ export class EditorGroup extends Disposable { //#endregion - private _id!: GroupIdentifier; + private _id: GroupIdentifier; get id(): GroupIdentifier { return this._id; } private editors: EditorInput[] = []; @@ -109,7 +109,7 @@ export class EditorGroup extends Disposable { super(); if (isSerializedEditorGroup(labelOrSerializedGroup)) { - this.deserialize(labelOrSerializedGroup); + this._id = this.deserialize(labelOrSerializedGroup); } else { this._id = EditorGroup.IDS++; } @@ -661,7 +661,7 @@ export class EditorGroup extends Disposable { }; } - private deserialize(data: ISerializedEditorGroup): void { + private deserialize(data: ISerializedEditorGroup): number { const registry = Registry.as(Extensions.EditorInputFactories); if (typeof data.id === 'number') { @@ -694,5 +694,7 @@ export class EditorGroup extends Disposable { if (typeof data.preview === 'number') { this.preview = this.editors[data.preview]; } + + return this._id; } } diff --git a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts index 9bfb056d4edc1..a0090bae84487 100644 --- a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts @@ -62,7 +62,7 @@ class CommandsHistory extends Disposable { private static readonly PREF_KEY_CACHE = 'commandPalette.mru.cache'; private static readonly PREF_KEY_COUNTER = 'commandPalette.mru.counter'; - private commandHistoryLength!: number; + private commandHistoryLength = 0; constructor( @IStorageService private readonly storageService: IStorageService, diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index da4b46c39917d..68abd9e52f51f 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -71,7 +71,6 @@ const TextInputActions: IAction[] = [ export class ElectronWindow extends Disposable { private touchBarMenu: IMenu | undefined; - private touchBarUpdater: RunOnceScheduler | undefined; private readonly touchBarDisposables = this._register(new DisposableStore()); private lastInstalledTouchedBar: ICommandAction[][] | undefined; @@ -394,16 +393,15 @@ export class ElectronWindow extends Disposable { this.touchBarMenu = undefined; // Create new (delayed) - this.touchBarUpdater = new RunOnceScheduler(() => this.doUpdateTouchbarMenu(), 300); - this.touchBarDisposables.add(this.touchBarUpdater); - this.touchBarUpdater.schedule(); + const scheduler: RunOnceScheduler = this.touchBarDisposables.add(new RunOnceScheduler(() => this.doUpdateTouchbarMenu(scheduler), 300)); + scheduler.schedule(); } - private doUpdateTouchbarMenu(): void { + private doUpdateTouchbarMenu(scheduler: RunOnceScheduler): void { if (!this.touchBarMenu) { this.touchBarMenu = this.editorService.invokeWithinEditorContext(accessor => this.menuService.createMenu(MenuId.TouchBarContext, accessor.get(IContextKeyService))); this.touchBarDisposables.add(this.touchBarMenu); - this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => this.touchBarUpdater!.schedule())); + this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => scheduler.schedule())); } const actions: Array = []; diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 4e092146cc5fd..c70804f05681f 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -120,8 +120,9 @@ export class HistoryService extends Disposable implements IHistoryService { private lastEditLocation: IStackEntry | undefined; - private history: Array | undefined; + private history!: Array; private recentlyClosedFiles: IRecentlyClosedFile[]; + private loaded: boolean; private resourceFilter: ResourceGlobMatcher; private fileInputFactory: IFileInputFactory; @@ -154,6 +155,7 @@ export class HistoryService extends Disposable implements IHistoryService { this.lastIndex = -1; this.stack = []; this.recentlyClosedFiles = []; + this.loaded = false; this.resourceFilter = this._register(instantiationService.createInstance( ResourceGlobMatcher, (root?: URI) => this.getExcludes(root), @@ -487,17 +489,17 @@ export class HistoryService extends Disposable implements IHistoryService { return; } + this.ensureHistoryLoaded(); + const historyInput = this.preferResourceInput(input); // Remove any existing entry and add to the beginning this.removeFromHistory(input); - - const history = this.ensureHistoryLoaded(); - history.unshift(historyInput); + this.history.unshift(historyInput); // Respect max entries setting - if (history.length > HistoryService.MAX_HISTORY_ITEMS) { - this.clearOnEditorDispose(history.pop()!, this.editorHistoryListeners); + if (this.history.length > HistoryService.MAX_HISTORY_ITEMS) { + this.clearOnEditorDispose(this.history.pop()!, this.editorHistoryListeners); } // Remove this from the history unless the history input is a resource @@ -553,9 +555,9 @@ export class HistoryService extends Disposable implements IHistoryService { } private removeExcludedFromHistory(): void { - const history = this.ensureHistoryLoaded(); + this.ensureHistoryLoaded(); - this.history = history.filter(e => { + this.history = this.history.filter(e => { const include = this.include(e); // Cleanup any listeners associated with the input when removing from history @@ -568,9 +570,9 @@ export class HistoryService extends Disposable implements IHistoryService { } private removeFromHistory(arg1: IEditorInput | IResourceInput | FileChangesEvent): void { - const history = this.ensureHistoryLoaded(); + this.ensureHistoryLoaded(); - this.history = history.filter(e => { + this.history = this.history.filter(e => { const matches = this.matches(arg1, e); // Cleanup any listeners associated with the input when removing from history @@ -847,17 +849,17 @@ export class HistoryService extends Disposable implements IHistoryService { } getHistory(): Array { - const history = this.ensureHistoryLoaded(); + this.ensureHistoryLoaded(); - return history.slice(0); + return this.history.slice(0); } - private ensureHistoryLoaded(): Array { - if (!this.history) { - this.history = this.loadHistory(); + private ensureHistoryLoaded(): void { + if (!this.loaded) { + this.loadHistory(); } - return this.history; + this.loaded = true; } private saveState(): void { @@ -891,7 +893,7 @@ export class HistoryService extends Disposable implements IHistoryService { this.storageService.store(HistoryService.STORAGE_KEY, JSON.stringify(entries), StorageScope.WORKSPACE); } - private loadHistory(): Array { + private loadHistory(): void { let entries: ISerializedEditorHistoryEntry[] = []; const entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE); @@ -901,7 +903,7 @@ export class HistoryService extends Disposable implements IHistoryService { const registry = Registry.as(EditorExtensions.EditorInputFactories); - return coalesce(entries.map(entry => { + this.history = coalesce(entries.map(entry => { try { return this.safeLoadHistoryEntry(registry, entry); } catch (error) { From 44ac060e73ee7d53cb0068219862783713559fa4 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 5 Sep 2019 11:45:03 +0200 Subject: [PATCH 089/204] resolve #80344 on master --- .../workbench/browser/parts/statusbar/media/statusbarpart.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vs/workbench/browser/parts/statusbar/media/statusbarpart.css b/src/vs/workbench/browser/parts/statusbar/media/statusbarpart.css index 1037fb4808f0d..92c49501535bb 100644 --- a/src/vs/workbench/browser/parts/statusbar/media/statusbarpart.css +++ b/src/vs/workbench/browser/parts/statusbar/media/statusbarpart.css @@ -20,6 +20,8 @@ z-index: 5; pointer-events: none; background-color: var(--status-border-top-color); + width: 100%; + height: 1px; } .monaco-workbench .part.statusbar > .left-items, From 6581d602aa03e7b9cc51c9adb650f6cd766792d3 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 5 Sep 2019 11:53:06 +0200 Subject: [PATCH 090/204] Fix #80369 --- .../extensions/browser/extensionsActions.ts | 2 +- .../extensions/browser/extensionsViewlet.ts | 16 ++++++---------- .../contrib/extensions/common/extensions.ts | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 71a2b755343bb..fbdabd31fd46e 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -1605,7 +1605,7 @@ export class ShowRecommendedExtensionsAction extends Action { return this.viewletService.openViewlet(VIEWLET_ID, true) .then(viewlet => viewlet as IExtensionsViewlet) .then(viewlet => { - viewlet.search('@recommended '); + viewlet.search('@recommended ', true); viewlet.focus(); }); } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts index d9aef35dae5be..b4b05abc5ecec 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.ts @@ -59,11 +59,6 @@ import { RemoteNameContext } from 'vs/workbench/browser/contextkeys'; import { ILabelService } from 'vs/platform/label/common/label'; import { MementoObject } from 'vs/workbench/common/memento'; -interface SearchInputEvent extends Event { - target: HTMLInputElement; - immediate?: boolean; -} - const NonEmptyWorkspaceContext = new RawContextKey('nonEmptyWorkspace', false); const DefaultViewsContext = new RawContextKey('defaultExtensionViews', true); const SearchMarketplaceExtensionsContext = new RawContextKey('searchMarketplaceExtensions', false); @@ -488,12 +483,13 @@ export class ExtensionsViewlet extends ViewContainerViewlet implements IExtensio return this.secondaryActions; } - search(value: string): void { + search(value: string, refresh: boolean = false): void { if (this.searchBox) { - const event = new Event('input', { bubbles: true }) as SearchInputEvent; - event.immediate = true; - - this.searchBox.setValue(value); + if (this.searchBox.getValue() !== value) { + this.searchBox.setValue(value); + } else if (refresh) { + this.doSearch(); + } } } diff --git a/src/vs/workbench/contrib/extensions/common/extensions.ts b/src/vs/workbench/contrib/extensions/common/extensions.ts index 126a008a66bb9..402f9e0a2fe9c 100644 --- a/src/vs/workbench/contrib/extensions/common/extensions.ts +++ b/src/vs/workbench/contrib/extensions/common/extensions.ts @@ -23,7 +23,7 @@ export const VIEW_CONTAINER: ViewContainer = Registry.as Date: Thu, 5 Sep 2019 12:17:55 +0200 Subject: [PATCH 091/204] Migrate computed editor options --- .../editor/browser/controller/mouseTarget.ts | 2 +- .../browser/controller/textAreaHandler.ts | 4 +- src/vs/editor/browser/view/viewOverlays.ts | 6 +- .../contentWidgets/contentWidgets.ts | 8 +- .../currentLineHighlight.ts | 4 +- .../currentLineMarginHighlight.ts | 4 +- .../viewParts/decorations/decorations.ts | 9 +- .../viewParts/glyphMargin/glyphMargin.ts | 4 +- .../viewParts/indentGuides/indentGuides.ts | 4 +- .../viewParts/lineNumbers/lineNumbers.ts | 3 +- .../browser/viewParts/lines/viewLine.ts | 2 +- .../browser/viewParts/lines/viewLines.ts | 4 +- .../browser/viewParts/minimap/minimap.ts | 4 +- .../overviewRuler/decorationsOverviewRuler.ts | 4 +- .../viewParts/overviewRuler/overviewRuler.ts | 17 ++- .../viewParts/selections/selections.ts | 4 +- .../viewParts/viewCursors/viewCursor.ts | 4 +- .../browser/viewParts/viewZones/viewZones.ts | 6 +- .../editor/browser/widget/codeEditorWidget.ts | 2 +- .../editor/browser/widget/diffEditorWidget.ts | 4 +- .../editor/browser/widget/inlineDiffMargin.ts | 2 +- src/vs/editor/common/config/editorOptions.ts | 93 ++++++------ .../editor/common/controller/cursorCommon.ts | 7 +- .../common/standalone/standaloneEnums.ts | 116 +++++++-------- src/vs/editor/common/view/viewEvents.ts | 4 - src/vs/editor/common/viewLayout/viewLayout.ts | 13 +- .../contrib/codeAction/lightBulbWidget.ts | 2 +- .../editor/contrib/codelens/codelensWidget.ts | 5 +- .../contrib/gotoError/gotoErrorWidget.ts | 3 +- src/vs/editor/contrib/hover/hoverWidgets.ts | 26 ++-- .../editor/contrib/hover/modesContentHover.ts | 2 +- .../contrib/referenceSearch/peekViewWidget.ts | 3 +- .../editor/contrib/rename/renameInputField.ts | 3 +- .../editor/contrib/zoneWidget/zoneWidget.ts | 8 +- src/vs/monaco.d.ts | 133 +++++++++--------- .../comments/browser/commentThreadWidget.ts | 7 +- .../contrib/debug/browser/exceptionWidget.ts | 3 +- .../preferences/browser/preferencesWidgets.ts | 5 +- .../contrib/scm/browser/dirtydiffDecorator.ts | 4 +- .../walkThrough/browser/walkThroughPart.ts | 6 +- 40 files changed, 285 insertions(+), 259 deletions(-) diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index 1db7f2849a444..4ec958948b249 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -242,7 +242,7 @@ export class HitTestContext { const options = context.configuration.options; this.layoutInfo = options.get(EditorOption.layoutInfo); this.viewDomNode = viewHelper.viewDomNode; - this.lineHeight = context.configuration.editor.lineHeight; + this.lineHeight = options.get(EditorOption.lineHeight); this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this.lastViewCursorsRenderData = lastViewCursorsRenderData; this._context = context; diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index 2cde241536112..18902d71eb90f 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -130,7 +130,7 @@ export class TextAreaHandler extends ViewPart { this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; this._fontInfo = conf.fontInfo; - this._lineHeight = conf.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); @@ -383,7 +383,7 @@ export class TextAreaHandler extends ViewPart { this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; this._fontInfo = conf.fontInfo; - this._lineHeight = conf.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); this.textArea.setAttribute('aria-label', options.get(EditorOption.ariaLabel)); diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index 1145334be1775..43a6a96f830b9 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -149,7 +149,7 @@ export class ViewOverlayLine implements IVisibleLine { constructor(configuration: IConfiguration, dynamicOverlays: DynamicViewOverlay[]) { this._configuration = configuration; - this._lineHeight = this._configuration.editor.lineHeight; + this._lineHeight = this._configuration.options.get(EditorOption.lineHeight); this._dynamicOverlays = dynamicOverlays; this._domNode = null; @@ -173,9 +173,7 @@ export class ViewOverlayLine implements IVisibleLine { // Nothing } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): void { - if (e.lineHeight) { - this._lineHeight = this._configuration.editor.lineHeight; - } + this._lineHeight = this._configuration.options.get(EditorOption.lineHeight); } public renderLine(lineNumber: number, deltaTop: number, viewportData: ViewportData, sb: IStringBuilder): boolean { diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index 721a7ff2acb7a..3a962f22ea273 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -215,7 +215,7 @@ class Widget { this._fixedOverflowWidgets = options.get(EditorOption.fixedOverflowWidgets); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._position = null; this._range = null; @@ -235,11 +235,9 @@ class Widget { } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): void { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } + const options = this._context.configuration.options; + this._lineHeight = options.get(EditorOption.lineHeight); if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index 448aff03d52aa..820b7c30e2944 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -29,7 +29,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); this._contentWidth = layoutInfo.contentWidth; @@ -52,7 +52,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); this._contentWidth = layoutInfo.contentWidth; return true; diff --git a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts index 17a473d86b4f8..f07b024aca1d0 100644 --- a/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineMarginHighlight/currentLineMarginHighlight.ts @@ -28,7 +28,7 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); this._contentLeft = layoutInfo.contentLeft; @@ -49,7 +49,7 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._renderLineHighlight = options.get(EditorOption.renderLineHighlight); this._contentLeft = layoutInfo.contentLeft; return true; diff --git a/src/vs/editor/browser/viewParts/decorations/decorations.ts b/src/vs/editor/browser/viewParts/decorations/decorations.ts index 0716cc3b4e1c4..2e0627b2b9456 100644 --- a/src/vs/editor/browser/viewParts/decorations/decorations.ts +++ b/src/vs/editor/browser/viewParts/decorations/decorations.ts @@ -10,6 +10,7 @@ import { HorizontalRange, RenderingContext } from 'vs/editor/common/view/renderi import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export class DecorationsOverlay extends DynamicViewOverlay { @@ -21,7 +22,8 @@ export class DecorationsOverlay extends DynamicViewOverlay { constructor(context: ViewContext) { super(); this._context = context; - this._lineHeight = this._context.configuration.editor.lineHeight; + const options = this._context.configuration.options; + this._lineHeight = options.get(EditorOption.lineHeight); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this._renderResult = null; @@ -37,9 +39,8 @@ export class DecorationsOverlay extends DynamicViewOverlay { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._lineHeight = this._context.configuration.editor.lineHeight; - } + const options = this._context.configuration.options; + this._lineHeight = options.get(EditorOption.lineHeight); if (e.fontInfo) { this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; } diff --git a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts index 7bc4e31bd2eb5..494b7d7ca233e 100644 --- a/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts +++ b/src/vs/editor/browser/viewParts/glyphMargin/glyphMargin.ts @@ -90,7 +90,7 @@ export class GlyphMarginOverlay extends DedupOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._glyphMargin = options.get(EditorOption.glyphMargin); this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; @@ -110,7 +110,7 @@ export class GlyphMarginOverlay extends DedupOverlay { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._glyphMargin = options.get(EditorOption.glyphMargin); this._glyphMarginLeft = layoutInfo.glyphMarginLeft; this._glyphMarginWidth = layoutInfo.glyphMarginWidth; diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index 705700fc6d6a5..762c8dff7135f 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -33,7 +33,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._enabled = options.get(EditorOption.renderIndentGuides); this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); @@ -56,7 +56,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; this._enabled = options.get(EditorOption.renderIndentGuides); this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index 1d5e650806252..ccf43d5b6949c 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -42,8 +42,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay { private _readConfig(): void { const options = this._context.configuration.options; - const config = this._context.configuration.editor; - this._lineHeight = config.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); const lineNumbers = options.get(EditorOption.lineNumbers); this._renderLineNumbers = lineNumbers.renderType; this._renderCustomLineNumbers = lineNumbers.renderFn; diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index 25e861bf9c685..f337db9c1f857 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -90,7 +90,7 @@ export class ViewLineOptions { && !options.get(EditorOption.disableMonospaceOptimizations) ); this.canUseHalfwidthRightwardsArrow = config.editor.fontInfo.canUseHalfwidthRightwardsArrow; - this.lineHeight = config.editor.lineHeight; + this.lineHeight = options.get(EditorOption.lineHeight); this.stopRenderingLineAfter = options.get(EditorOption.stopRenderingLineAfter); this.fontLigatures = options.get(EditorOption.fontLigatures); } diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index f8d9fb45839d6..092cb3c9a705e 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -96,7 +96,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); - this._lineHeight = conf.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; this._isViewportWrapping = wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); @@ -149,7 +149,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); - this._lineHeight = conf.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; this._isViewportWrapping = wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 27312e54b806e..2550266af7692 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -108,7 +108,7 @@ class MinimapOptions { constructor(configuration: IConfiguration) { const options = configuration.options; - const pixelRatio = configuration.editor.pixelRatio; + const pixelRatio = options.get(EditorOption.pixelRatio); const layoutInfo = options.get(EditorOption.layoutInfo); const fontInfo = configuration.editor.fontInfo; @@ -118,7 +118,7 @@ class MinimapOptions { this.showSlider = minimapOpts.showSlider; this.pixelRatio = pixelRatio; this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; - this.lineHeight = configuration.editor.lineHeight; + this.lineHeight = options.get(EditorOption.lineHeight); this.minimapLeft = layoutInfo.minimapLeft; this.minimapWidth = layoutInfo.minimapWidth; this.minimapHeight = layoutInfo.height; diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index 7658dfbf33c95..a4e988745cbc9 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -44,8 +44,8 @@ class Settings { constructor(config: IConfiguration, theme: ITheme) { const options = config.options; - this.lineHeight = config.editor.lineHeight; - this.pixelRatio = config.editor.pixelRatio; + this.lineHeight = options.get(EditorOption.lineHeight); + this.pixelRatio = options.get(EditorOption.pixelRatio); this.overviewRulerLanes = options.get(EditorOption.overviewRulerLanes); this.renderBorder = options.get(EditorOption.overviewRulerBorder); diff --git a/src/vs/editor/browser/viewParts/overviewRuler/overviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/overviewRuler.ts index 4b164f01c6b06..7b9ef090d2a5d 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/overviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/overviewRuler.ts @@ -5,7 +5,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode'; import { IOverviewRuler } from 'vs/editor/browser/editorBrowser'; -import { OverviewRulerPosition } from 'vs/editor/common/config/editorOptions'; +import { OverviewRulerPosition, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ColorZone, OverviewRulerZone, OverviewZoneManager } from 'vs/editor/common/view/overviewZoneManager'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; @@ -20,6 +20,7 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler { constructor(context: ViewContext, cssClassName: string) { super(); this._context = context; + const options = this._context.configuration.options; this._domNode = createFastDomNode(document.createElement('canvas')); this._domNode.setClassName(cssClassName); @@ -30,9 +31,9 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler { this._zoneManager.setDOMWidth(0); this._zoneManager.setDOMHeight(0); this._zoneManager.setOuterHeight(this._context.viewLayout.getScrollHeight()); - this._zoneManager.setLineHeight(this._context.configuration.editor.lineHeight); + this._zoneManager.setLineHeight(options.get(EditorOption.lineHeight)); - this._zoneManager.setPixelRatio(this._context.configuration.editor.pixelRatio); + this._zoneManager.setPixelRatio(options.get(EditorOption.pixelRatio)); this._context.addEventHandler(this); } @@ -45,13 +46,15 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler { // ---- begin view event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - if (e.lineHeight) { - this._zoneManager.setLineHeight(this._context.configuration.editor.lineHeight); + const options = this._context.configuration.options; + + if (e.hasChanged(EditorOption.lineHeight)) { + this._zoneManager.setLineHeight(options.get(EditorOption.lineHeight)); this._render(); } - if (e.pixelRatio) { - this._zoneManager.setPixelRatio(this._context.configuration.editor.pixelRatio); + if (e.hasChanged(EditorOption.pixelRatio)) { + this._zoneManager.setPixelRatio(options.get(EditorOption.pixelRatio)); this._domNode.setWidth(this._zoneManager.getDOMWidth()); this._domNode.setHeight(this._zoneManager.getDOMHeight()); this._domNode.domNode.width = this._zoneManager.getCanvasWidth(); diff --git a/src/vs/editor/browser/viewParts/selections/selections.ts b/src/vs/editor/browser/viewParts/selections/selections.ts index 1c1cd7fdd485c..b960faf575117 100644 --- a/src/vs/editor/browser/viewParts/selections/selections.ts +++ b/src/vs/editor/browser/viewParts/selections/selections.ts @@ -85,7 +85,7 @@ export class SelectionsOverlay extends DynamicViewOverlay { super(); this._context = context; const options = this._context.configuration.options; - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._roundedSelection = options.get(EditorOption.roundedSelection); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this._selections = []; @@ -103,7 +103,7 @@ export class SelectionsOverlay extends DynamicViewOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._roundedSelection = options.get(EditorOption.roundedSelection); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; return true; diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index 491943b8fb68b..be49b426a8d13 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -54,7 +54,7 @@ export class ViewCursor { const options = this._context.configuration.options; this._cursorStyle = options.get(EditorOption.cursorStyle); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); @@ -101,7 +101,7 @@ export class ViewCursor { const options = this._context.configuration.options; this._cursorStyle = options.get(EditorOption.cursorStyle); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); diff --git a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts index 8bac486f4bc94..6d7e14730894b 100644 --- a/src/vs/editor/browser/viewParts/viewZones/viewZones.ts +++ b/src/vs/editor/browser/viewParts/viewZones/viewZones.ts @@ -45,7 +45,7 @@ export class ViewZones extends ViewPart { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; @@ -92,11 +92,11 @@ export class ViewZones extends ViewPart { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._lineHeight = this._context.configuration.editor.lineHeight; + this._lineHeight = options.get(EditorOption.lineHeight); this._contentWidth = layoutInfo.contentWidth; this._contentLeft = layoutInfo.contentLeft; - if (e.lineHeight) { + if (e.hasChanged(EditorOption.lineHeight)) { this._recomputeWhitespacesProps(); } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index bd77626336934..730a5c027f8fc 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -1289,7 +1289,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE return { top: top, left: left, - height: this._configuration.editor.lineHeight + height: options.get(EditorOption.lineHeight) }; } diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index fd704dbd5d2db..93f4e5444259e 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -1998,7 +1998,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { const layoutInfo = this.modifiedEditorOptions.get(EditorOption.layoutInfo); const lineDecorationsWidth = layoutInfo.decorationsWidth; - let lineHeight = this.modifiedEditorConfiguration.lineHeight; + let lineHeight = this.modifiedEditorOptions.get(EditorOption.lineHeight); const typicalHalfwidthCharacterWidth = this.modifiedEditorConfiguration.fontInfo.typicalHalfwidthCharacterWidth; let maxCharsPerLine = 0; const originalContent: string[] = []; @@ -2054,7 +2054,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { sb.appendASCIIString(' char-delete'); } sb.appendASCIIString('" style="top:'); - sb.appendASCIIString(String(count * config.lineHeight)); + sb.appendASCIIString(String(count * options.get(EditorOption.lineHeight))); sb.appendASCIIString('px;width:1000000px;">'); const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, originalModel.mightContainNonBasicASCII()); diff --git a/src/vs/editor/browser/widget/inlineDiffMargin.ts b/src/vs/editor/browser/widget/inlineDiffMargin.ts index cec830e304c0e..90bb8d9165a3d 100644 --- a/src/vs/editor/browser/widget/inlineDiffMargin.ts +++ b/src/vs/editor/browser/widget/inlineDiffMargin.ts @@ -59,7 +59,7 @@ export class InlineDiffMargin extends Disposable { this._diffActions = document.createElement('div'); this._diffActions.className = 'lightbulb-glyph'; this._diffActions.style.position = 'absolute'; - const lineHeight = editor.getConfiguration().lineHeight; + const lineHeight = editor.getOption(EditorOption.lineHeight); const lineFeed = editor.getModel()!.getEOL(); this._diffActions.style.right = '0px'; this._diffActions.style.visibility = 'hidden'; diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 873bb5575e7f1..c88fa2db71c9f 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -717,11 +717,17 @@ export interface IEditorOptions { * Controls fading out of unused variables. */ showUnused?: boolean; +} +export type IExtendedEditorOptions = IEditorOptions & { /** * Do not use, this is a computed option. */ editorClassName?: undefined; + /** + * Do not use, this is a computed option. + */ + pixelRatio?: undefined; /** * Do not use, this is a computed option. */ @@ -734,7 +740,7 @@ export interface IEditorOptions { * Do not use, this is a computed option. */ wrappingInfo?: undefined; -} +}; /** * Configuration options for the diff editor. @@ -900,9 +906,6 @@ function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'l export class InternalEditorOptions { readonly _internalEditorOptionsBrand: void; - readonly pixelRatio: number; - readonly lineHeight: number; - // ---- grouped options readonly fontInfo: FontInfo; @@ -910,12 +913,8 @@ export class InternalEditorOptions { * @internal */ constructor(source: { - pixelRatio: number; - lineHeight: number; fontInfo: FontInfo; }) { - this.pixelRatio = source.pixelRatio; - this.lineHeight = source.lineHeight | 0; this.fontInfo = source.fontInfo; } @@ -924,9 +923,7 @@ export class InternalEditorOptions { */ public equals(other: InternalEditorOptions): boolean { return ( - this.pixelRatio === other.pixelRatio - && this.lineHeight === other.lineHeight - && this.fontInfo.equals(other.fontInfo) + this.fontInfo.equals(other.fontInfo) ); } @@ -941,8 +938,6 @@ export class InternalEditorOptions { } return changeEvent.get(id); }, - pixelRatio: (this.pixelRatio !== newOpts.pixelRatio), - lineHeight: (this.lineHeight !== newOpts.lineHeight), fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), }; } @@ -953,8 +948,6 @@ export class InternalEditorOptions { */ export interface IConfigurationChangedEvent { hasChanged(id: EditorOption): boolean; - readonly pixelRatio: boolean; - readonly lineHeight: boolean; readonly fontInfo: boolean; } @@ -1067,8 +1060,6 @@ export class InternalEditorOptionsFactory { public static createInternalEditorOptions(env: IEnvironmentalOptions) { return new InternalEditorOptions({ - pixelRatio: env.pixelRatio, - lineHeight: env.fontInfo.lineHeight, fontInfo: env.fontInfo, }); } @@ -1139,7 +1130,7 @@ export const EDITOR_MODEL_DEFAULTS = { /** * @internal */ -export interface IRawEditorOptionsBag extends IEditorOptions { +export interface IRawEditorOptionsBag extends IExtendedEditorOptions { [key: string]: any; } @@ -1210,28 +1201,28 @@ export class ChangedEditorOptions { /** * @internal */ -type PossibleKeyName0 = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; +type PossibleKeyName0 = { [K in keyof IExtendedEditorOptions]: IExtendedEditorOptions[K] extends V | undefined ? K : never }[keyof IExtendedEditorOptions]; /** * @internal */ type PossibleKeyName = NonNullable>; -export interface IEditorOption, T3 = T2> { +export interface IEditorOption, T3 = T2> { readonly id: K1; readonly name: K2; readonly defaultValue: T2; /** * @internal */ - read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined; + read(options: IRawEditorOptionsBag): IExtendedEditorOptions[K2] | undefined; /** * @internal */ - mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined; + mix(a: IExtendedEditorOptions[K2] | undefined, b: IExtendedEditorOptions[K2] | undefined): IExtendedEditorOptions[K2] | undefined; /** * @internal */ - validate(input: IEditorOptions[K2] | undefined): T2; + validate(input: IExtendedEditorOptions[K2] | undefined): T2; /** * @internal */ @@ -1245,7 +1236,7 @@ export interface IEditorOption implements IEditorOption { +abstract class BaseEditorOption implements IEditorOption { public readonly id: K1; public readonly name: K2; @@ -1259,10 +1250,10 @@ abstract class BaseEditorOptionthis.name]; } - public mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined { + public mix(a: IExtendedEditorOptions[K2] | undefined, b: IExtendedEditorOptions[K2] | undefined): IExtendedEditorOptions[K2] | undefined { switch (typeof b) { case 'bigint': return b; case 'boolean': return b; @@ -1274,7 +1265,7 @@ abstract class BaseEditorOption, this.allowedValues = allowedValues; this.convert = convert; } - public validate(input: IEditorOptions[K2] | undefined): T1 { + public validate(input: IExtendedEditorOptions[K2] | undefined): T1 { return _stringSet(input, this.defaultValue, this.allowedValues); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T1): T2 { @@ -1345,14 +1336,14 @@ class EditorEnumOption, } } -class EditorPassthroughOption extends BaseEditorOption { - public validate(input: IEditorOptions[K2] | undefined): IEditorOptions[K2] { +class EditorPassthroughOption extends BaseEditorOption { + public validate(input: IExtendedEditorOptions[K2] | undefined): IExtendedEditorOptions[K2] { if (typeof input === 'undefined') { return this.defaultValue; } return input; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: IEditorOptions[K2]): IEditorOptions[K2] { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: IExtendedEditorOptions[K2]): IExtendedEditorOptions[K2] { return value; } } @@ -1646,6 +1637,32 @@ class EditorTabFocusMode> extends BaseEditorOption { + public validate(input: undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): number { + return env.pixelRatio; + } +} + +//#endregion + +//#region lineHeight + +class EditorLineHeight> extends BaseEditorOption { + public validate(input: number | undefined): number { + return this.defaultValue; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { + return env.fontInfo.lineHeight; + } +} + +//#endregion + //#region emptySelectionClipboard class EditorEmptySelectionClipboard> extends EditorBooleanOption { @@ -2338,7 +2355,7 @@ function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): */ export const editorOptionsRegistry: IEditorOption[] = []; -function registerEditorOption(option: IEditorOption): IEditorOption { +function registerEditorOption(option: IEditorOption): IEditorOption { editorOptionsRegistry[option.id] = option; return option; } @@ -2382,6 +2399,7 @@ export const enum EditorOption { inDiffEditor, lightbulb, lineDecorationsWidth, + lineHeight, lineNumbers, lineNumbersMinChars, links, @@ -2436,6 +2454,7 @@ export const enum EditorOption { ariaLabel, disableMonospaceOptimizations, editorClassName, + pixelRatio, tabFocusMode, suggest, layoutInfo, @@ -2494,6 +2513,7 @@ export const EditorOptions = { enabled: true })), lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineHeight: registerEditorOption(new EditorLineHeight(EditorOption.lineHeight, 'lineHeight', EDITOR_FONT_DEFAULTS.lineHeight)), lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), links: registerEditorOption(new EditorBooleanOption(EditorOption.links, 'links', true)), @@ -2574,6 +2594,7 @@ export const EditorOptions = { ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])), disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])), editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])), + pixelRatio: registerEditorOption(new EditorPixelRatio(EditorOption.pixelRatio, 'pixelRatio', undefined)), tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), suggest: registerEditorOption(new EditorSuggest(EditorOption.suggest, 'suggest', { filterGraceful: true, @@ -2588,14 +2609,6 @@ export const EditorOptions = { wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), }; -// const tmp: { [key: string]: IEditorOption; } = EditorOptions; -// for (const key of Object.keys(tmp)) { -// const option = tmp[key]; -// if (key !== option.name) { -// throw new Error(`mismatch - ${key} - ${option.name}`); -// } -// } - export type EditorOptionsType = typeof EditorOptions; export type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 3016ee9e8030c..dd85df4cc431b 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -121,7 +121,7 @@ export class CursorConfiguration { || e.hasChanged(EditorOption.autoClosingOvertype) || e.hasChanged(EditorOption.autoSurround) || e.hasChanged(EditorOption.useTabStops) - || e.lineHeight + || e.hasChanged(EditorOption.lineHeight) || e.hasChanged(EditorOption.readOnly) ); } @@ -133,7 +133,6 @@ export class CursorConfiguration { ) { this._languageIdentifier = languageIdentifier; - const c = configuration.editor; const options = configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); @@ -141,8 +140,8 @@ export class CursorConfiguration { this.tabSize = modelOptions.tabSize; this.indentSize = modelOptions.indentSize; this.insertSpaces = modelOptions.insertSpaces; - this.pageSize = Math.max(1, Math.floor(layoutInfo.height / c.fontInfo.lineHeight) - 2); - this.lineHeight = c.lineHeight; + this.lineHeight = options.get(EditorOption.lineHeight); + this.pageSize = Math.max(1, Math.floor(layoutInfo.height / this.lineHeight) - 2); this.useTabStops = options.get(EditorOption.useTabStops); this.wordSeparators = options.get(EditorOption.wordSeparators); this.emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 6410d3b438bce..268d0bfada72e 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -478,63 +478,65 @@ export enum EditorOption { inDiffEditor = 35, lightbulb = 36, lineDecorationsWidth = 37, - lineNumbers = 38, - lineNumbersMinChars = 39, - links = 40, - matchBrackets = 41, - minimap = 42, - mouseStyle = 43, - mouseWheelScrollSensitivity = 44, - mouseWheelZoom = 45, - multiCursorMergeOverlapping = 46, - multiCursorModifier = 47, - occurrencesHighlight = 48, - overviewRulerBorder = 49, - overviewRulerLanes = 50, - parameterHints = 51, - quickSuggestions = 52, - quickSuggestionsDelay = 53, - readOnly = 54, - renderControlCharacters = 55, - renderIndentGuides = 56, - renderFinalNewline = 57, - renderLineHighlight = 58, - renderWhitespace = 59, - revealHorizontalRightPadding = 60, - roundedSelection = 61, - rulers = 62, - scrollbar = 63, - scrollBeyondLastColumn = 64, - scrollBeyondLastLine = 65, - selectionClipboard = 66, - selectionHighlight = 67, - selectOnLineNumbers = 68, - showFoldingControls = 69, - showUnused = 70, - snippetSuggestions = 71, - smoothScrolling = 72, - stopRenderingLineAfter = 73, - suggestFontSize = 74, - suggestLineHeight = 75, - suggestOnTriggerCharacters = 76, - suggestSelection = 77, - tabCompletion = 78, - useTabStops = 79, - wordSeparators = 80, - wordWrap = 81, - wordWrapBreakAfterCharacters = 82, - wordWrapBreakBeforeCharacters = 83, - wordWrapBreakObtrusiveCharacters = 84, - wordWrapColumn = 85, - wordWrapMinified = 86, - wrappingIndent = 87, - ariaLabel = 88, - disableMonospaceOptimizations = 89, - editorClassName = 90, - tabFocusMode = 91, - suggest = 92, - layoutInfo = 93, - wrappingInfo = 94 + lineHeight = 38, + lineNumbers = 39, + lineNumbersMinChars = 40, + links = 41, + matchBrackets = 42, + minimap = 43, + mouseStyle = 44, + mouseWheelScrollSensitivity = 45, + mouseWheelZoom = 46, + multiCursorMergeOverlapping = 47, + multiCursorModifier = 48, + occurrencesHighlight = 49, + overviewRulerBorder = 50, + overviewRulerLanes = 51, + parameterHints = 52, + quickSuggestions = 53, + quickSuggestionsDelay = 54, + readOnly = 55, + renderControlCharacters = 56, + renderIndentGuides = 57, + renderFinalNewline = 58, + renderLineHighlight = 59, + renderWhitespace = 60, + revealHorizontalRightPadding = 61, + roundedSelection = 62, + rulers = 63, + scrollbar = 64, + scrollBeyondLastColumn = 65, + scrollBeyondLastLine = 66, + selectionClipboard = 67, + selectionHighlight = 68, + selectOnLineNumbers = 69, + showFoldingControls = 70, + showUnused = 71, + snippetSuggestions = 72, + smoothScrolling = 73, + stopRenderingLineAfter = 74, + suggestFontSize = 75, + suggestLineHeight = 76, + suggestOnTriggerCharacters = 77, + suggestSelection = 78, + tabCompletion = 79, + useTabStops = 80, + wordSeparators = 81, + wordWrap = 82, + wordWrapBreakAfterCharacters = 83, + wordWrapBreakBeforeCharacters = 84, + wordWrapBreakObtrusiveCharacters = 85, + wordWrapColumn = 86, + wordWrapMinified = 87, + wrappingIndent = 88, + ariaLabel = 89, + disableMonospaceOptimizations = 90, + editorClassName = 91, + pixelRatio = 92, + tabFocusMode = 93, + suggest = 94, + layoutInfo = 95, + wrappingInfo = 96 } /** diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index e113f65c0723e..05d9e6b0db8ab 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -35,14 +35,10 @@ export class ViewConfigurationChangedEvent { public readonly type = ViewEventType.ViewConfigurationChanged; public readonly _source: IConfigurationChangedEvent; - public readonly pixelRatio: boolean; - public readonly lineHeight: boolean; public readonly fontInfo: boolean; constructor(source: IConfigurationChangedEvent) { this._source = source; - this.pixelRatio = source.pixelRatio; - this.lineHeight = source.lineHeight; this.fontInfo = source.fontInfo; } diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index 952406baa27e9..2a4f9355ac81b 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -30,7 +30,7 @@ export class ViewLayout extends Disposable implements IViewLayout { const options = this._configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); - this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight); + this._linesLayout = new LinesLayout(lineCount, options.get(EditorOption.lineHeight)); this.scrollable = this._register(new Scrollable(0, scheduleAtNextAnimationFrame)); this._configureSmoothScrollDuration(); @@ -59,11 +59,11 @@ export class ViewLayout extends Disposable implements IViewLayout { // ---- begin view event handlers public onConfigurationChanged(e: IConfigurationChangedEvent): void { - if (e.lineHeight) { - this._linesLayout.setLineHeight(this._configuration.editor.lineHeight); + const options = this._configuration.options; + if (e.hasChanged(EditorOption.lineHeight)) { + this._linesLayout.setLineHeight(options.get(EditorOption.lineHeight)); } if (e.hasChanged(EditorOption.layoutInfo)) { - const options = this._configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); this.scrollable.setScrollDimensions({ width: layoutInfo.contentWidth, @@ -102,11 +102,12 @@ export class ViewLayout extends Disposable implements IViewLayout { } private _getTotalHeight(): number { + const options = this._configuration.options; const scrollDimensions = this.scrollable.getScrollDimensions(); let result = this._linesLayout.getLinesTotalHeight(); - if (this._configuration.options.get(EditorOption.scrollBeyondLastLine)) { - result += scrollDimensions.height - this._configuration.editor.lineHeight; + if (options.get(EditorOption.scrollBeyondLastLine)) { + result += scrollDimensions.height - options.get(EditorOption.lineHeight); } else { result += this._getHorizontalScrollbarHeight(scrollDimensions); } diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index 3987b9a5eeee1..f4a3bbf228ad4 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -79,7 +79,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget { // a bit of extra work to make sure the menu // doesn't cover the line-text const { top, height } = dom.getDomNodePagePosition(this._domNode); - const { lineHeight } = this._editor.getConfiguration(); + const lineHeight = this._editor.getOption(EditorOption.lineHeight); let pad = Math.floor(lineHeight / 3); if (this._state.widgetPosition.position !== null && this._state.widgetPosition.position.lineNumber < this._state.editorPosition.lineNumber) { diff --git a/src/vs/editor/contrib/codelens/codelensWidget.ts b/src/vs/editor/contrib/codelens/codelensWidget.ts index 5ae20b27edb7a..516f971af2bc0 100644 --- a/src/vs/editor/contrib/codelens/codelensWidget.ts +++ b/src/vs/editor/contrib/codelens/codelensWidget.ts @@ -16,6 +16,7 @@ import { editorCodeLensForeground } from 'vs/editor/common/view/editorColorRegis import { CodeLensItem } from 'vs/editor/contrib/codelens/codelens'; import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class CodeLensViewZone implements editorBrowser.IViewZone { @@ -80,7 +81,9 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget { } updateHeight(): void { - const { fontInfo, lineHeight } = this._editor.getConfiguration(); + const options = this._editor.getOptions(); + const { fontInfo } = this._editor.getConfiguration(); + const lineHeight = options.get(EditorOption.lineHeight); this._domNode.style.height = `${Math.round(lineHeight * 1.1)}px`; this._domNode.style.lineHeight = `${lineHeight}px`; this._domNode.style.fontSize = `${Math.round(fontInfo.fontSize * 0.9)}px`; diff --git a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts index 9da6b13042f44..dd7414923a758 100644 --- a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts +++ b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts @@ -26,6 +26,7 @@ import { IAction } from 'vs/base/common/actions'; import { IActionBarOptions, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar'; import { peekViewTitleForeground, peekViewTitleInfoForeground } from 'vs/editor/contrib/referenceSearch/referencesWidget'; import { SeverityIcon } from 'vs/platform/severityIcon/common/severityIcon'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; class MessageWidget { @@ -122,7 +123,7 @@ class MessageWidget { this._editor.applyFontInfo(this._relatedBlock); if (isNonEmptyArray(relatedInformation)) { const relatedInformationNode = this._relatedBlock.appendChild(document.createElement('div')); - relatedInformationNode.style.paddingTop = `${Math.floor(this._editor.getConfiguration().lineHeight * 0.66)}px`; + relatedInformationNode.style.paddingTop = `${Math.floor(this._editor.getOption(EditorOption.lineHeight) * 0.66)}px`; this._lines += 1; for (const related of relatedInformation) { diff --git a/src/vs/editor/contrib/hover/hoverWidgets.ts b/src/vs/editor/contrib/hover/hoverWidgets.ts index 13dff65003845..96d28a550992c 100644 --- a/src/vs/editor/contrib/hover/hoverWidgets.ts +++ b/src/vs/editor/contrib/hover/hoverWidgets.ts @@ -8,15 +8,15 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { Widget } from 'vs/base/browser/ui/widget'; import { KeyCode } from 'vs/base/common/keyCodes'; -import * as editorBrowser from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IContentWidget, ICodeEditor, IContentWidgetPosition, ContentWidgetPositionPreference, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser'; +import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; -export class ContentHoverWidget extends Widget implements editorBrowser.IContentWidget { +export class ContentHoverWidget extends Widget implements IContentWidget { private readonly _id: string; - protected _editor: editorBrowser.ICodeEditor; + protected _editor: ICodeEditor; private _isVisible: boolean; private readonly _containerDomNode: HTMLElement; private readonly _domNode: HTMLElement; @@ -37,7 +37,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent toggleClass(this._containerDomNode, 'hidden', !this._isVisible); } - constructor(id: string, editor: editorBrowser.ICodeEditor) { + constructor(id: string, editor: ICodeEditor) { super(); this._id = id; this._editor = editor; @@ -113,14 +113,14 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent } } - public getPosition(): editorBrowser.IContentWidgetPosition | null { + public getPosition(): IContentWidgetPosition | null { if (this.isVisible) { return { position: this._showAtPosition, range: this._showAtRange, preference: [ - editorBrowser.ContentWidgetPositionPreference.ABOVE, - editorBrowser.ContentWidgetPositionPreference.BELOW + ContentWidgetPositionPreference.ABOVE, + ContentWidgetPositionPreference.BELOW ] }; } @@ -161,15 +161,15 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent } } -export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWidget { +export class GlyphHoverWidget extends Widget implements IOverlayWidget { private readonly _id: string; - protected _editor: editorBrowser.ICodeEditor; + protected _editor: ICodeEditor; private _isVisible: boolean; private readonly _domNode: HTMLElement; protected _showAtLineNumber: number; - constructor(id: string, editor: editorBrowser.ICodeEditor) { + constructor(id: string, editor: ICodeEditor) { super(); this._id = id; this._editor = editor; @@ -218,7 +218,7 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi const editorLayout = this._editor.getLayoutInfo(); const topForLineNumber = this._editor.getTopForLineNumber(this._showAtLineNumber); const editorScrollTop = this._editor.getScrollTop(); - const lineHeight = this._editor.getConfiguration().lineHeight; + const lineHeight = this._editor.getOption(EditorOption.lineHeight); const nodeHeight = this._domNode.clientHeight; const top = topForLineNumber - editorScrollTop - ((nodeHeight - lineHeight) / 2); @@ -233,7 +233,7 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi this.isVisible = false; } - public getPosition(): editorBrowser.IOverlayWidgetPosition | null { + public getPosition(): IOverlayWidgetPosition | null { return null; } diff --git a/src/vs/editor/contrib/hover/modesContentHover.ts b/src/vs/editor/contrib/hover/modesContentHover.ts index 76bb60097fd1e..06877b671d565 100644 --- a/src/vs/editor/contrib/hover/modesContentHover.ts +++ b/src/vs/editor/contrib/hover/modesContentHover.ts @@ -366,7 +366,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget { // create blank olor picker model and widget first to ensure it's positioned correctly. const model = new ColorPickerModel(color, [], 0); - const widget = new ColorPickerWidget(fragment, model, this._editor.getConfiguration().pixelRatio, this._themeService); + const widget = new ColorPickerWidget(fragment, model, this._editor.getOption(EditorOption.pixelRatio), this._themeService); getColorPresentations(editorModel, colorInfo, msg.provider, CancellationToken.None).then(colorPresentations => { model.colorPresentations = colorPresentations || []; diff --git a/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts b/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts index 0ef1a5253c6fa..16d358dd7a469 100644 --- a/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/peekViewWidget.ts @@ -21,6 +21,7 @@ import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/con import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IDisposable } from 'vs/base/common/lifecycle'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const IPeekViewService = createDecorator('IPeekViewService'); @@ -216,7 +217,7 @@ export abstract class PeekViewWidget extends ZoneWidget { return; } - const headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2); + const headHeight = Math.ceil(this.editor.getOption(EditorOption.lineHeight) * 1.2); const bodyHeight = heightInPixel - (headHeight + 2 /* the border-top/bottom width*/); this._doLayoutHead(headHeight, widthInPixel); diff --git a/src/vs/editor/contrib/rename/renameInputField.ts b/src/vs/editor/contrib/rename/renameInputField.ts index c285d9707cd3a..b3c9bea2be823 100644 --- a/src/vs/editor/contrib/rename/renameInputField.ts +++ b/src/vs/editor/contrib/rename/renameInputField.ts @@ -13,6 +13,7 @@ import { localize } from 'vs/nls'; import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { inputBackground, inputBorder, inputForeground, widgetShadow } from 'vs/platform/theme/common/colorRegistry'; import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const CONTEXT_RENAME_INPUT_VISIBLE = new RawContextKey('renameInputVisible', false); @@ -68,7 +69,7 @@ export class RenameInputField implements IContentWidget, IDisposable { this._inputField.type = 'text'; this._inputField.setAttribute('aria-label', localize('renameAriaLabel', "Rename input. Type new name and press Enter to commit.")); this._domNode = document.createElement('div'); - this._domNode.style.height = `${this._editor.getConfiguration().lineHeight}px`; + this._domNode.style.height = `${this._editor.getOption(EditorOption.lineHeight)}px`; this._domNode.className = 'monaco-editor rename-box'; this._domNode.appendChild(this._inputField); diff --git a/src/vs/editor/contrib/zoneWidget/zoneWidget.ts b/src/vs/editor/contrib/zoneWidget/zoneWidget.ts index 703706bf238bf..f464b2b14f3ae 100644 --- a/src/vs/editor/contrib/zoneWidget/zoneWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/zoneWidget.ts @@ -11,7 +11,7 @@ import { IdGenerator } from 'vs/base/common/idGenerator'; import { DisposableStore } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, IViewZoneChangeAccessor } from 'vs/editor/browser/editorBrowser'; -import { EditorLayoutInfo } from 'vs/editor/common/config/editorOptions'; +import { EditorLayoutInfo, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -334,7 +334,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider { } private _decoratingElementsHeight(): number { - let lineHeight = this.editor.getConfiguration().lineHeight; + let lineHeight = this.editor.getOption(EditorOption.lineHeight); let result = 0; if (this.options.showArrow) { @@ -364,7 +364,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider { // Render the widget as zone (rendering) and widget (lifecycle) const viewZoneDomNode = document.createElement('div'); viewZoneDomNode.style.overflow = 'hidden'; - const lineHeight = this.editor.getConfiguration().lineHeight; + const lineHeight = this.editor.getOption(EditorOption.lineHeight); // adjust heightInLines to viewport const maxHeightInLines = (this.editor.getLayoutInfo().height / lineHeight) * 0.8; @@ -505,7 +505,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider { this._disposables.add(this._resizeSash.onDidChange((evt: ISashEvent) => { if (data) { - let lineDelta = (evt.currentY - data.startY) / this.editor.getConfiguration().lineHeight; + let lineDelta = (evt.currentY - data.startY) / this.editor.getOption(EditorOption.lineHeight); let roundedLineDelta = lineDelta < 0 ? Math.ceil(lineDelta) : Math.floor(lineDelta); let newHeightInLines = data.heightInLines + roundedLineDelta; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index ee94ff2b4bcb1..59b8f512f1925 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3110,10 +3110,17 @@ declare namespace monaco.editor { * Controls fading out of unused variables. */ showUnused?: boolean; + } + + export type IExtendedEditorOptions = IEditorOptions & { /** * Do not use, this is a computed option. */ editorClassName?: undefined; + /** + * Do not use, this is a computed option. + */ + pixelRatio?: undefined; /** * Do not use, this is a computed option. */ @@ -3126,7 +3133,7 @@ declare namespace monaco.editor { * Do not use, this is a computed option. */ wrappingInfo?: undefined; - } + }; /** * Configuration options for the diff editor. @@ -3254,8 +3261,6 @@ declare namespace monaco.editor { */ export class InternalEditorOptions { readonly _internalEditorOptionsBrand: void; - readonly pixelRatio: number; - readonly lineHeight: number; readonly fontInfo: FontInfo; } @@ -3264,8 +3269,6 @@ declare namespace monaco.editor { */ export interface IConfigurationChangedEvent { hasChanged(id: EditorOption): boolean; - readonly pixelRatio: boolean; - readonly lineHeight: boolean; readonly fontInfo: boolean; } @@ -3286,7 +3289,7 @@ declare namespace monaco.editor { get(id: T): FindComputedEditorOptionValueById; } - export interface IEditorOption, T3 = T2> { + export interface IEditorOption, T3 = T2> { readonly id: K1; readonly name: K2; readonly defaultValue: T2; @@ -3525,63 +3528,65 @@ declare namespace monaco.editor { inDiffEditor = 35, lightbulb = 36, lineDecorationsWidth = 37, - lineNumbers = 38, - lineNumbersMinChars = 39, - links = 40, - matchBrackets = 41, - minimap = 42, - mouseStyle = 43, - mouseWheelScrollSensitivity = 44, - mouseWheelZoom = 45, - multiCursorMergeOverlapping = 46, - multiCursorModifier = 47, - occurrencesHighlight = 48, - overviewRulerBorder = 49, - overviewRulerLanes = 50, - parameterHints = 51, - quickSuggestions = 52, - quickSuggestionsDelay = 53, - readOnly = 54, - renderControlCharacters = 55, - renderIndentGuides = 56, - renderFinalNewline = 57, - renderLineHighlight = 58, - renderWhitespace = 59, - revealHorizontalRightPadding = 60, - roundedSelection = 61, - rulers = 62, - scrollbar = 63, - scrollBeyondLastColumn = 64, - scrollBeyondLastLine = 65, - selectionClipboard = 66, - selectionHighlight = 67, - selectOnLineNumbers = 68, - showFoldingControls = 69, - showUnused = 70, - snippetSuggestions = 71, - smoothScrolling = 72, - stopRenderingLineAfter = 73, - suggestFontSize = 74, - suggestLineHeight = 75, - suggestOnTriggerCharacters = 76, - suggestSelection = 77, - tabCompletion = 78, - useTabStops = 79, - wordSeparators = 80, - wordWrap = 81, - wordWrapBreakAfterCharacters = 82, - wordWrapBreakBeforeCharacters = 83, - wordWrapBreakObtrusiveCharacters = 84, - wordWrapColumn = 85, - wordWrapMinified = 86, - wrappingIndent = 87, - ariaLabel = 88, - disableMonospaceOptimizations = 89, - editorClassName = 90, - tabFocusMode = 91, - suggest = 92, - layoutInfo = 93, - wrappingInfo = 94 + lineHeight = 38, + lineNumbers = 39, + lineNumbersMinChars = 40, + links = 41, + matchBrackets = 42, + minimap = 43, + mouseStyle = 44, + mouseWheelScrollSensitivity = 45, + mouseWheelZoom = 46, + multiCursorMergeOverlapping = 47, + multiCursorModifier = 48, + occurrencesHighlight = 49, + overviewRulerBorder = 50, + overviewRulerLanes = 51, + parameterHints = 52, + quickSuggestions = 53, + quickSuggestionsDelay = 54, + readOnly = 55, + renderControlCharacters = 56, + renderIndentGuides = 57, + renderFinalNewline = 58, + renderLineHighlight = 59, + renderWhitespace = 60, + revealHorizontalRightPadding = 61, + roundedSelection = 62, + rulers = 63, + scrollbar = 64, + scrollBeyondLastColumn = 65, + scrollBeyondLastLine = 66, + selectionClipboard = 67, + selectionHighlight = 68, + selectOnLineNumbers = 69, + showFoldingControls = 70, + showUnused = 71, + snippetSuggestions = 72, + smoothScrolling = 73, + stopRenderingLineAfter = 74, + suggestFontSize = 75, + suggestLineHeight = 76, + suggestOnTriggerCharacters = 77, + suggestSelection = 78, + tabCompletion = 79, + useTabStops = 80, + wordSeparators = 81, + wordWrap = 82, + wordWrapBreakAfterCharacters = 83, + wordWrapBreakBeforeCharacters = 84, + wordWrapBreakObtrusiveCharacters = 85, + wordWrapColumn = 86, + wordWrapMinified = 87, + wrappingIndent = 88, + ariaLabel = 89, + disableMonospaceOptimizations = 90, + editorClassName = 91, + pixelRatio = 92, + tabFocusMode = 93, + suggest = 94, + layoutInfo = 95, + wrappingInfo = 96 } export const EditorOptions: { @@ -3623,6 +3628,7 @@ declare namespace monaco.editor { inDiffEditor: IEditorOption; lightbulb: IEditorOption; lineDecorationsWidth: IEditorOption; + lineHeight: IEditorOption; lineNumbers: IEditorOption; lineNumbersMinChars: IEditorOption; links: IEditorOption; @@ -3676,6 +3682,7 @@ declare namespace monaco.editor { ariaLabel: IEditorOption; disableMonospaceOptimizations: IEditorOption; editorClassName: IEditorOption; + pixelRatio: IEditorOption; tabFocusMode: IEditorOption; suggest: IEditorOption; layoutInfo: IEditorOption; diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 0bd28e5fe58f0..42d3d7a8a1438 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -44,6 +44,7 @@ import { ICommentService } from 'vs/workbench/contrib/comments/browser/commentSe import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys'; import { ICommentThreadWidget } from 'vs/workbench/contrib/comments/common/commentThreadWidget'; import { SimpleCommentEditor } from './simpleCommentEditor'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export const COMMENTEDITOR_DECORATION_KEY = 'commenteditordecoration'; const COLLAPSE_ACTION_CLASS = 'expand-review-action'; @@ -386,7 +387,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget this._disposables.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e))); this._disposables.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e))); - let headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2); + let headHeight = Math.ceil(this.editor.getOption(EditorOption.lineHeight) * 1.2); this._headElement.style.height = `${headHeight}px`; this._headElement.style.lineHeight = this._headElement.style.height; @@ -692,8 +693,8 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget _refresh() { if (this._isExpanded && this._bodyElement) { let dimensions = dom.getClientArea(this._bodyElement); - const headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2); - const lineHeight = this.editor.getConfiguration().lineHeight; + const headHeight = Math.ceil(this.editor.getOption(EditorOption.lineHeight) * 1.2); + const lineHeight = this.editor.getOption(EditorOption.lineHeight); const arrowHeight = Math.round(lineHeight / 3); const frameThickness = Math.round(lineHeight / 9) * 2; diff --git a/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts b/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts index 0d038ec13c90a..9191e39728b21 100644 --- a/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts +++ b/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts @@ -15,6 +15,7 @@ import { Color } from 'vs/base/common/color'; import { registerColor } from 'vs/platform/theme/common/colorRegistry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; const $ = dom.$; // theming @@ -89,7 +90,7 @@ export class ExceptionWidget extends ZoneWidget { // Reload the height with respect to the exception text content and relayout it to match the line count. this.container!.style.height = 'initial'; - const lineHeight = this.editor.getConfiguration().lineHeight; + const lineHeight = this.editor.getOption(EditorOption.lineHeight); const arrowHeight = Math.round(lineHeight / 3); const computedLinesNumber = Math.ceil((this.container!.offsetHeight + arrowHeight) / lineHeight); diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 7f66cba3d6278..2697f1a9e029a 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -202,10 +202,11 @@ export class SettingsGroupTitleWidget extends Widget implements IViewZone { private layout(): void { const configuration = this.editor.getConfiguration(); + const options = this.editor.getOptions(); const layoutInfo = this.editor.getLayoutInfo(); this._domNode.style.width = layoutInfo.contentWidth - layoutInfo.verticalScrollbarWidth + 'px'; - this.titleContainer.style.lineHeight = configuration.lineHeight + 3 + 'px'; - this.titleContainer.style.height = configuration.lineHeight + 3 + 'px'; + this.titleContainer.style.lineHeight = options.get(EditorOption.lineHeight) + 3 + 'px'; + this.titleContainer.style.height = options.get(EditorOption.lineHeight) + 3 + 'px'; this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; this.icon.style.minWidth = `${this.getIconSize(16)}px`; } diff --git a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts index 955579069d795..ec16eec903b11 100644 --- a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts +++ b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts @@ -33,7 +33,7 @@ import { rot } from 'vs/base/common/numbers'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { peekViewBorder, peekViewTitleBackground, peekViewTitleForeground, peekViewTitleInfoForeground } from 'vs/editor/contrib/referenceSearch/referencesWidget'; import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; -import { IDiffEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IDiffEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Action, IAction, ActionRunner } from 'vs/base/common/actions'; import { IActionBarOptions, ActionsOrientation, IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -223,7 +223,7 @@ class DirtyDiffWidget extends PeekViewWidget { const position = new Position(getModifiedEndLineNumber(change), 1); - const lineHeight = this.editor.getConfiguration().lineHeight; + const lineHeight = this.editor.getOption(EditorOption.lineHeight); const editorHeight = this.editor.getLayoutInfo().height; const editorHeightInLines = Math.floor(editorHeight / lineHeight); const height = Math.min(getChangeHeight(change) + /* padding */ 8, Math.floor(editorHeightInLines / 3)); diff --git a/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts b/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts index 9a0ed0de1141f..089c2bb1a46f3 100644 --- a/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts +++ b/src/vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart.ts @@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { Event } from 'vs/base/common/event'; import { isObject } from 'vs/base/common/types'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; -import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { registerColor, focusBorder, textLinkForeground, textLinkActiveForeground, textPreformatForeground, contrastBorder, textBlockQuoteBackground, textBlockQuoteBorder } from 'vs/platform/theme/common/colorRegistry'; import { getExtraColor } from 'vs/workbench/contrib/welcome/walkThrough/common/walkThroughUtils'; @@ -312,7 +312,7 @@ export class WalkThroughPart extends BaseEditor { this.contentDisposables.push(editor); const updateHeight = (initial: boolean) => { - const lineHeight = editor.getConfiguration().lineHeight; + const lineHeight = editor.getOption(EditorOption.lineHeight); const height = `${Math.max(model.getLineCount() + 1, 4) * lineHeight}px`; if (div.style.height !== height) { div.style.height = height; @@ -329,7 +329,7 @@ export class WalkThroughPart extends BaseEditor { if (innerContent) { const targetTop = div.getBoundingClientRect().top; const containerTop = innerContent.getBoundingClientRect().top; - const lineHeight = editor.getConfiguration().lineHeight; + const lineHeight = editor.getOption(EditorOption.lineHeight); const lineTop = (targetTop + (e.position.lineNumber - 1) * lineHeight) - containerTop; const lineBottom = lineTop + lineHeight; const scrollDimensions = this.scrollbar.getScrollDimensions(); From 11176da04d448305e9abea1ceec44b6ad214a0e5 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 13:33:08 +0200 Subject: [PATCH 092/204] fixes #80386 --- src/vs/base/browser/ui/inputbox/inputBox.css | 4 ++++ src/vs/base/browser/ui/inputbox/inputBox.ts | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vs/base/browser/ui/inputbox/inputBox.css b/src/vs/base/browser/ui/inputbox/inputBox.css index d13e1f2e53595..ae4cd429a0754 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.css +++ b/src/vs/base/browser/ui/inputbox/inputBox.css @@ -64,6 +64,10 @@ outline: none; } +.monaco-inputbox > .wrapper > textarea.input.empty { + white-space: nowrap; +} + .monaco-inputbox > .wrapper > textarea.input::-webkit-scrollbar { display: none; } diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index cae97a6aea0c5..a326d0211b499 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -159,7 +159,7 @@ export class InputBox extends Widget { let tagName = this.options.flexibleHeight ? 'textarea' : 'input'; let wrapper = dom.append(this.element, $('.wrapper')); - this.input = dom.append(wrapper, $(tagName + '.input')); + this.input = dom.append(wrapper, $(tagName + '.input.empty')); this.input.setAttribute('autocorrect', 'off'); this.input.setAttribute('autocapitalize', 'off'); this.input.setAttribute('spellcheck', 'false'); @@ -507,6 +507,7 @@ export class InputBox extends Widget { this.validate(); this.updateMirror(); + dom.toggleClass(this.input, 'empty', !this.value); if (this.state === 'open' && this.contextViewProvider) { this.contextViewProvider.layout(); @@ -518,7 +519,7 @@ export class InputBox extends Widget { return; } - const value = this.value || this.placeholder; + const value = this.value; const lastCharCode = value.charCodeAt(value.length - 1); const suffix = lastCharCode === 10 ? ' ' : ''; const mirrorTextContent = value + suffix; From d0898d57d4ba950cece5aad11eb06f9ce1bb4f0a Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 13:47:42 +0200 Subject: [PATCH 093/204] fixes #80336 --- src/vs/base/browser/ui/splitview/splitview.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/base/browser/ui/splitview/splitview.css b/src/vs/base/browser/ui/splitview/splitview.css index 75e686cb5fcfc..e5baba1f32a49 100644 --- a/src/vs/base/browser/ui/splitview/splitview.css +++ b/src/vs/base/browser/ui/splitview/splitview.css @@ -42,7 +42,6 @@ .monaco-split-view2.horizontal > .split-view-container > .split-view-view { height: 100%; - display: inline-block; } .monaco-split-view2.separator-border > .split-view-container > .split-view-view:not(:first-child)::before { From ca4c1bf7a0268ca7abaaf4bb7b99ba18dab8328d Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 14:59:08 +0200 Subject: [PATCH 094/204] Go to ext host for system default shell and args for tasks Fixes https://github.com/microsoft/vscode-remote-release/issues/1203 --- src/vs/workbench/api/browser/mainThreadTask.ts | 3 +++ src/vs/workbench/api/common/extHost.protocol.ts | 1 + src/vs/workbench/api/node/extHostTask.ts | 4 ++++ src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts | 2 +- src/vs/workbench/contrib/tasks/common/taskSystem.ts | 3 ++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadTask.ts b/src/vs/workbench/api/browser/mainThreadTask.ts index 7934efb088bb4..6fc2d150952cd 100644 --- a/src/vs/workbench/api/browser/mainThreadTask.ts +++ b/src/vs/workbench/api/browser/mainThreadTask.ts @@ -626,6 +626,9 @@ export class MainThreadTask implements MainThreadTaskShape { }); }); }); + }, + getDefaultShellAndArgs: (): Promise<{ shell: string, args: string[] | string | undefined }> => { + return Promise.resolve(this._proxy.$getDefaultShellAndArgs()); } }); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index fa06f7545ac79..d208aca0e8c12 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1185,6 +1185,7 @@ export interface ExtHostTaskShape { $onDidEndTaskProcess(value: tasks.TaskProcessEndedDTO): void; $OnDidEndTask(execution: tasks.TaskExecutionDTO): void; $resolveVariables(workspaceFolder: UriComponents, toResolve: { process?: { name: string; cwd?: string }, variables: string[] }): Promise<{ process?: string; variables: { [key: string]: string } }>; + $getDefaultShellAndArgs(): Thenable<{ shell: string, args: string[] | string | undefined }>; } export interface IBreakpointDto { diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 2e1941175989a..ccf856d9d80bf 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -659,6 +659,10 @@ export class ExtHostTask implements ExtHostTaskShape { return result; } + public $getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> { + return this._terminalService.$requestDefaultShellAndArgs(true); + } + private nextHandle(): number { return this._handleCounter++; } diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index e268caeeab693..f03460bfdeef7 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -778,7 +778,7 @@ export class TerminalTaskSystem implements ITaskSystem { let terminalName = this.createTerminalName(task); let originalCommand = task.command.name; if (isShellCommand) { - const defaultConfig = await this.terminalInstanceService.getDefaultShellAndArgs(true, platform); + const defaultConfig = variableResolver.taskSystemInfo ? await variableResolver.taskSystemInfo.getDefaultShellAndArgs() : await this.terminalInstanceService.getDefaultShellAndArgs(true, platform); shellLaunchConfig = { name: terminalName, executable: defaultConfig.shell, args: defaultConfig.args, waitOnExit }; let shellSpecified: boolean = false; let shellOptions: ShellConfiguration | undefined = task.command.options && task.command.options.shell; diff --git a/src/vs/workbench/contrib/tasks/common/taskSystem.ts b/src/vs/workbench/contrib/tasks/common/taskSystem.ts index e1ffe3a49c2da..c844be5ec2674 100644 --- a/src/vs/workbench/contrib/tasks/common/taskSystem.ts +++ b/src/vs/workbench/contrib/tasks/common/taskSystem.ts @@ -119,6 +119,7 @@ export interface TaskSystemInfo { context: any; uriProvider: (this: void, path: string) => URI; resolveVariables(workspaceFolder: IWorkspaceFolder, toResolve: ResolveSet): Promise; + getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }>; } export interface TaskSystemInfoResolver { @@ -137,4 +138,4 @@ export interface ITaskSystem { terminateAll(): Promise; revealTask(task: Task): boolean; customExecutionComplete(task: Task, result: number): Promise; -} \ No newline at end of file +} From 27adb78b9d91a8f697a8cb2901610e897b34cf73 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 15:18:07 +0200 Subject: [PATCH 095/204] Migrate fontInfo to the new editor option format --- .../editor/browser/controller/mouseTarget.ts | 4 +- .../browser/controller/textAreaHandler.ts | 6 +- src/vs/editor/browser/editorBrowser.ts | 6 +- src/vs/editor/browser/view/viewOverlays.ts | 4 +- .../viewParts/decorations/decorations.ts | 6 +- .../viewParts/indentGuides/indentGuides.ts | 10 +- .../browser/viewParts/lines/viewLine.ts | 7 +- .../browser/viewParts/lines/viewLines.ts | 11 +- .../browser/viewParts/minimap/minimap.ts | 2 +- .../editor/browser/viewParts/rulers/rulers.ts | 4 +- .../viewParts/selections/selections.ts | 4 +- .../viewParts/viewCursors/viewCursor.ts | 10 +- .../editor/browser/widget/codeEditorWidget.ts | 12 +- .../editor/browser/widget/diffEditorWidget.ts | 24 +- src/vs/editor/browser/widget/diffReview.ts | 25 +- .../widget/embeddedCodeEditorWidget.ts | 8 +- .../common/config/commonEditorConfig.ts | 78 +++--- src/vs/editor/common/config/editorOptions.ts | 232 ++++++------------ src/vs/editor/common/config/fontInfo.ts | 93 ++----- .../editor/common/controller/cursorCommon.ts | 4 +- src/vs/editor/common/editorCommon.ts | 13 +- .../common/standalone/standaloneEnums.ts | 145 +++++------ src/vs/editor/common/view/viewEvents.ts | 8 +- src/vs/editor/common/viewLayout/viewLayout.ts | 6 +- .../editor/common/viewModel/viewModelImpl.ts | 14 +- .../contrib/codeAction/lightBulbWidget.ts | 6 +- .../contrib/codelens/codelensController.ts | 2 +- .../editor/contrib/codelens/codelensWidget.ts | 2 +- src/vs/editor/contrib/find/findWidget.ts | 4 +- src/vs/editor/contrib/folding/folding.ts | 4 +- .../contrib/gotoError/gotoErrorWidget.ts | 2 +- src/vs/editor/contrib/hover/hover.ts | 6 +- src/vs/editor/contrib/hover/hoverWidgets.ts | 12 +- .../contrib/markdown/markdownRenderer.ts | 3 +- .../parameterHints/parameterHintsWidget.ts | 10 +- .../editor/contrib/rename/renameInputField.ts | 4 +- .../editor/contrib/suggest/suggestWidget.ts | 35 ++- .../standalone/browser/standaloneEditor.ts | 6 +- .../common/config/commonEditorConfig.test.ts | 4 +- .../viewModel/splitLinesCollection.test.ts | 6 +- src/vs/monaco.d.ts | 171 ++++++------- .../browser/parts/editor/editorStatus.ts | 4 +- .../codeEditor/browser/selectionClipboard.ts | 4 +- .../comments/browser/commentThreadWidget.ts | 4 +- .../contrib/debug/browser/debugHover.ts | 6 +- .../contrib/debug/browser/exceptionWidget.ts | 2 +- .../preferences/browser/preferencesWidgets.ts | 10 +- 47 files changed, 473 insertions(+), 570 deletions(-) diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index 4ec958948b249..c025c958a0fea 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -243,7 +243,7 @@ export class HitTestContext { this.layoutInfo = options.get(EditorOption.layoutInfo); this.viewDomNode = viewHelper.viewDomNode; this.lineHeight = options.get(EditorOption.lineHeight); - this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this.typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; this.lastViewCursorsRenderData = lastViewCursorsRenderData; this._context = context; this._viewHelper = viewHelper; @@ -717,7 +717,7 @@ export class MouseTargetFactory { const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); const mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft; - return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); + return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth); } public static _getMouseColumn(mouseContentHorizontalOffset: number, typicalHalfwidthCharacterWidth: number): number { diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index 18902d71eb90f..c65043b9515ab 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -121,7 +121,6 @@ export class TextAreaHandler extends ViewPart { this._scrollLeft = 0; this._scrollTop = 0; - const conf = this._context.configuration.editor; const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); @@ -129,7 +128,7 @@ export class TextAreaHandler extends ViewPart { this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; - this._fontInfo = conf.fontInfo; + this._fontInfo = options.get(EditorOption.fontInfo); this._lineHeight = options.get(EditorOption.lineHeight); this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); @@ -374,7 +373,6 @@ export class TextAreaHandler extends ViewPart { // --- begin event handlers public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - const conf = this._context.configuration.editor; const options = this._context.configuration.options; const layoutInfo = options.get(EditorOption.layoutInfo); @@ -382,7 +380,7 @@ export class TextAreaHandler extends ViewPart { this._contentLeft = layoutInfo.contentLeft; this._contentWidth = layoutInfo.contentWidth; this._contentHeight = layoutInfo.contentHeight; - this._fontInfo = conf.fontInfo; + this._fontInfo = options.get(EditorOption.fontInfo); this._lineHeight = options.get(EditorOption.lineHeight); this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard); this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting); diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index c8f7a8ee5caa8..0fa2f3379216d 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -6,7 +6,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IMouseEvent, IMouseWheelEvent } from 'vs/base/browser/mouseEvent'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { OverviewRulerPosition, IConfigurationChangedEvent, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { OverviewRulerPosition, ConfigurationChangedEvent, EditorLayoutInfo, IComputedEditorOptions, EditorOption, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { IPosition, Position } from 'vs/editor/common/core/position'; @@ -351,7 +351,7 @@ export interface ICodeEditor extends editorCommon.IEditor { * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) * @event */ - onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; + onDidChangeConfiguration(listener: (e: ConfigurationChangedEvent) => void): IDisposable; /** * An event emitted when the cursor position has changed. * @event @@ -534,8 +534,6 @@ export interface ICodeEditor extends editorCommon.IEditor { /** * Returns the current editor's configuration */ - getConfiguration(): InternalEditorOptions; - getOptions(): IComputedEditorOptions; getOption(id: T): FindComputedEditorOptionValueById; diff --git a/src/vs/editor/browser/view/viewOverlays.ts b/src/vs/editor/browser/view/viewOverlays.ts index 43a6a96f830b9..130f1f09fae81 100644 --- a/src/vs/editor/browser/view/viewOverlays.ts +++ b/src/vs/editor/browser/view/viewOverlays.ts @@ -257,12 +257,12 @@ export class MarginViewOverlays extends ViewOverlays { this.domNode.setClassName('margin-view-overlays'); this.domNode.setWidth(1); - Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); + Configuration.applyFontInfo(this.domNode, options.get(EditorOption.fontInfo)); } public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { - Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo); const options = this._context.configuration.options; + Configuration.applyFontInfo(this.domNode, options.get(EditorOption.fontInfo)); const layoutInfo = options.get(EditorOption.layoutInfo); this._contentLeft = layoutInfo.contentLeft; return super.onConfigurationChanged(e) || true; diff --git a/src/vs/editor/browser/viewParts/decorations/decorations.ts b/src/vs/editor/browser/viewParts/decorations/decorations.ts index 2e0627b2b9456..7ba289755194a 100644 --- a/src/vs/editor/browser/viewParts/decorations/decorations.ts +++ b/src/vs/editor/browser/viewParts/decorations/decorations.ts @@ -24,7 +24,7 @@ export class DecorationsOverlay extends DynamicViewOverlay { this._context = context; const options = this._context.configuration.options; this._lineHeight = options.get(EditorOption.lineHeight); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; this._renderResult = null; this._context.addEventHandler(this); @@ -41,9 +41,7 @@ export class DecorationsOverlay extends DynamicViewOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; this._lineHeight = options.get(EditorOption.lineHeight); - if (e.fontInfo) { - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; - } + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; return true; } public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts index 762c8dff7135f..6af61888a62b8 100644 --- a/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts +++ b/src/vs/editor/browser/viewParts/indentGuides/indentGuides.ts @@ -32,12 +32,13 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); + const fontInfo = options.get(EditorOption.fontInfo); this._lineHeight = options.get(EditorOption.lineHeight); - this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; + this._spaceWidth = fontInfo.spaceWidth; this._enabled = options.get(EditorOption.renderIndentGuides); this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); - this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); + this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth); this._renderResult = null; @@ -55,12 +56,13 @@ export class IndentGuidesOverlay extends DynamicViewOverlay { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); + const fontInfo = options.get(EditorOption.fontInfo); this._lineHeight = options.get(EditorOption.lineHeight); - this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth; + this._spaceWidth = fontInfo.spaceWidth; this._enabled = options.get(EditorOption.renderIndentGuides); this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide); - this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth); + this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth); return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index f337db9c1f857..79b99d939a4d8 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -82,14 +82,15 @@ export class ViewLineOptions { constructor(config: IConfiguration, themeType: ThemeType) { this.themeType = themeType; const options = config.options; + const fontInfo = options.get(EditorOption.fontInfo); this.renderWhitespace = options.get(EditorOption.renderWhitespace); this.renderControlCharacters = options.get(EditorOption.renderControlCharacters); - this.spaceWidth = config.editor.fontInfo.spaceWidth; + this.spaceWidth = fontInfo.spaceWidth; this.useMonospaceOptimizations = ( - config.editor.fontInfo.isMonospace + fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations) ); - this.canUseHalfwidthRightwardsArrow = config.editor.fontInfo.canUseHalfwidthRightwardsArrow; + this.canUseHalfwidthRightwardsArrow = fontInfo.canUseHalfwidthRightwardsArrow; this.lineHeight = options.get(EditorOption.lineHeight); this.stopRenderingLineAfter = options.get(EditorOption.stopRenderingLineAfter); this.fontLigatures = options.get(EditorOption.fontLigatures); diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index 092cb3c9a705e..eb524a41b69f3 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -94,10 +94,11 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, const conf = this._context.configuration; const options = this._context.configuration.options; + const fontInfo = options.get(EditorOption.fontInfo); const wrappingInfo = options.get(EditorOption.wrappingInfo); this._lineHeight = options.get(EditorOption.lineHeight); - this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; this._isViewportWrapping = wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines); @@ -107,7 +108,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, PartFingerprints.write(this.domNode, PartFingerprint.ViewLines); this.domNode.setClassName('view-lines'); - Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo); + Configuration.applyFontInfo(this.domNode, fontInfo); // --- width & height this._maxLineWidth = 0; @@ -145,17 +146,17 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, this._maxLineWidth = 0; } - const conf = this._context.configuration; const options = this._context.configuration.options; + const fontInfo = options.get(EditorOption.fontInfo); const wrappingInfo = options.get(EditorOption.wrappingInfo); this._lineHeight = options.get(EditorOption.lineHeight); - this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; this._isViewportWrapping = wrappingInfo.isViewportWrapping; this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding); this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines); this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting); - Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo); + Configuration.applyFontInfo(this.domNode, fontInfo); this._onOptionsMaybeChanged(); diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 2550266af7692..d7fb6e544086d 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -110,7 +110,7 @@ class MinimapOptions { const options = configuration.options; const pixelRatio = options.get(EditorOption.pixelRatio); const layoutInfo = options.get(EditorOption.layoutInfo); - const fontInfo = configuration.editor.fontInfo; + const fontInfo = options.get(EditorOption.fontInfo); this.renderMinimap = layoutInfo.renderMinimap | 0; this.scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine); diff --git a/src/vs/editor/browser/viewParts/rulers/rulers.ts b/src/vs/editor/browser/viewParts/rulers/rulers.ts index 3c9f9cf6bb543..0f22de06a7372 100644 --- a/src/vs/editor/browser/viewParts/rulers/rulers.ts +++ b/src/vs/editor/browser/viewParts/rulers/rulers.ts @@ -29,7 +29,7 @@ export class Rulers extends ViewPart { this._renderedRulers = []; const options = this._context.configuration.options; this._rulers = options.get(EditorOption.rulers); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; } public dispose(): void { @@ -41,7 +41,7 @@ export class Rulers extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; this._rulers = options.get(EditorOption.rulers); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; return true; } public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/selections/selections.ts b/src/vs/editor/browser/viewParts/selections/selections.ts index b960faf575117..f059e95dbb127 100644 --- a/src/vs/editor/browser/viewParts/selections/selections.ts +++ b/src/vs/editor/browser/viewParts/selections/selections.ts @@ -87,7 +87,7 @@ export class SelectionsOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; this._lineHeight = options.get(EditorOption.lineHeight); this._roundedSelection = options.get(EditorOption.roundedSelection); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; this._selections = []; this._renderResult = null; this._context.addEventHandler(this); @@ -105,7 +105,7 @@ export class SelectionsOverlay extends DynamicViewOverlay { const options = this._context.configuration.options; this._lineHeight = options.get(EditorOption.lineHeight); this._roundedSelection = options.get(EditorOption.roundedSelection); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; return true; } public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index be49b426a8d13..09648af24a8f9 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -52,10 +52,11 @@ export class ViewCursor { constructor(context: ViewContext) { this._context = context; const options = this._context.configuration.options; + const fontInfo = options.get(EditorOption.fontInfo); this._cursorStyle = options.get(EditorOption.cursorStyle); this._lineHeight = options.get(EditorOption.lineHeight); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); this._isVisible = true; @@ -66,7 +67,7 @@ export class ViewCursor { this._domNode.setHeight(this._lineHeight); this._domNode.setTop(0); this._domNode.setLeft(0); - Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); + Configuration.applyFontInfo(this._domNode, fontInfo); this._domNode.setDisplay('none'); this._position = new Position(1, 1); @@ -99,12 +100,13 @@ export class ViewCursor { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { const options = this._context.configuration.options; + const fontInfo = options.get(EditorOption.fontInfo); this._cursorStyle = options.get(EditorOption.cursorStyle); this._lineHeight = options.get(EditorOption.lineHeight); - this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth); - Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); + Configuration.applyFontInfo(this._domNode, fontInfo); return true; } diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 730a5c027f8fc..3170cdb2b665d 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { ICommandDelegate } from 'vs/editor/browser/view/viewController'; import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl'; import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents'; -import { IConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, InternalEditorOptions, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; import { Cursor, CursorStateChangedEvent } from 'vs/editor/common/controller/cursor'; import { CursorColumns, ICursors } from 'vs/editor/common/controller/cursorCommon'; import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; @@ -125,8 +125,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE private readonly _onDidChangeModelDecorations: Emitter = this._register(new Emitter()); public readonly onDidChangeModelDecorations: Event = this._onDidChangeModelDecorations.event; - private readonly _onDidChangeConfiguration: Emitter = this._register(new Emitter()); - public readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; + private readonly _onDidChangeConfiguration: Emitter = this._register(new Emitter()); + public readonly onDidChangeConfiguration: Event = this._onDidChangeConfiguration.event; protected readonly _onDidChangeModel: Emitter = this._register(new Emitter()); public readonly onDidChangeModel: Event = this._onDidChangeModel.event; @@ -368,10 +368,6 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE this._configuration.updateOptions(newOptions); } - public getConfiguration(): InternalEditorOptions { - return this._configuration.editor; - } - public getOptions(): IComputedEditorOptions { return this._configuration.options; } @@ -1308,7 +1304,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } public applyFontInfo(target: HTMLElement): void { - Configuration.applyFontInfoSlow(target, this._configuration.editor.fontInfo); + Configuration.applyFontInfoSlow(target, this._configuration.options.get(EditorOption.fontInfo)); } protected _attachModel(model: ITextModel | null): void { diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index 93f4e5444259e..3e6e67a65a013 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -20,7 +20,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { DiffReview } from 'vs/editor/browser/widget/diffReview'; -import { IDiffEditorOptions, IEditorOptions, EditorLayoutInfo, InternalEditorOptions, IComputedEditorOptions, EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions'; +import { IDiffEditorOptions, IEditorOptions, EditorLayoutInfo, IComputedEditorOptions, EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -480,7 +480,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE })); this._register(editor.onDidChangeConfiguration((e) => { - if (e.fontInfo && editor.getModel()) { + if (e.hasChanged(EditorOption.fontInfo) && editor.getModel()) { this._onViewZonesChanged(); } })); @@ -1946,7 +1946,6 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito class InlineViewZonesComputer extends ViewZonesComputer { private readonly originalModel: ITextModel; - private readonly modifiedEditorConfiguration: InternalEditorOptions; private readonly modifiedEditorOptions: IComputedEditorOptions; private readonly modifiedEditorTabSize: number; private readonly renderIndicators: boolean; @@ -1954,7 +1953,6 @@ class InlineViewZonesComputer extends ViewZonesComputer { constructor(lineChanges: editorCommon.ILineChange[], originalForeignVZ: IEditorWhitespace[], modifiedForeignVZ: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor, renderIndicators: boolean) { super(lineChanges, originalForeignVZ, modifiedForeignVZ); this.originalModel = originalEditor.getModel()!; - this.modifiedEditorConfiguration = modifiedEditor.getConfiguration(); this.modifiedEditorOptions = modifiedEditor.getOptions(); this.modifiedEditorTabSize = modifiedEditor.getModel()!.getOptions().tabSize; this.renderIndicators = renderIndicators; @@ -1996,14 +1994,15 @@ class InlineViewZonesComputer extends ViewZonesComputer { let sb = createStringBuilder(10000); let marginHTML: string[] = []; const layoutInfo = this.modifiedEditorOptions.get(EditorOption.layoutInfo); + const fontInfo = this.modifiedEditorOptions.get(EditorOption.fontInfo); const lineDecorationsWidth = layoutInfo.decorationsWidth; let lineHeight = this.modifiedEditorOptions.get(EditorOption.lineHeight); - const typicalHalfwidthCharacterWidth = this.modifiedEditorConfiguration.fontInfo.typicalHalfwidthCharacterWidth; + const typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth; let maxCharsPerLine = 0; const originalContent: string[] = []; for (let lineNumber = lineChange.originalStartLineNumber; lineNumber <= lineChange.originalEndLineNumber; lineNumber++) { - maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorConfiguration, this.modifiedEditorOptions, this.modifiedEditorTabSize, lineNumber, decorations, sb)); + maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorOptions, this.modifiedEditorTabSize, lineNumber, decorations, sb)); originalContent.push(this.originalModel.getLineContent(lineNumber)); if (this.renderIndicators) { @@ -2018,12 +2017,12 @@ class InlineViewZonesComputer extends ViewZonesComputer { let domNode = document.createElement('div'); domNode.className = 'view-lines line-delete'; domNode.innerHTML = sb.build(); - Configuration.applyFontInfoSlow(domNode, this.modifiedEditorConfiguration.fontInfo); + Configuration.applyFontInfoSlow(domNode, fontInfo); let marginDomNode = document.createElement('div'); marginDomNode.className = 'inline-deleted-margin-view-zone'; marginDomNode.innerHTML = marginHTML.join(''); - Configuration.applyFontInfoSlow(marginDomNode, this.modifiedEditorConfiguration.fontInfo); + Configuration.applyFontInfoSlow(marginDomNode, fontInfo); return { shouldNotShrink: true, @@ -2042,9 +2041,10 @@ class InlineViewZonesComputer extends ViewZonesComputer { }; } - private _renderOriginalLine(count: number, originalModel: ITextModel, config: InternalEditorOptions, options: IComputedEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { + private _renderOriginalLine(count: number, originalModel: ITextModel, options: IComputedEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number { const lineTokens = originalModel.getLineTokens(lineNumber); const lineContent = lineTokens.getLineContent(); + const fontInfo = options.get(EditorOption.fontInfo); const actualDecorations = LineDecoration.filter(decorations, lineNumber, 1, lineContent.length + 1); @@ -2060,8 +2060,8 @@ class InlineViewZonesComputer extends ViewZonesComputer { const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, originalModel.mightContainNonBasicASCII()); const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, originalModel.mightContainRTL()); const output = renderViewLine(new RenderLineInput( - (config.fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), - config.fontInfo.canUseHalfwidthRightwardsArrow, + (fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), + fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, isBasicASCII, @@ -2070,7 +2070,7 @@ class InlineViewZonesComputer extends ViewZonesComputer { lineTokens, actualDecorations, tabSize, - config.fontInfo.spaceWidth, + fontInfo.spaceWidth, options.get(EditorOption.stopRenderingLineAfter), options.get(EditorOption.renderWhitespace), options.get(EditorOption.renderControlCharacters), diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index c2b32e4c5ae65..81e1de6d6a68a 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -17,7 +17,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget'; -import { InternalEditorOptions, IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { LineTokens } from 'vs/editor/common/core/lineTokens'; import { Position } from 'vs/editor/common/core/position'; import { ILineChange, ScrollType } from 'vs/editor/common/editorCommon'; @@ -524,9 +524,7 @@ export class DiffReview extends Disposable { private _render(): void { - const originalOpts = this._diffEditor.getOriginalEditor().getConfiguration(); const originalOptions = this._diffEditor.getOriginalEditor().getOptions(); - const modifiedOpts = this._diffEditor.getModifiedEditor().getConfiguration(); const modifiedOptions = this._diffEditor.getModifiedEditor().getOptions(); const originalModel = this._diffEditor.getOriginalEditor().getModel(); @@ -553,7 +551,7 @@ export class DiffReview extends Disposable { let container = document.createElement('div'); container.className = 'diff-review-table'; container.setAttribute('role', 'list'); - Configuration.applyFontInfoSlow(container, modifiedOpts.fontInfo); + Configuration.applyFontInfoSlow(container, modifiedOptions.get(EditorOption.fontInfo)); let minOriginalLine = 0; let maxOriginalLine = 0; @@ -622,7 +620,7 @@ export class DiffReview extends Disposable { let modLine = minModifiedLine; for (let i = 0, len = diffs.length; i < len; i++) { const diffEntry = diffs[i]; - DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOpts, originalOptions, originalModel, originalModelOpts, modifiedOpts, modifiedOptions, modifiedModel, modifiedModelOpts); + DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOptions, originalModel, originalModelOpts, modifiedOptions, modifiedModel, modifiedModelOpts); if (diffEntry.modifiedLineStart !== 0) { modLine = diffEntry.modifiedLineEnd; } @@ -635,8 +633,8 @@ export class DiffReview extends Disposable { private static _renderSection( dest: HTMLElement, diffEntry: DiffEntry, modLine: number, width: number, - originalOpts: InternalEditorOptions, originalOptions: IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, - modifiedOpts: InternalEditorOptions, modifiedOptions: IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions + originalOptions: IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions, + modifiedOptions: IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions ): void { const type = diffEntry.getType(); @@ -721,12 +719,12 @@ export class DiffReview extends Disposable { let lineContent: string; if (modifiedLine !== 0) { cell.insertAdjacentHTML('beforeend', - this._renderLine(modifiedModel, modifiedOpts, modifiedOptions, modifiedModelOpts.tabSize, modifiedLine) + this._renderLine(modifiedModel, modifiedOptions, modifiedModelOpts.tabSize, modifiedLine) ); lineContent = modifiedModel.getLineContent(modifiedLine); } else { cell.insertAdjacentHTML('beforeend', - this._renderLine(originalModel, originalOpts, originalOptions, originalModelOpts.tabSize, originalLine) + this._renderLine(originalModel, originalOptions, originalModelOpts.tabSize, originalLine) ); lineContent = originalModel.getLineContent(originalLine); } @@ -753,8 +751,9 @@ export class DiffReview extends Disposable { } } - private static _renderLine(model: ITextModel, config: InternalEditorOptions, options: IComputedEditorOptions, tabSize: number, lineNumber: number): string { + private static _renderLine(model: ITextModel, options: IComputedEditorOptions, tabSize: number, lineNumber: number): string { const lineContent = model.getLineContent(lineNumber); + const fontInfo = options.get(EditorOption.fontInfo); const defaultMetadata = ( (FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET) @@ -771,8 +770,8 @@ export class DiffReview extends Disposable { const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, model.mightContainNonBasicASCII()); const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, model.mightContainRTL()); const r = renderViewLine(new RenderLineInput( - (config.fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), - config.fontInfo.canUseHalfwidthRightwardsArrow, + (fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations)), + fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, isBasicASCII, @@ -781,7 +780,7 @@ export class DiffReview extends Disposable { lineTokens, [], tabSize, - config.fontInfo.spaceWidth, + fontInfo.spaceWidth, options.get(EditorOption.stopRenderingLineAfter), options.get(EditorOption.renderWhitespace), options.get(EditorOption.renderControlCharacters), diff --git a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts index 2f36d8e97656d..5e63eaa066947 100644 --- a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts +++ b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts @@ -8,7 +8,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget'; -import { IConfigurationChangedEvent, IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; @@ -44,14 +44,14 @@ export class EmbeddedCodeEditorWidget extends CodeEditorWidget { // Overwrite parent's options super.updateOptions(this._overwriteOptions); - this._register(parentEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => this._onParentConfigurationChanged(e))); + this._register(parentEditor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => this._onParentConfigurationChanged(e))); } getParentEditor(): ICodeEditor { return this._parentEditor; } - private _onParentConfigurationChanged(e: IConfigurationChangedEvent): void { + private _onParentConfigurationChanged(e: ConfigurationChangedEvent): void { super.updateOptions(this._parentEditor.getRawConfiguration()); super.updateOptions(this._overwriteOptions); } @@ -95,7 +95,7 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget { return this._parentEditor; } - private _onParentConfigurationChanged(e: IConfigurationChangedEvent): void { + private _onParentConfigurationChanged(e: ConfigurationChangedEvent): void { super.updateOptions(this._parentEditor.getRawConfiguration()); super.updateOptions(this._overwriteOptions); } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 686808bbd1cf4..f751b1bcbcf47 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; -import { IEditorOptions, RawEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ChangedEditorOptions, InternalEditorOptions, IConfigurationChangedEvent, InternalEditorOptionsFactory, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -60,21 +60,46 @@ export interface IEnvConfiguration { const hasOwnProperty = Object.hasOwnProperty; -export class EditorConfiguration2 { - public static readOptions(options: IEditorOptions): RawEditorOptions { - // console.log(`parseOptions`, options); +class RawEditorOptions { + private readonly _values: any[] = []; + public _read(id: EditorOption): T | undefined { + return this._values[id]; + } + public _write(id: EditorOption, value: T | undefined): void { + this._values[id] = value; + } +} + +class EditorConfiguration2 { + public static readOptions(_options: IEditorOptions): RawEditorOptions { + const options: { [key: string]: any; } = _options; const result = new RawEditorOptions(); for (const editorOption of editorOptionsRegistry) { - result._write(editorOption.id, editorOption.read(options)); + const value = options[editorOption.name]; + result._write(editorOption.id, value); } return result; } - public static mixOptions(a: RawEditorOptions, b: IEditorOptions): RawEditorOptions { - // console.log(`mixOptions`, a, b); + private static _mix(a: any, b: any): any { + switch (typeof b) { + case 'bigint': return b; + case 'boolean': return b; + case 'function': return b; + case 'number': return b; + case 'object': return (Array.isArray(b) || typeof a !== 'object' ? b : objects.mixin(objects.mixin({}, a), b)); + case 'string': return b; + default: + return a; + } + } + + public static mixOptions(a: RawEditorOptions, _b: IEditorOptions): RawEditorOptions { + const b: { [key: string]: any; } = _b; const result = new RawEditorOptions(); for (const editorOption of editorOptionsRegistry) { - result._write(editorOption.id, editorOption.mix(a._read(editorOption.id), editorOption.read(b))); + const bValue = b[editorOption.name]; + result._write(editorOption.id, EditorConfiguration2._mix(a._read(editorOption.id), bValue)); } return result; } @@ -97,18 +122,18 @@ export class EditorConfiguration2 { return result; } - public static checkEquals(a: ComputedEditorOptions, b: ComputedEditorOptions): ChangedEditorOptions | null { + public static checkEquals(a: ComputedEditorOptions, b: ComputedEditorOptions): ConfigurationChangedEvent | null { // console.log(`equals`, a, b); - const result = new ChangedEditorOptions(); + const result: boolean[] = []; let somethingChanged = false; for (const editorOption of editorOptionsRegistry) { const changed = !editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); - result._write(editorOption.id, changed); + result[editorOption.id] = changed; if (changed) { somethingChanged = true; } } - return (somethingChanged ? result : null); + return (somethingChanged ? new ConfigurationChangedEvent(result) : null); } } @@ -186,12 +211,11 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed public readonly isSimpleWidget: boolean; protected _rawOptions: IEditorOptions; - public editor!: InternalEditorOptions; private _isDominatedByLongLines: boolean; private _lineNumbersDigitCount: number; - private _onDidChange = this._register(new Emitter()); - public readonly onDidChange: Event = this._onDidChange.event; + private _onDidChange = this._register(new Emitter()); + public readonly onDidChange: Event = this._onDidChange.event; private _rawOptions2: RawEditorOptions; protected _validatedOptions2: ValidatedEditorOptions; @@ -229,21 +253,19 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed } protected _recomputeOptions(): void { - const oldOptions = this.editor; - const oldOptions2 = this.options; - const [newOptions, newOptions2] = this._computeInternalOptions(); + const oldOptions = this.options; + const newOptions = this._computeInternalOptions(); - const changeEvent = (oldOptions2 ? EditorConfiguration2.checkEquals(oldOptions2, newOptions2) : null); + const changeEvent = (oldOptions ? EditorConfiguration2.checkEquals(oldOptions, newOptions) : null); - if (oldOptions && oldOptions.equals(newOptions) && oldOptions2 && changeEvent === null) { + if (oldOptions && changeEvent === null) { return; } - this.editor = newOptions; - this.options = newOptions2; + this.options = newOptions; - if (oldOptions) { - this._onDidChange.fire(oldOptions.createChangeEvent(newOptions, changeEvent)); + if (changeEvent) { + this._onDidChange.fire(changeEvent); } } @@ -251,9 +273,9 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed return this._rawOptions; } - private _computeInternalOptions(): [InternalEditorOptions, ComputedEditorOptions] { + private _computeInternalOptions(): ComputedEditorOptions { const partialEnv = this._getEnvConfiguration(); - const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel, this.isSimpleWidget); + const bareFontInfo = BareFontInfo.createFromValidatedSettings(this._validatedOptions2, partialEnv.zoomLevel, this.isSimpleWidget); const env: IEnvironmentalOptions = { outerWidth: partialEnv.outerWidth, outerHeight: partialEnv.outerHeight, @@ -266,9 +288,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed tabFocusMode: TabFocus.getTabFocusMode(), accessibilitySupport: partialEnv.accessibilitySupport }; - const r = InternalEditorOptionsFactory.createInternalEditorOptions(env); - const r2 = EditorConfiguration2.computeOptions(this._validatedOptions2, env); - return [r, r2]; + return EditorConfiguration2.computeOptions(this._validatedOptions2, env); } private static _primitiveArrayEquals(a: any[], b: any[]): boolean { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index c88fa2db71c9f..a5ff1b8076886 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -700,7 +700,7 @@ export interface IEditorOptions { /** * The font weight */ - fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'; + fontWeight?: string; /** * The font size */ @@ -728,6 +728,10 @@ export type IExtendedEditorOptions = IEditorOptions & { * Do not use, this is a computed option. */ pixelRatio?: undefined; + /** + * Do not use, this is a computed option. + */ + fontInfo?: undefined; /** * Do not use, this is a computed option. */ @@ -868,89 +872,43 @@ export enum TextEditorCursorStyle { */ export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' { switch (cursorStyle) { - case TextEditorCursorStyle.Line: - return 'line'; - case TextEditorCursorStyle.Block: - return 'block'; - case TextEditorCursorStyle.Underline: - return 'underline'; - case TextEditorCursorStyle.LineThin: - return 'line-thin'; - case TextEditorCursorStyle.BlockOutline: - return 'block-outline'; - case TextEditorCursorStyle.UnderlineThin: - return 'underline-thin'; + case TextEditorCursorStyle.Line: return 'line'; + case TextEditorCursorStyle.Block: return 'block'; + case TextEditorCursorStyle.Underline: return 'underline'; + case TextEditorCursorStyle.LineThin: return 'line-thin'; + case TextEditorCursorStyle.BlockOutline: return 'block-outline'; + case TextEditorCursorStyle.UnderlineThin: return 'underline-thin'; } } function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle { switch (cursorStyle) { - case 'line': - return TextEditorCursorStyle.Line; - case 'block': - return TextEditorCursorStyle.Block; - case 'underline': - return TextEditorCursorStyle.Underline; - case 'line-thin': - return TextEditorCursorStyle.LineThin; - case 'block-outline': - return TextEditorCursorStyle.BlockOutline; - case 'underline-thin': - return TextEditorCursorStyle.UnderlineThin; + case 'line': return TextEditorCursorStyle.Line; + case 'block': return TextEditorCursorStyle.Block; + case 'underline': return TextEditorCursorStyle.Underline; + case 'line-thin': return TextEditorCursorStyle.LineThin; + case 'block-outline': return TextEditorCursorStyle.BlockOutline; + case 'underline-thin': return TextEditorCursorStyle.UnderlineThin; } } /** - * Internal configuration options (transformed or computed) for the editor. + * An event describing that the configuration of the editor has changed. */ -export class InternalEditorOptions { - readonly _internalEditorOptionsBrand: void; - - // ---- grouped options - readonly fontInfo: FontInfo; - +export class ConfigurationChangedEvent { + private readonly _values: boolean[]; /** * @internal */ - constructor(source: { - fontInfo: FontInfo; - }) { - this.fontInfo = source.fontInfo; + constructor(values: boolean[]) { + this._values = values; } - /** - * @internal - */ - public equals(other: InternalEditorOptions): boolean { - return ( - this.fontInfo.equals(other.fontInfo) - ); - } - - /** - * @internal - */ - public createChangeEvent(newOpts: InternalEditorOptions, changeEvent: ChangedEditorOptions | null): IConfigurationChangedEvent { - return { - hasChanged: (id: EditorOption) => { - if (!changeEvent) { - return false; - } - return changeEvent.get(id); - }, - fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)), - }; + public hasChanged(id: EditorOption): boolean { + return this._values[id]; } } -/** - * An event describing that the configuration of the editor has changed. - */ -export interface IConfigurationChangedEvent { - hasChanged(id: EditorOption): boolean; - readonly fontInfo: boolean; -} - export interface IEnvironmentalOptions { readonly outerWidth: number; readonly outerHeight: number; @@ -992,6 +950,16 @@ function _stringSet(value: T | undefined, defaultValue: T, allowedValues: T[] return value; } +function _clamp(n: number, min: number, max: number): number { + if (n < min) { + return min; + } + if (n > max) { + return max; + } + return n; +} + function _clampedInt(value: any, defaultValue: number, minimum: number, maximum: number): number { let r: number; if (typeof value === 'undefined') { @@ -1008,11 +976,14 @@ function _clampedInt(value: any, defaultValue: number, minimum: number, maximum: } function _float(value: any, defaultValue: number): number { - let r = parseFloat(value); - if (isNaN(r)) { - r = defaultValue; + if (typeof value === 'number') { + return value; } - return r; + if (typeof value === 'undefined') { + return defaultValue; + } + const r = parseFloat(value); + return (isNaN(r) ? defaultValue : r); } function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent { @@ -1026,16 +997,11 @@ function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle { switch (cursorBlinkingStyle) { - case 'blink': - return TextEditorCursorBlinkingStyle.Blink; - case 'smooth': - return TextEditorCursorBlinkingStyle.Smooth; - case 'phase': - return TextEditorCursorBlinkingStyle.Phase; - case 'expand': - return TextEditorCursorBlinkingStyle.Expand; - case 'solid': - return TextEditorCursorBlinkingStyle.Solid; + case 'blink': return TextEditorCursorBlinkingStyle.Blink; + case 'smooth': return TextEditorCursorBlinkingStyle.Smooth; + case 'phase': return TextEditorCursorBlinkingStyle.Phase; + case 'expand': return TextEditorCursorBlinkingStyle.Expand; + case 'solid': return TextEditorCursorBlinkingStyle.Solid; } } @@ -1044,24 +1010,9 @@ function _scrollbarVisibilityFromString(visibility: string | undefined, defaultV return defaultValue; } switch (visibility) { - case 'hidden': - return ScrollbarVisibility.Hidden; - case 'visible': - return ScrollbarVisibility.Visible; - default: - return ScrollbarVisibility.Auto; - } -} - -/** - * @internal - */ -export class InternalEditorOptionsFactory { - - public static createInternalEditorOptions(env: IEnvironmentalOptions) { - return new InternalEditorOptions({ - fontInfo: env.fontInfo, - }); + case 'hidden': return ScrollbarVisibility.Hidden; + case 'visible': return ScrollbarVisibility.Visible; + default: return ScrollbarVisibility.Auto; } } @@ -1134,19 +1085,6 @@ export interface IRawEditorOptionsBag extends IExtendedEditorOptions { [key: string]: any; } -/** - * @internal - */ -export class RawEditorOptions { - private readonly _values: any[] = []; - public _read(id: EditorOption): T | undefined { - return this._values[id]; - } - public _write(id: EditorOption, value: T | undefined): void { - this._values[id] = value; - } -} - /** * @internal */ @@ -1183,19 +1121,6 @@ export class ComputedEditorOptions implements IComputedEditorOptions { } } -/** - * @internal - */ -export class ChangedEditorOptions { - private readonly _values: boolean[] = []; - public get(id: EditorOption): boolean { - return this._values[id]; - } - public _write(id: EditorOption, value: boolean): void { - this._values[id] = value; - } -} - //#region IEditorOption /** @@ -1211,14 +1136,6 @@ export interface IEditorOptionthis.name]; - } - public mix(a: IExtendedEditorOptions[K2] | undefined, b: IExtendedEditorOptions[K2] | undefined): IExtendedEditorOptions[K2] | undefined { - switch (typeof b) { - case 'bigint': return b; - case 'boolean': return b; - case 'function': return b; - case 'number': return b; - case 'object': return (Array.isArray(b) || typeof a !== 'object' ? b : objects.mixin(objects.mixin({}, a), b)); - case 'string': return b; - default: - return a; - } - } public abstract validate(input: IExtendedEditorOptions[K2] | undefined): T2; public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; public equals(a: T3, b: T3): boolean { @@ -1652,10 +1554,7 @@ class EditorPixelRatio> extends BaseEditorOption { - public validate(input: number | undefined): number { - return this.defaultValue; - } +class EditorLineHeight> extends EditorIntOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { return env.fontInfo.lineHeight; } @@ -1663,6 +1562,22 @@ class EditorLineHeight> extends BaseEditorOption { + public validate(input: number | undefined): undefined { + return undefined; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): FontInfo { + return env.fontInfo; + } + public equals(a: FontInfo, b: FontInfo): boolean { + return a.equals(b); + } +} + +//#endregion + //#region emptySelectionClipboard class EditorEmptySelectionClipboard> extends EditorBooleanOption { @@ -2265,9 +2180,6 @@ export interface EditorWrappingInfo { } class EditorWrappingInfoComputer> extends BaseEditorOption { - public mix(a: undefined, b: undefined): undefined { - return undefined; - } public validate(input: undefined): undefined { return undefined; } @@ -2388,7 +2300,11 @@ export const enum EditorOption { fixedOverflowWidgets, folding, foldingStrategy, + fontFamily, + fontInfo, fontLigatures, + fontSize, + fontWeight, formatOnPaste, formatOnType, glyphMargin, @@ -2397,6 +2313,7 @@ export const enum EditorOption { highlightActiveIndentGuide, hover, inDiffEditor, + letterSpacing, lightbulb, lineDecorationsWidth, lineHeight, @@ -2494,7 +2411,11 @@ export const EditorOptions = { fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)), folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), foldingStrategy: registerEditorOption(new EditorEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto', ['auto', 'indentation'], (x: 'auto' | 'indentation') => x)), + fontFamily: registerEditorOption(new EditorStringOption(EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily)), + fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo, 'fontInfo', undefined)), fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), + fontSize: registerEditorOption(new EditorFloatOption(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize, x => _clamp(x, 0, 100))), + fontWeight: registerEditorOption(new EditorStringOption(EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight)), formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)), formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)), glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)), @@ -2509,11 +2430,12 @@ export const EditorOptions = { sticky: true })), inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)), + letterSpacing: registerEditorOption(new EditorFloatOption(EditorOption.letterSpacing, 'letterSpacing', EDITOR_FONT_DEFAULTS.letterSpacing, x => _clamp(x, -5, 20))), lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', { enabled: true })), lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), - lineHeight: registerEditorOption(new EditorLineHeight(EditorOption.lineHeight, 'lineHeight', EDITOR_FONT_DEFAULTS.lineHeight)), + lineHeight: registerEditorOption(new EditorLineHeight(EditorOption.lineHeight, 'lineHeight', EDITOR_FONT_DEFAULTS.lineHeight, 0, 150)), lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), links: registerEditorOption(new EditorBooleanOption(EditorOption.links, 'links', true)), diff --git a/src/vs/editor/common/config/fontInfo.ts b/src/vs/editor/common/config/fontInfo.ts index c69ea3f33202e..b23edab7d907d 100644 --- a/src/vs/editor/common/config/fontInfo.ts +++ b/src/vs/editor/common/config/fontInfo.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as platform from 'vs/base/common/platform'; -import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; +import { EDITOR_FONT_DEFAULTS, EditorOptions, ValidatedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; /** @@ -17,56 +17,7 @@ const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35; * Font settings maximum and minimum limits */ const MINIMUM_FONT_SIZE = 8; -const MAXIMUM_FONT_SIZE = 100; const MINIMUM_LINE_HEIGHT = 8; -const MAXIMUM_LINE_HEIGHT = 150; -const MINIMUM_LETTER_SPACING = -5; -const MAXIMUM_LETTER_SPACING = 20; - -function safeParseFloat(n: number | string | undefined, defaultValue: number): number { - if (typeof n === 'number') { - return n; - } - if (typeof n === 'undefined') { - return defaultValue; - } - let r = parseFloat(n); - if (isNaN(r)) { - return defaultValue; - } - return r; -} - -function safeParseInt(n: number | string | undefined, defaultValue: number): number { - if (typeof n === 'number') { - return Math.round(n); - } - if (typeof n === 'undefined') { - return defaultValue; - } - let r = parseInt(n); - if (isNaN(r)) { - return defaultValue; - } - return r; -} - -function clamp(n: number, min: number, max: number): number { - if (n < min) { - return min; - } - if (n > max) { - return max; - } - return n; -} - -function _string(value: any, defaultValue: string): string { - if (typeof value !== 'string') { - return defaultValue; - } - return value; -} export class BareFontInfo { readonly _bareFontInfoBrand: void; @@ -74,38 +25,44 @@ export class BareFontInfo { /** * @internal */ - public static createFromRawSettings(opts: { - fontFamily?: string; - fontWeight?: string; - fontSize?: number | string; - lineHeight?: number | string; - letterSpacing?: number | string; - }, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo { - - let fontFamily = _string(opts.fontFamily, EDITOR_FONT_DEFAULTS.fontFamily); - let fontWeight = _string(opts.fontWeight, EDITOR_FONT_DEFAULTS.fontWeight); + public static createFromValidatedSettings(options: ValidatedEditorOptions, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo { + const fontFamily = options.get(EditorOption.fontFamily); + const fontWeight = options.get(EditorOption.fontWeight); + const fontSize = options.get(EditorOption.fontSize); + const lineHeight = options.get(EditorOption.lineHeight); + const letterSpacing = options.get(EditorOption.letterSpacing); + return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom); + } + /** + * @internal + */ + public static createFromRawSettings(opts: { fontFamily?: string; fontWeight?: string; fontSize?: number; lineHeight?: number; letterSpacing?: number; }, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo { + const fontFamily = EditorOptions.fontFamily.validate(opts.fontFamily); + const fontWeight = EditorOptions.fontWeight.validate(opts.fontWeight); + const fontSize = EditorOptions.fontSize.validate(opts.fontSize); + const lineHeight = EditorOptions.lineHeight.validate(opts.lineHeight); + const letterSpacing = EditorOptions.letterSpacing.validate(opts.letterSpacing); + return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom); + } - let fontSize = safeParseFloat(opts.fontSize, EDITOR_FONT_DEFAULTS.fontSize); - fontSize = clamp(fontSize, 0, MAXIMUM_FONT_SIZE); + /** + * @internal + */ + private static _create(fontFamily: string, fontWeight: string, fontSize: number, lineHeight: number, letterSpacing: number, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo { if (fontSize === 0) { fontSize = EDITOR_FONT_DEFAULTS.fontSize; } else if (fontSize < MINIMUM_FONT_SIZE) { fontSize = MINIMUM_FONT_SIZE; } - let lineHeight = safeParseInt(opts.lineHeight, 0); - lineHeight = clamp(lineHeight, 0, MAXIMUM_LINE_HEIGHT); if (lineHeight === 0) { lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize); } else if (lineHeight < MINIMUM_LINE_HEIGHT) { lineHeight = MINIMUM_LINE_HEIGHT; } - let letterSpacing = safeParseFloat(opts.letterSpacing, 0); - letterSpacing = clamp(letterSpacing, MINIMUM_LETTER_SPACING, MAXIMUM_LETTER_SPACING); - - let editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1); + const editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1); fontSize *= editorZoomLevelMultiplier; lineHeight *= editorZoomLevelMultiplier; diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index dd85df4cc431b..168234965e983 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -6,7 +6,7 @@ import { CharCode } from 'vs/base/common/charCode'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; -import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, ConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption } from 'vs/editor/common/config/editorOptions'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -110,7 +110,7 @@ export class CursorConfiguration { private readonly _languageIdentifier: LanguageIdentifier; private _electricChars: { [key: string]: boolean; } | null; - public static shouldRecreate(e: IConfigurationChangedEvent): boolean { + public static shouldRecreate(e: ConfigurationChangedEvent): boolean { return ( e.hasChanged(EditorOption.layoutInfo) || e.hasChanged(EditorOption.wordSeparators) diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 6c9541592342f..e11482fa25bee 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -6,7 +6,7 @@ import { IMarkdownString } from 'vs/base/common/htmlContent'; import { IDisposable } from 'vs/base/common/lifecycle'; import { URI, UriComponents } from 'vs/base/common/uri'; -import * as editorOptions from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, IComputedEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; @@ -149,14 +149,13 @@ export interface ILineChange extends IChange { * @internal */ export interface IConfiguration extends IDisposable { - onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable; + onDidChange(listener: (e: ConfigurationChangedEvent) => void): IDisposable; - readonly editor: editorOptions.InternalEditorOptions; - readonly options: editorOptions.IComputedEditorOptions; + readonly options: IComputedEditorOptions; setMaxLineNumber(maxLineNumber: number): void; - updateOptions(newOptions: editorOptions.IEditorOptions): void; - getRawOptions(): editorOptions.IEditorOptions; + updateOptions(newOptions: IEditorOptions): void; + getRawOptions(): IEditorOptions; observeReferenceElement(dimension?: IDimension): void; setIsDominatedByLongLines(isDominatedByLongLines: boolean): void; } @@ -264,7 +263,7 @@ export interface IEditor { /** * Update the editor's options after the editor has been created. */ - updateOptions(newOptions: editorOptions.IEditorOptions): void; + updateOptions(newOptions: IEditorOptions): void; /** * Indicates that the editor becomes visible. diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 268d0bfada72e..9a5f179dfabcb 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -467,76 +467,81 @@ export enum EditorOption { fixedOverflowWidgets = 24, folding = 25, foldingStrategy = 26, - fontLigatures = 27, - formatOnPaste = 28, - formatOnType = 29, - glyphMargin = 30, - gotoLocation = 31, - hideCursorInOverviewRuler = 32, - highlightActiveIndentGuide = 33, - hover = 34, - inDiffEditor = 35, - lightbulb = 36, - lineDecorationsWidth = 37, - lineHeight = 38, - lineNumbers = 39, - lineNumbersMinChars = 40, - links = 41, - matchBrackets = 42, - minimap = 43, - mouseStyle = 44, - mouseWheelScrollSensitivity = 45, - mouseWheelZoom = 46, - multiCursorMergeOverlapping = 47, - multiCursorModifier = 48, - occurrencesHighlight = 49, - overviewRulerBorder = 50, - overviewRulerLanes = 51, - parameterHints = 52, - quickSuggestions = 53, - quickSuggestionsDelay = 54, - readOnly = 55, - renderControlCharacters = 56, - renderIndentGuides = 57, - renderFinalNewline = 58, - renderLineHighlight = 59, - renderWhitespace = 60, - revealHorizontalRightPadding = 61, - roundedSelection = 62, - rulers = 63, - scrollbar = 64, - scrollBeyondLastColumn = 65, - scrollBeyondLastLine = 66, - selectionClipboard = 67, - selectionHighlight = 68, - selectOnLineNumbers = 69, - showFoldingControls = 70, - showUnused = 71, - snippetSuggestions = 72, - smoothScrolling = 73, - stopRenderingLineAfter = 74, - suggestFontSize = 75, - suggestLineHeight = 76, - suggestOnTriggerCharacters = 77, - suggestSelection = 78, - tabCompletion = 79, - useTabStops = 80, - wordSeparators = 81, - wordWrap = 82, - wordWrapBreakAfterCharacters = 83, - wordWrapBreakBeforeCharacters = 84, - wordWrapBreakObtrusiveCharacters = 85, - wordWrapColumn = 86, - wordWrapMinified = 87, - wrappingIndent = 88, - ariaLabel = 89, - disableMonospaceOptimizations = 90, - editorClassName = 91, - pixelRatio = 92, - tabFocusMode = 93, - suggest = 94, - layoutInfo = 95, - wrappingInfo = 96 + fontFamily = 27, + fontInfo = 28, + fontLigatures = 29, + fontSize = 30, + fontWeight = 31, + formatOnPaste = 32, + formatOnType = 33, + glyphMargin = 34, + gotoLocation = 35, + hideCursorInOverviewRuler = 36, + highlightActiveIndentGuide = 37, + hover = 38, + inDiffEditor = 39, + letterSpacing = 40, + lightbulb = 41, + lineDecorationsWidth = 42, + lineHeight = 43, + lineNumbers = 44, + lineNumbersMinChars = 45, + links = 46, + matchBrackets = 47, + minimap = 48, + mouseStyle = 49, + mouseWheelScrollSensitivity = 50, + mouseWheelZoom = 51, + multiCursorMergeOverlapping = 52, + multiCursorModifier = 53, + occurrencesHighlight = 54, + overviewRulerBorder = 55, + overviewRulerLanes = 56, + parameterHints = 57, + quickSuggestions = 58, + quickSuggestionsDelay = 59, + readOnly = 60, + renderControlCharacters = 61, + renderIndentGuides = 62, + renderFinalNewline = 63, + renderLineHighlight = 64, + renderWhitespace = 65, + revealHorizontalRightPadding = 66, + roundedSelection = 67, + rulers = 68, + scrollbar = 69, + scrollBeyondLastColumn = 70, + scrollBeyondLastLine = 71, + selectionClipboard = 72, + selectionHighlight = 73, + selectOnLineNumbers = 74, + showFoldingControls = 75, + showUnused = 76, + snippetSuggestions = 77, + smoothScrolling = 78, + stopRenderingLineAfter = 79, + suggestFontSize = 80, + suggestLineHeight = 81, + suggestOnTriggerCharacters = 82, + suggestSelection = 83, + tabCompletion = 84, + useTabStops = 85, + wordSeparators = 86, + wordWrap = 87, + wordWrapBreakAfterCharacters = 88, + wordWrapBreakBeforeCharacters = 89, + wordWrapBreakObtrusiveCharacters = 90, + wordWrapColumn = 91, + wordWrapMinified = 92, + wrappingIndent = 93, + ariaLabel = 94, + disableMonospaceOptimizations = 95, + editorClassName = 96, + pixelRatio = 97, + tabFocusMode = 98, + suggest = 99, + layoutInfo = 100, + wrappingInfo = 101 } /** diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index 05d9e6b0db8ab..55c455808ad31 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -6,7 +6,7 @@ import * as errors from 'vs/base/common/errors'; import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { ScrollEvent } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -34,12 +34,10 @@ export class ViewConfigurationChangedEvent { public readonly type = ViewEventType.ViewConfigurationChanged; - public readonly _source: IConfigurationChangedEvent; - public readonly fontInfo: boolean; + public readonly _source: ConfigurationChangedEvent; - constructor(source: IConfigurationChangedEvent) { + constructor(source: ConfigurationChangedEvent) { this._source = source; - this.fontInfo = source.fontInfo; } public hasChanged(id: EditorOption): boolean { diff --git a/src/vs/editor/common/viewLayout/viewLayout.ts b/src/vs/editor/common/viewLayout/viewLayout.ts index 2a4f9355ac81b..c06d7220a42b8 100644 --- a/src/vs/editor/common/viewLayout/viewLayout.ts +++ b/src/vs/editor/common/viewLayout/viewLayout.ts @@ -6,7 +6,7 @@ import { Event } from 'vs/base/common/event'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout'; import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; @@ -58,7 +58,7 @@ export class ViewLayout extends Disposable implements IViewLayout { // ---- begin view event handlers - public onConfigurationChanged(e: IConfigurationChangedEvent): void { + public onConfigurationChanged(e: ConfigurationChangedEvent): void { const options = this._configuration.options; if (e.hasChanged(EditorOption.lineHeight)) { this._linesLayout.setLineHeight(options.get(EditorOption.lineHeight)); @@ -150,7 +150,7 @@ export class ViewLayout extends Disposable implements IViewLayout { const wrappingInfo = options.get(EditorOption.wrappingInfo); let isViewportWrapping = wrappingInfo.isViewportWrapping; if (!isViewportWrapping) { - const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth; const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth(); return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth, whitespaceMinWidth); } diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 055cf6ae0d1ea..01e9f36723c46 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -6,7 +6,7 @@ import { Color } from 'vs/base/common/color'; import { IDisposable } from 'vs/base/common/lifecycle'; import * as strings from 'vs/base/common/strings'; -import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -59,9 +59,9 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel this.lines = new IdentityLinesCollection(this.model); } else { - const conf = this.configuration.editor; const options = this.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); + const fontInfo = options.get(EditorOption.fontInfo); const wordWrapBreakAfterCharacters = options.get(EditorOption.wordWrapBreakAfterCharacters); const wordWrapBreakBeforeCharacters = options.get(EditorOption.wordWrapBreakBeforeCharacters); const wordWrapBreakObtrusiveCharacters = options.get(EditorOption.wordWrapBreakObtrusiveCharacters); @@ -78,7 +78,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel hardWrappingLineMapperFactory, this.model.getOptions().tabSize, wrappingInfo.wrappingColumn, - conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth, + fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth, wrappingIndent ); } @@ -142,7 +142,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel this.hasFocus = hasFocus; } - private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: IConfigurationChangedEvent): void { + private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: ConfigurationChangedEvent): void { // We might need to restore the current centered view range, so save it (if available) let previousViewportStartModelPosition: Position | null = null; @@ -152,12 +152,12 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } let restorePreviousViewportStart = false; - const conf = this.configuration.editor; const options = this.configuration.options; const wrappingInfo = options.get(EditorOption.wrappingInfo); + const fontInfo = options.get(EditorOption.fontInfo); const wrappingIndent = options.get(EditorOption.wrappingIndent); - if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) { + if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth)) { eventsCollector.emit(new viewEvents.ViewFlushedEvent()); eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent()); @@ -675,7 +675,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel range = new Range(lineNumber, this.model.getLineMinColumn(lineNumber), lineNumber, this.model.getLineMaxColumn(lineNumber)); } - const fontInfo = this.configuration.editor.fontInfo; + const fontInfo = this.configuration.options.get(EditorOption.fontInfo); const colorMap = this._getColorMap(); const fontFamily = fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : `'${fontInfo.fontFamily}', ${EDITOR_FONT_DEFAULTS.fontFamily}`; diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index f4a3bbf228ad4..d5d8dac4981b2 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -138,7 +138,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget { return this.hide(); } - const config = this._editor.getConfiguration(); const options = this._editor.getOptions(); if (!options.get(EditorOption.lightbulb).enabled) { return this.hide(); @@ -151,9 +150,10 @@ export class LightBulbWidget extends Disposable implements IContentWidget { } const tabSize = model.getOptions().tabSize; + const fontInfo = options.get(EditorOption.fontInfo); const lineContent = model.getLineContent(lineNumber); const indent = TextModel.computeIndentLevel(lineContent, tabSize); - const lineHasSpace = config.fontInfo.spaceWidth * indent > 22; + const lineHasSpace = fontInfo.spaceWidth * indent > 22; const isFolded = (lineNumber: number) => { return lineNumber > 2 && this._editor.getTopForLineNumber(lineNumber) === this._editor.getTopForLineNumber(lineNumber - 1); }; @@ -164,7 +164,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget { effectiveLineNumber -= 1; } else if (!isFolded(lineNumber + 1)) { effectiveLineNumber += 1; - } else if (column * config.fontInfo.spaceWidth < 22) { + } else if (column * fontInfo.spaceWidth < 22) { // cannot show lightbulb above/below and showing // it inline would overlay the cursor... return this.hide(); diff --git a/src/vs/editor/contrib/codelens/codelensController.ts b/src/vs/editor/contrib/codelens/codelensController.ts index 72e341842a883..6e89d47039c14 100644 --- a/src/vs/editor/contrib/codelens/codelensController.ts +++ b/src/vs/editor/contrib/codelens/codelensController.ts @@ -205,7 +205,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { } })); this._localToDispose.add(this._editor.onDidChangeConfiguration(e => { - if (e.fontInfo) { + if (e.hasChanged(EditorOption.fontInfo)) { for (const lens of this._lenses) { lens.updateHeight(); } diff --git a/src/vs/editor/contrib/codelens/codelensWidget.ts b/src/vs/editor/contrib/codelens/codelensWidget.ts index 516f971af2bc0..42cf0deb06e15 100644 --- a/src/vs/editor/contrib/codelens/codelensWidget.ts +++ b/src/vs/editor/contrib/codelens/codelensWidget.ts @@ -82,7 +82,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget { updateHeight(): void { const options = this._editor.getOptions(); - const { fontInfo } = this._editor.getConfiguration(); + const fontInfo = options.get(EditorOption.fontInfo); const lineHeight = options.get(EditorOption.lineHeight); this._domNode.style.height = `${Math.round(lineHeight * 1.1)}px`; this._domNode.style.lineHeight = `${lineHeight}px`; diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index 9a399ea3aebc1..a05f0191e315b 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -23,7 +23,7 @@ import { toDisposable } from 'vs/base/common/lifecycle'; import * as platform from 'vs/base/common/platform'; import * as strings from 'vs/base/common/strings'; import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { CONTEXT_FIND_INPUT_FOCUSED, CONTEXT_REPLACE_INPUT_FOCUSED, FIND_IDS, MATCHES_LIMIT } from 'vs/editor/contrib/find/findModel'; import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState'; @@ -176,7 +176,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas this._tryUpdateWidgetWidth(); this._findInput.inputBox.layout(); - this._register(this._codeEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { + this._register(this._codeEditor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { if (e.hasChanged(EditorOption.readOnly)) { if (this._codeEditor.getOption(EditorOption.readOnly)) { // Hide replace part if editor becomes read only diff --git a/src/vs/editor/contrib/folding/folding.ts b/src/vs/editor/contrib/folding/folding.ts index 4ab5ce4decc7a..f0ae51e195553 100644 --- a/src/vs/editor/contrib/folding/folding.ts +++ b/src/vs/editor/contrib/folding/folding.ts @@ -18,7 +18,7 @@ import { FoldingModel, setCollapseStateAtLevel, CollapseMemento, setCollapseStat import { FoldingDecorationProvider } from './foldingDecorations'; import { FoldingRegions, FoldingRegion } from './foldingRanges'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel'; import { IRange } from 'vs/editor/common/core/range'; @@ -109,7 +109,7 @@ export class FoldingController extends Disposable implements IEditorContribution this._register(this.editor.onDidChangeModel(() => this.onModelChanged())); - this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { + this._register(this.editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { if (e.hasChanged(EditorOption.folding) || e.hasChanged(EditorOption.showFoldingControls) || e.hasChanged(EditorOption.foldingStrategy)) { let oldIsEnabled = this._isEnabled; const options = this.editor.getOptions(); diff --git a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts index dd7414923a758..39fe2e80364a7 100644 --- a/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts +++ b/src/vs/editor/contrib/gotoError/gotoErrorWidget.ts @@ -147,7 +147,7 @@ class MessageWidget { } } - const fontInfo = this._editor.getConfiguration().fontInfo; + const fontInfo = this._editor.getOption(EditorOption.fontInfo); const scrollWidth = Math.ceil(fontInfo.typicalFullwidthCharacterWidth * this._longestLineLength * 0.75); const scrollHeight = fontInfo.lineHeight * this._lines; this._scrollable.setScrollDimensions({ scrollWidth, scrollHeight }); diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index b89e96001d37a..215ddd5844c88 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -11,7 +11,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution, IScrollEvent } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; @@ -74,7 +74,7 @@ export class ModesHoverController implements IEditorContribution { this._hookEvents(); - this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { + this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { if (e.hasChanged(EditorOption.hover)) { this._hideWidgets(); this._unhookEvents(); @@ -164,7 +164,7 @@ export class ModesHoverController implements IEditorContribution { } if (targetType === MouseTargetType.CONTENT_EMPTY) { - const epsilon = this._editor.getConfiguration().fontInfo.typicalHalfwidthCharacterWidth / 2; + const epsilon = this._editor.getOption(EditorOption.fontInfo).typicalHalfwidthCharacterWidth / 2; const data = mouseEvent.target.detail; if (data && !data.isAfterLines && typeof data.horizontalDistanceToText === 'number' && data.horizontalDistanceToText < epsilon) { // Let hover kick in even when the mouse is technically in the empty area after a line, given the distance is small enough diff --git a/src/vs/editor/contrib/hover/hoverWidgets.ts b/src/vs/editor/contrib/hover/hoverWidgets.ts index 96d28a550992c..9077e4a9eb0cf 100644 --- a/src/vs/editor/contrib/hover/hoverWidgets.ts +++ b/src/vs/editor/contrib/hover/hoverWidgets.ts @@ -9,7 +9,7 @@ import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableEle import { Widget } from 'vs/base/browser/ui/widget'; import { KeyCode } from 'vs/base/common/keyCodes'; import { IContentWidget, ICodeEditor, IContentWidgetPosition, ContentWidgetPositionPreference, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -61,8 +61,8 @@ export class ContentHoverWidget extends Widget implements IContentWidget { } }); - this._register(this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.fontInfo) { + this._register(this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { + if (e.hasChanged(EditorOption.fontInfo)) { this.updateFont(); } })); @@ -152,7 +152,7 @@ export class ContentHoverWidget extends Widget implements IContentWidget { private layout(): void { const height = Math.max(this._editor.getLayoutInfo().height / 4, 250); - const { fontSize, lineHeight } = this._editor.getConfiguration().fontInfo; + const { fontSize, lineHeight } = this._editor.getOption(EditorOption.fontInfo); this._domNode.style.fontSize = `${fontSize}px`; this._domNode.style.lineHeight = `${lineHeight}px`; @@ -182,8 +182,8 @@ export class GlyphHoverWidget extends Widget implements IOverlayWidget { this._showAtLineNumber = -1; - this._register(this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.fontInfo) { + this._register(this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { + if (e.hasChanged(EditorOption.fontInfo)) { this.updateFont(); } })); diff --git a/src/vs/editor/contrib/markdown/markdownRenderer.ts b/src/vs/editor/contrib/markdown/markdownRenderer.ts index 81f0b2ccc8714..e8165ed3e7afe 100644 --- a/src/vs/editor/contrib/markdown/markdownRenderer.ts +++ b/src/vs/editor/contrib/markdown/markdownRenderer.ts @@ -15,6 +15,7 @@ import { optional } from 'vs/platform/instantiation/common/instantiation'; import { Event, Emitter } from 'vs/base/common/event'; import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle'; import { TokenizationRegistry } from 'vs/editor/common/modes'; +import { EditorOption } from 'vs/editor/common/config/editorOptions'; export interface IMarkdownRenderResult extends IDisposable { element: HTMLElement; @@ -57,7 +58,7 @@ export class MarkdownRenderer extends Disposable { } return tokenizeToString(value, undefined); }).then(code => { - return `${code}`; + return `${code}`; }); }, codeBlockRenderCallback: () => this._onDidRenderCodeBlock.fire(), diff --git a/src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts b/src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts index 0efd0207cb670..696ff9f693ab4 100644 --- a/src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts +++ b/src/vs/editor/contrib/parameterHints/parameterHintsWidget.ts @@ -11,7 +11,7 @@ import { Event } from 'vs/base/common/event'; import { IDisposable, Disposable, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle'; import 'vs/css!./parameterHints'; import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import * as modes from 'vs/editor/common/modes'; import { IModeService } from 'vs/editor/common/services/modeService'; import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer'; @@ -105,14 +105,14 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget, })); const updateFont = () => { - const fontInfo = this.editor.getConfiguration().fontInfo; + const fontInfo = this.editor.getOption(EditorOption.fontInfo); this.element.style.fontSize = `${fontInfo.fontSize}px`; }; updateFont(); - this._register(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) - .filter(e => e.fontInfo) + this._register(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) + .filter(e => e.hasChanged(EditorOption.fontInfo)) .on(updateFont, null)); this._register(this.editor.onDidLayoutChange(e => this.updateMaxHeight())); @@ -177,7 +177,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget, const code = dom.append(this.signature, $('.code')); const hasParameters = signature.parameters.length > 0; - const fontInfo = this.editor.getConfiguration().fontInfo; + const fontInfo = this.editor.getOption(EditorOption.fontInfo); code.style.fontSize = `${fontInfo.fontSize}px`; code.style.fontFamily = fontInfo.fontFamily; diff --git a/src/vs/editor/contrib/rename/renameInputField.ts b/src/vs/editor/contrib/rename/renameInputField.ts index b3c9bea2be823..1113144c6c43c 100644 --- a/src/vs/editor/contrib/rename/renameInputField.ts +++ b/src/vs/editor/contrib/rename/renameInputField.ts @@ -41,7 +41,7 @@ export class RenameInputField implements IContentWidget, IDisposable { this._editor.addContentWidget(this); this._disposables.add(editor.onDidChangeConfiguration(e => { - if (e.fontInfo) { + if (e.hasChanged(EditorOption.fontInfo)) { this.updateFont(); } })); @@ -104,7 +104,7 @@ export class RenameInputField implements IContentWidget, IDisposable { return; } - const fontInfo = this._editor.getConfiguration().fontInfo; + const fontInfo = this._editor.getOption(EditorOption.fontInfo); this._inputField.style.fontFamily = fontInfo.fontFamily; this._inputField.style.fontWeight = fontInfo.fontWeight; this._inputField.style.fontSize = `${fontInfo.fontSize}px`; diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 3a9a8eec06f57..fa7198d184c71 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -16,7 +16,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser'; import { Context as SuggestContext, CompletionItem } from './suggest'; import { CompletionModel } from './completionModel'; @@ -124,12 +124,12 @@ class Renderer implements IListRenderer data.readMore.title = nls.localize('readMore', "Read More...{0}", this.triggerKeybindingLabel); const configureFont = () => { - const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); - const fontFamily = configuration.fontInfo.fontFamily; - const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize; - const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight; - const fontWeight = configuration.fontInfo.fontWeight; + const fontInfo = options.get(EditorOption.fontInfo); + const fontFamily = fontInfo.fontFamily; + const fontSize = options.get(EditorOption.suggestFontSize) || fontInfo.fontSize; + const lineHeight = options.get(EditorOption.suggestLineHeight) || fontInfo.lineHeight; + const fontWeight = fontInfo.fontWeight; const fontSizePx = `${fontSize}px`; const lineHeightPx = `${lineHeight}px`; @@ -145,8 +145,8 @@ class Renderer implements IListRenderer configureFont(); - data.disposables.add(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) - .filter(e => e.fontInfo || e.hasChanged(EditorOption.suggestFontSize) || e.hasChanged(EditorOption.suggestLineHeight)) + data.disposables.add(Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) + .filter(e => e.hasChanged(EditorOption.fontInfo) || e.hasChanged(EditorOption.suggestFontSize) || e.hasChanged(EditorOption.suggestLineHeight)) .on(configureFont, null)); return data; @@ -277,8 +277,8 @@ class SuggestionDetails { this.configureFont(); - Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) - .filter(e => e.fontInfo) + Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor)) + .filter(e => e.hasChanged(EditorOption.fontInfo)) .on(this.configureFont, this, this.disposables); markdownRenderer.onDidRenderCodeBlock(() => this.scrollbar.scanDomNode(), this, this.disposables); @@ -390,12 +390,12 @@ class SuggestionDetails { } private configureFont() { - const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); - const fontFamily = configuration.fontInfo.fontFamily; - const fontSize = options.get(EditorOption.suggestFontSize) || configuration.fontInfo.fontSize; - const lineHeight = options.get(EditorOption.suggestLineHeight) || configuration.fontInfo.lineHeight; - const fontWeight = configuration.fontInfo.fontWeight; + const fontInfo = options.get(EditorOption.fontInfo); + const fontFamily = fontInfo.fontFamily; + const fontSize = options.get(EditorOption.suggestFontSize) || fontInfo.fontSize; + const lineHeight = options.get(EditorOption.suggestLineHeight) || fontInfo.lineHeight; + const fontWeight = fontInfo.fontWeight; const fontSizePx = `${fontSize}px`; const lineHeightPx = `${lineHeight}px`; @@ -1071,7 +1071,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegateeditorOptions.InternalEditorOptions, + ConfigurationChangedEvent: ConfigurationChangedEvent, BareFontInfo: BareFontInfo, FontInfo: FontInfo, TextModelResolvedOptions: TextModelResolvedOptions, @@ -381,7 +381,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { // vars EditorType: editorCommon.EditorType, - EditorOptions: editorOptions.EditorOptions, + EditorOptions: EditorOptions, }; } diff --git a/src/vs/editor/test/common/config/commonEditorConfig.test.ts b/src/vs/editor/test/common/config/commonEditorConfig.test.ts index f2ab0bbbd41e3..0608fa6476e5f 100644 --- a/src/vs/editor/test/common/config/commonEditorConfig.test.ts +++ b/src/vs/editor/test/common/config/commonEditorConfig.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig'; -import { IEditorHoverOptions, EditorOption, IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { IEditorHoverOptions, EditorOption, ConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility'; @@ -193,7 +193,7 @@ suite('Common Editor Config', () => { test('does not emit event when nothing changes', () => { const config = new TestConfiguration({ glyphMargin: true, roundedSelection: false }); - let event: IConfigurationChangedEvent | null = null; + let event: ConfigurationChangedEvent | null = null; config.onDidChange(e => event = e); assert.equal(config.options.get(EditorOption.glyphMargin), true); diff --git a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts index 2ecf905ed3578..d57bcaecded22 100644 --- a/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts +++ b/src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts @@ -92,6 +92,7 @@ suite('Editor ViewModel - SplitLinesCollection', () => { function withSplitLinesCollection(text: string, callback: (model: TextModel, linesCollection: SplitLinesCollection) => void): void { const config = new TestConfiguration({}); const wrappingInfo = config.options.get(EditorOption.wrappingInfo); + const fontInfo = config.options.get(EditorOption.fontInfo); const wordWrapBreakAfterCharacters = config.options.get(EditorOption.wordWrapBreakAfterCharacters); const wordWrapBreakBeforeCharacters = config.options.get(EditorOption.wordWrapBreakBeforeCharacters); const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOption.wordWrapBreakObtrusiveCharacters); @@ -117,7 +118,7 @@ suite('Editor ViewModel - SplitLinesCollection', () => { hardWrappingLineMapperFactory, model.getOptions().tabSize, wrappingInfo.wrappingColumn, - config.editor.fontInfo.typicalFullwidthCharacterWidth / config.editor.fontInfo.typicalHalfwidthCharacterWidth, + fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth, wrappingIndent ); @@ -745,6 +746,7 @@ suite('SplitLinesCollection', () => { wrappingIndent: 'indent' }); const wrappingInfo = configuration.options.get(EditorOption.wrappingInfo); + const fontInfo = configuration.options.get(EditorOption.fontInfo); const wordWrapBreakAfterCharacters = configuration.options.get(EditorOption.wordWrapBreakAfterCharacters); const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOption.wordWrapBreakBeforeCharacters); const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOption.wordWrapBreakObtrusiveCharacters); @@ -761,7 +763,7 @@ suite('SplitLinesCollection', () => { factory, model.getOptions().tabSize, wrappingInfo.wrappingColumn, - configuration.editor.fontInfo.typicalFullwidthCharacterWidth / configuration.editor.fontInfo.typicalHalfwidthCharacterWidth, + fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth, wrappingIndent ); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 59b8f512f1925..b6afdd0aafb59 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3093,7 +3093,7 @@ declare namespace monaco.editor { /** * The font weight */ - fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'; + fontWeight?: string; /** * The font size */ @@ -3121,6 +3121,10 @@ declare namespace monaco.editor { * Do not use, this is a computed option. */ pixelRatio?: undefined; + /** + * Do not use, this is a computed option. + */ + fontInfo?: undefined; /** * Do not use, this is a computed option. */ @@ -3256,20 +3260,11 @@ declare namespace monaco.editor { UnderlineThin = 6 } - /** - * Internal configuration options (transformed or computed) for the editor. - */ - export class InternalEditorOptions { - readonly _internalEditorOptionsBrand: void; - readonly fontInfo: FontInfo; - } - /** * An event describing that the configuration of the editor has changed. */ - export interface IConfigurationChangedEvent { + export class ConfigurationChangedEvent { hasChanged(id: EditorOption): boolean; - readonly fontInfo: boolean; } export interface IEnvironmentalOptions { @@ -3517,76 +3512,81 @@ declare namespace monaco.editor { fixedOverflowWidgets = 24, folding = 25, foldingStrategy = 26, - fontLigatures = 27, - formatOnPaste = 28, - formatOnType = 29, - glyphMargin = 30, - gotoLocation = 31, - hideCursorInOverviewRuler = 32, - highlightActiveIndentGuide = 33, - hover = 34, - inDiffEditor = 35, - lightbulb = 36, - lineDecorationsWidth = 37, - lineHeight = 38, - lineNumbers = 39, - lineNumbersMinChars = 40, - links = 41, - matchBrackets = 42, - minimap = 43, - mouseStyle = 44, - mouseWheelScrollSensitivity = 45, - mouseWheelZoom = 46, - multiCursorMergeOverlapping = 47, - multiCursorModifier = 48, - occurrencesHighlight = 49, - overviewRulerBorder = 50, - overviewRulerLanes = 51, - parameterHints = 52, - quickSuggestions = 53, - quickSuggestionsDelay = 54, - readOnly = 55, - renderControlCharacters = 56, - renderIndentGuides = 57, - renderFinalNewline = 58, - renderLineHighlight = 59, - renderWhitespace = 60, - revealHorizontalRightPadding = 61, - roundedSelection = 62, - rulers = 63, - scrollbar = 64, - scrollBeyondLastColumn = 65, - scrollBeyondLastLine = 66, - selectionClipboard = 67, - selectionHighlight = 68, - selectOnLineNumbers = 69, - showFoldingControls = 70, - showUnused = 71, - snippetSuggestions = 72, - smoothScrolling = 73, - stopRenderingLineAfter = 74, - suggestFontSize = 75, - suggestLineHeight = 76, - suggestOnTriggerCharacters = 77, - suggestSelection = 78, - tabCompletion = 79, - useTabStops = 80, - wordSeparators = 81, - wordWrap = 82, - wordWrapBreakAfterCharacters = 83, - wordWrapBreakBeforeCharacters = 84, - wordWrapBreakObtrusiveCharacters = 85, - wordWrapColumn = 86, - wordWrapMinified = 87, - wrappingIndent = 88, - ariaLabel = 89, - disableMonospaceOptimizations = 90, - editorClassName = 91, - pixelRatio = 92, - tabFocusMode = 93, - suggest = 94, - layoutInfo = 95, - wrappingInfo = 96 + fontFamily = 27, + fontInfo = 28, + fontLigatures = 29, + fontSize = 30, + fontWeight = 31, + formatOnPaste = 32, + formatOnType = 33, + glyphMargin = 34, + gotoLocation = 35, + hideCursorInOverviewRuler = 36, + highlightActiveIndentGuide = 37, + hover = 38, + inDiffEditor = 39, + letterSpacing = 40, + lightbulb = 41, + lineDecorationsWidth = 42, + lineHeight = 43, + lineNumbers = 44, + lineNumbersMinChars = 45, + links = 46, + matchBrackets = 47, + minimap = 48, + mouseStyle = 49, + mouseWheelScrollSensitivity = 50, + mouseWheelZoom = 51, + multiCursorMergeOverlapping = 52, + multiCursorModifier = 53, + occurrencesHighlight = 54, + overviewRulerBorder = 55, + overviewRulerLanes = 56, + parameterHints = 57, + quickSuggestions = 58, + quickSuggestionsDelay = 59, + readOnly = 60, + renderControlCharacters = 61, + renderIndentGuides = 62, + renderFinalNewline = 63, + renderLineHighlight = 64, + renderWhitespace = 65, + revealHorizontalRightPadding = 66, + roundedSelection = 67, + rulers = 68, + scrollbar = 69, + scrollBeyondLastColumn = 70, + scrollBeyondLastLine = 71, + selectionClipboard = 72, + selectionHighlight = 73, + selectOnLineNumbers = 74, + showFoldingControls = 75, + showUnused = 76, + snippetSuggestions = 77, + smoothScrolling = 78, + stopRenderingLineAfter = 79, + suggestFontSize = 80, + suggestLineHeight = 81, + suggestOnTriggerCharacters = 82, + suggestSelection = 83, + tabCompletion = 84, + useTabStops = 85, + wordSeparators = 86, + wordWrap = 87, + wordWrapBreakAfterCharacters = 88, + wordWrapBreakBeforeCharacters = 89, + wordWrapBreakObtrusiveCharacters = 90, + wordWrapColumn = 91, + wordWrapMinified = 92, + wrappingIndent = 93, + ariaLabel = 94, + disableMonospaceOptimizations = 95, + editorClassName = 96, + pixelRatio = 97, + tabFocusMode = 98, + suggest = 99, + layoutInfo = 100, + wrappingInfo = 101 } export const EditorOptions: { @@ -3617,7 +3617,11 @@ declare namespace monaco.editor { fixedOverflowWidgets: IEditorOption; folding: IEditorOption; foldingStrategy: IEditorOption; + fontFamily: IEditorOption; + fontInfo: IEditorOption; fontLigatures: IEditorOption; + fontSize: IEditorOption; + fontWeight: IEditorOption; formatOnPaste: IEditorOption; formatOnType: IEditorOption; glyphMargin: IEditorOption; @@ -3626,6 +3630,7 @@ declare namespace monaco.editor { highlightActiveIndentGuide: IEditorOption; hover: IEditorOption; inDiffEditor: IEditorOption; + letterSpacing: IEditorOption; lightbulb: IEditorOption; lineDecorationsWidth: IEditorOption; lineHeight: IEditorOption; @@ -4019,7 +4024,7 @@ declare namespace monaco.editor { * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) * @event */ - onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; + onDidChangeConfiguration(listener: (e: ConfigurationChangedEvent) => void): IDisposable; /** * An event emitted when the cursor position has changed. * @event @@ -4147,7 +4152,6 @@ declare namespace monaco.editor { /** * Returns the current editor's configuration */ - getConfiguration(): InternalEditorOptions; getOptions(): IComputedEditorOptions; getOption(id: T): FindComputedEditorOptionValueById; /** @@ -4392,6 +4396,7 @@ declare namespace monaco.editor { readonly spaceWidth: number; readonly maxDigitWidth: number; } + export class BareFontInfo { readonly _bareFontInfoBrand: void; readonly zoomLevel: number; diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index b167f3ea8df68..67940979ba682 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -35,7 +35,7 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ITextFileService, SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; -import { IConfigurationChangedEvent, IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { deepClone } from 'vs/base/common/objects'; @@ -583,7 +583,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { if (activeCodeEditor) { // Hook Listener for Configuration changes - this.activeEditorListeners.add(activeCodeEditor.onDidChangeConfiguration((event: IConfigurationChangedEvent) => { + this.activeEditorListeners.add(activeCodeEditor.onDidChangeConfiguration((event: ConfigurationChangedEvent) => { if (event.hasChanged(EditorOption.accessibilitySupport)) { this.onScreenReaderModeChange(activeCodeEditor); } diff --git a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts index 32133496349d9..ebf9955db2ab7 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/selectionClipboard.ts @@ -9,7 +9,7 @@ import * as process from 'vs/base/common/process'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { IConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { Range } from 'vs/editor/common/core/range'; import { IEditorContribution } from 'vs/editor/common/editorCommon'; @@ -26,7 +26,7 @@ export class SelectionClipboard extends Disposable implements IEditorContributio if (platform.isLinux) { let isEnabled = editor.getOption(EditorOption.selectionClipboard); - this._register(editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { + this._register(editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { if (e.hasChanged(EditorOption.selectionClipboard)) { isEnabled = editor.getOption(EditorOption.selectionClipboard); } diff --git a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts index 42d3d7a8a1438..8691a8105d5f9 100644 --- a/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts +++ b/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts @@ -129,7 +129,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget this._styleElement = dom.createStyleSheet(this.domNode); this._globalToDispose.add(this.themeService.onThemeChange(this._applyTheme, this)); this._globalToDispose.add(this.editor.onDidChangeConfiguration(e => { - if (e.fontInfo) { + if (e.hasChanged(EditorOption.fontInfo)) { this._applyTheme(this.themeService.getTheme()); } })); @@ -855,7 +855,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget content.push(`.monaco-editor .review-widget .body .comment-form .validation-error { color: ${errorForeground}; }`); } - const fontInfo = this.editor.getConfiguration().fontInfo; + const fontInfo = this.editor.getOption(EditorOption.fontInfo); content.push(`.monaco-editor .review-widget .body code { font-family: ${fontInfo.fontFamily}; font-size: ${fontInfo.fontSize}px; diff --git a/src/vs/workbench/contrib/debug/browser/debugHover.ts b/src/vs/workbench/contrib/debug/browser/debugHover.ts index e4f23037af07b..2c7dd35cf1520 100644 --- a/src/vs/workbench/contrib/debug/browser/debugHover.ts +++ b/src/vs/workbench/contrib/debug/browser/debugHover.ts @@ -9,7 +9,7 @@ import { KeyCode } from 'vs/base/common/keyCodes'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import * as dom from 'vs/base/browser/dom'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; -import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { IContentWidget, ICodeEditor, IContentWidgetPosition, ContentWidgetPositionPreference } from 'vs/editor/browser/editorBrowser'; @@ -114,8 +114,8 @@ export class DebugHoverWidget implements IContentWidget { this.hide(); } })); - this.toDispose.push(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => { - if (e.fontInfo) { + this.toDispose.push(this.editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => { + if (e.hasChanged(EditorOption.fontInfo)) { this.editor.applyFontInfo(this.domNode); } })); diff --git a/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts b/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts index 9191e39728b21..913eaefc26cf6 100644 --- a/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts +++ b/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts @@ -63,7 +63,7 @@ export class ExceptionWidget extends ZoneWidget { protected _fillContainer(container: HTMLElement): void { this.setCssClass('exception-widget'); // Set the font size and line height to the one from the editor configuration. - const fontInfo = this.editor.getConfiguration().fontInfo; + const fontInfo = this.editor.getOption(EditorOption.fontInfo); container.style.fontSize = `${fontInfo.fontSize}px`; container.style.lineHeight = `${fontInfo.lineHeight}px`; diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 2697f1a9e029a..a6c6b87cf159a 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -85,9 +85,9 @@ export class SettingsHeaderWidget extends Widget implements IViewZone { } private layout(): void { - const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); - this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; + const fontInfo = options.get(EditorOption.fontInfo); + this.titleContainer.style.fontSize = fontInfo.fontSize + 'px'; if (!options.get(EditorOption.folding)) { this.titleContainer.style.paddingLeft = '6px'; } @@ -201,18 +201,18 @@ export class SettingsGroupTitleWidget extends Widget implements IViewZone { } private layout(): void { - const configuration = this.editor.getConfiguration(); const options = this.editor.getOptions(); + const fontInfo = options.get(EditorOption.fontInfo); const layoutInfo = this.editor.getLayoutInfo(); this._domNode.style.width = layoutInfo.contentWidth - layoutInfo.verticalScrollbarWidth + 'px'; this.titleContainer.style.lineHeight = options.get(EditorOption.lineHeight) + 3 + 'px'; this.titleContainer.style.height = options.get(EditorOption.lineHeight) + 3 + 'px'; - this.titleContainer.style.fontSize = configuration.fontInfo.fontSize + 'px'; + this.titleContainer.style.fontSize = fontInfo.fontSize + 'px'; this.icon.style.minWidth = `${this.getIconSize(16)}px`; } private getIconSize(minSize: number): number { - const fontSize = this.editor.getConfiguration().fontInfo.fontSize; + const fontSize = this.editor.getOption(EditorOption.fontInfo).fontSize; return fontSize > 8 ? Math.max(fontSize, minSize) : 12; } From 7077b6b7f94b23d01e5bbebcf858709171a8ab94 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 15:20:08 +0200 Subject: [PATCH 096/204] Fix very annoying gulp task error that always takes you to tasks output Even when you click dismiss --- extensions/gulp/src/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/gulp/src/main.ts b/extensions/gulp/src/main.ts index b260f0e49b816..20d824c25ed78 100644 --- a/extensions/gulp/src/main.ts +++ b/extensions/gulp/src/main.ts @@ -62,8 +62,10 @@ function getOutputChannel(): vscode.OutputChannel { function showError() { vscode.window.showWarningMessage(localize('gulpTaskDetectError', 'Problem finding gulp tasks. See the output for more information.'), - localize('gulpShowOutput', 'Go to output')).then(() => { - _channel.show(true); + localize('gulpShowOutput', 'Go to output')).then((choice) => { + if (choice !== undefined) { + _channel.show(true); + } }); } From e9581bcbd6c68a8777245ea0ddefb27224cb4689 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 15:25:41 +0200 Subject: [PATCH 097/204] Add EditorFontSize --- src/vs/editor/common/config/editorOptions.ts | 20 +++++++++++++++++++- src/vs/editor/common/config/fontInfo.ts | 11 ++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index a5ff1b8076886..702d1aa9f0ab8 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -1556,12 +1556,30 @@ class EditorPixelRatio> extends EditorIntOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { + // The lineHeight is computed from the fontSize if it is 0 and the result of that computation is in the env.fontInfo return env.fontInfo.lineHeight; } } //#endregion +//#region fontSize + +class EditorFontSize> extends BaseEditorOption { + public validate(input: number | undefined): number { + let r = _float(input, this.defaultValue); + if (r === 0) { + return EDITOR_FONT_DEFAULTS.fontSize; + } + return _clamp(r, 8, 100); + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { + return value; + } +} + +//#endregion + //#region fontInfo class EditorFontInfo> extends BaseEditorOption { @@ -2414,7 +2432,7 @@ export const EditorOptions = { fontFamily: registerEditorOption(new EditorStringOption(EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily)), fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo, 'fontInfo', undefined)), fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), - fontSize: registerEditorOption(new EditorFloatOption(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize, x => _clamp(x, 0, 100))), + fontSize: registerEditorOption(new EditorFontSize(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize)), fontWeight: registerEditorOption(new EditorStringOption(EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight)), formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)), formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)), diff --git a/src/vs/editor/common/config/fontInfo.ts b/src/vs/editor/common/config/fontInfo.ts index b23edab7d907d..6aa495b1d823c 100644 --- a/src/vs/editor/common/config/fontInfo.ts +++ b/src/vs/editor/common/config/fontInfo.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as platform from 'vs/base/common/platform'; -import { EDITOR_FONT_DEFAULTS, EditorOptions, ValidatedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { EditorOptions, ValidatedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; /** @@ -14,9 +14,8 @@ import { EditorZoom } from 'vs/editor/common/config/editorZoom'; const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35; /** - * Font settings maximum and minimum limits + * @internal */ -const MINIMUM_FONT_SIZE = 8; const MINIMUM_LINE_HEIGHT = 8; export class BareFontInfo { @@ -50,12 +49,6 @@ export class BareFontInfo { * @internal */ private static _create(fontFamily: string, fontWeight: string, fontSize: number, lineHeight: number, letterSpacing: number, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo { - if (fontSize === 0) { - fontSize = EDITOR_FONT_DEFAULTS.fontSize; - } else if (fontSize < MINIMUM_FONT_SIZE) { - fontSize = MINIMUM_FONT_SIZE; - } - if (lineHeight === 0) { lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize); } else if (lineHeight < MINIMUM_LINE_HEIGHT) { From 1cab21cffbf15b657a152b10e1e4a7dc57ca85a7 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 11:58:47 +0200 Subject: [PATCH 098/204] make string[] in ParsedArgs consistent --- src/vs/code/electron-main/app.ts | 7 ++- src/vs/code/electron-main/windows.ts | 44 +++++++++------- .../environment/common/environment.ts | 16 +++--- src/vs/platform/environment/node/argv.ts | 52 ++++++------------- .../launch/electron-main/launchService.ts | 3 +- .../contrib/debug/browser/rawDebugSession.ts | 8 +-- 6 files changed, 54 insertions(+), 76 deletions(-) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index cf63cbaf3e2b7..7faad37bebcec 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -56,7 +56,6 @@ import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver'; import { IMenubarService } from 'vs/platform/menubar/node/menubar'; import { MenubarService } from 'vs/platform/menubar/electron-main/menubarService'; import { MenubarChannel } from 'vs/platform/menubar/node/menubarIpc'; -import { hasArgs } from 'vs/platform/environment/node/argv'; import { RunOnceScheduler } from 'vs/base/common/async'; import { registerContextMenuListener } from 'vs/base/parts/contextmenu/electron-main/contextmenu'; import { homedir } from 'os'; @@ -616,9 +615,9 @@ export class CodeApplication extends Disposable { // Open our first window const macOpenFiles: string[] = (global).macOpenFiles; const context = !!process.env['VSCODE_CLI'] ? OpenContext.CLI : OpenContext.DESKTOP; - const hasCliArgs = hasArgs(args._); - const hasFolderURIs = hasArgs(args['folder-uri']); - const hasFileURIs = hasArgs(args['file-uri']); + const hasCliArgs = args._.length; + const hasFolderURIs = !!args['folder-uri']; + const hasFileURIs = !!args['file-uri']; const noRecentEntry = args['skip-add-to-recently-opened'] === true; const waitMarkerFileURI = args.wait && args.waitMarkerFilePath ? URI.file(args.waitMarkerFilePath) : undefined; diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index c7cdbd794e02c..8541606e61a53 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -12,7 +12,6 @@ import { IBackupMainService, IEmptyWindowBackupInfo } from 'vs/platform/backup/c import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; import { IStateService } from 'vs/platform/state/common/state'; import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window'; -import { hasArgs, asArray } from 'vs/platform/environment/node/argv'; import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter } from 'electron'; import { parseLineAndColumnAware } from 'vs/code/node/paths'; import { ILifecycleService, UnloadReason, LifecycleService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMain'; @@ -450,7 +449,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService { // Make sure to pass focus to the most relevant of the windows if we open multiple if (usedWindows.length > 1) { - const focusLastActive = this.windowsState.lastActiveWindow && !openConfig.forceEmpty && !hasArgs(openConfig.cli._) && !hasArgs(openConfig.cli['file-uri']) && !hasArgs(openConfig.cli['folder-uri']) && !(openConfig.urisToOpen && openConfig.urisToOpen.length); + const focusLastActive = this.windowsState.lastActiveWindow && !openConfig.forceEmpty && openConfig.cli._.length && !openConfig.cli['file-uri'] && !openConfig.cli['folder-uri'] && !(openConfig.urisToOpen && openConfig.urisToOpen.length); let focusLastOpened = true; let focusLastWindow = true; @@ -811,7 +810,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService { } // Extract paths: from CLI - else if (hasArgs(openConfig.cli._) || hasArgs(openConfig.cli['folder-uri']) || hasArgs(openConfig.cli['file-uri'])) { + else if (openConfig.cli._.length || openConfig.cli['folder-uri'] || openConfig.cli['file-uri']) { windowsToOpen = this.doExtractPathsFromCLI(openConfig.cli); isCommandLineOrAPICall = true; } @@ -885,31 +884,36 @@ export class WindowsManager extends Disposable implements IWindowsMainService { const parseOptions: IPathParseOptions = { ignoreFileNotFound: true, gotoLineMode: cli.goto, remoteAuthority: cli.remote || undefined }; // folder uris - const folderUris = asArray(cli['folder-uri']); - for (let f of folderUris) { - const folderUri = this.argToUri(f); - if (folderUri) { - const path = this.parseUri({ folderUri }, parseOptions); - if (path) { - pathsToOpen.push(path); + const folderUris = cli['folder-uri']; + if (folderUris) { + for (let f of folderUris) { + const folderUri = this.argToUri(f); + if (folderUri) { + const path = this.parseUri({ folderUri }, parseOptions); + if (path) { + pathsToOpen.push(path); + } } } } + // file uris - const fileUris = asArray(cli['file-uri']); - for (let f of fileUris) { - const fileUri = this.argToUri(f); - if (fileUri) { - const path = this.parseUri(hasWorkspaceFileExtension(f) ? { workspaceUri: fileUri } : { fileUri }, parseOptions); - if (path) { - pathsToOpen.push(path); + const fileUris = cli['file-uri']; + if (fileUris) { + for (let f of fileUris) { + const fileUri = this.argToUri(f); + if (fileUri) { + const path = this.parseUri(hasWorkspaceFileExtension(f) ? { workspaceUri: fileUri } : { fileUri }, parseOptions); + if (path) { + pathsToOpen.push(path); + } } } } // folder or file paths - const cliArgs = asArray(cli._); + const cliArgs = cli._; for (let cliArg of cliArgs) { const path = this.parsePath(cliArg, parseOptions); if (path) { @@ -1178,8 +1182,8 @@ export class WindowsManager extends Disposable implements IWindowsMainService { return; } - let folderUris = asArray(openConfig.cli['folder-uri']); - let fileUris = asArray(openConfig.cli['file-uri']); + let folderUris = openConfig.cli['folder-uri'] || []; + let fileUris = openConfig.cli['file-uri'] || []; let cliArgs = openConfig.cli._; // Fill in previously opened workspace unless an explicit path is provided and we are not unit testing diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index cfb931c013eeb..338a392f360ce 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -8,8 +8,8 @@ import { URI } from 'vs/base/common/uri'; export interface ParsedArgs { _: string[]; - 'folder-uri'?: string | string[]; - 'file-uri'?: string | string[]; + 'folder-uri'?: string[]; + 'file-uri'?: string[]; _urls?: string[]; help?: boolean; version?: boolean; @@ -36,7 +36,7 @@ export interface ParsedArgs { logExtensionHostCommunication?: boolean; 'extensions-dir'?: string; 'builtin-extensions-dir'?: string; - extensionDevelopmentPath?: string | string[]; // one or more local paths or URIs + extensionDevelopmentPath?: string[]; // one or more local paths or URIs extensionTestsPath?: string; // either a local path or a URI 'extension-development-confirm-save'?: boolean; 'inspect-extensions'?: string; @@ -45,14 +45,14 @@ export interface ParsedArgs { 'inspect-search'?: string; 'inspect-brk-search'?: string; 'disable-extensions'?: boolean; - 'disable-extension'?: string | string[]; + 'disable-extension'?: string[]; 'list-extensions'?: boolean; 'show-versions'?: boolean; 'category'?: string; - 'install-extension'?: string | string[]; - 'uninstall-extension'?: string | string[]; - 'locate-extension'?: string | string[]; - 'enable-proposed-api'?: string | string[]; + 'install-extension'?: string[]; + 'uninstall-extension'?: string[]; + 'locate-extension'?: string[]; + 'enable-proposed-api'?: string[]; 'open-url'?: boolean; 'skip-getting-started'?: boolean; 'skip-release-notes'?: boolean; diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 5e22e54d396c4..3d6d64e391062 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -22,7 +22,7 @@ const helpCategories = { export interface Option { id: keyof ParsedArgs; - type: 'boolean' | 'string'; + type: 'boolean' | 'string' | 'string[]'; alias?: string; deprecates?: string; // old deprecated id args?: string | string[]; @@ -42,23 +42,23 @@ export const options: Option[] = [ { id: 'version', type: 'boolean', cat: 'o', alias: 'v', description: localize('version', "Print version.") }, { id: 'help', type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") }, { id: 'telemetry', type: 'boolean', cat: 'o', description: localize('telemetry', "Shows all telemetry events which VS code collects.") }, - { id: 'folder-uri', type: 'string', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") }, - { id: 'file-uri', type: 'string', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") }, + { id: 'folder-uri', type: 'string[]', cat: 'o', args: 'uri', description: localize('folderUri', "Opens a window with given folder uri(s)") }, + { id: 'file-uri', type: 'string[]', cat: 'o', args: 'uri', description: localize('fileUri', "Opens a window with given file uri(s)") }, { id: 'extensions-dir', type: 'string', deprecates: 'extensionHomePath', cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") }, { id: 'list-extensions', type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") }, { id: 'show-versions', type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extension.") }, { id: 'category', type: 'string', cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extension.") }, - { id: 'install-extension', type: 'string', cat: 'e', args: 'extension-id | path-to-vsix', description: localize('installExtension', "Installs or updates the extension. Use `--force` argument to avoid prompts.") }, - { id: 'uninstall-extension', type: 'string', cat: 'e', args: 'extension-id', description: localize('uninstallExtension', "Uninstalls an extension.") }, - { id: 'enable-proposed-api', type: 'string', cat: 'e', args: 'extension-id', description: localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.") }, + { id: 'install-extension', type: 'string[]', cat: 'e', args: 'extension-id | path-to-vsix', description: localize('installExtension', "Installs or updates the extension. Use `--force` argument to avoid prompts.") }, + { id: 'uninstall-extension', type: 'string[]', cat: 'e', args: 'extension-id', description: localize('uninstallExtension', "Uninstalls an extension.") }, + { id: 'enable-proposed-api', type: 'string[]', cat: 'e', args: 'extension-id', description: localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.") }, { id: 'verbose', type: 'boolean', cat: 't', description: localize('verbose', "Print verbose output (implies --wait).") }, { id: 'log', type: 'string', cat: 't', args: 'level', description: localize('log', "Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.") }, { id: 'status', type: 'boolean', alias: 's', cat: 't', description: localize('status', "Print process usage and diagnostics information.") }, { id: 'prof-startup', type: 'boolean', cat: 't', description: localize('prof-startup', "Run CPU profiler during startup") }, { id: 'disable-extensions', type: 'boolean', deprecates: 'disableExtensions', cat: 't', description: localize('disableExtensions', "Disable all installed extensions.") }, - { id: 'disable-extension', type: 'string', cat: 't', args: 'extension-id', description: localize('disableExtension', "Disable an extension.") }, + { id: 'disable-extension', type: 'string[]', cat: 't', args: 'extension-id', description: localize('disableExtension', "Disable an extension.") }, { id: 'inspect-extensions', type: 'string', deprecates: 'debugPluginHost', args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") }, { id: 'inspect-brk-extensions', type: 'string', deprecates: 'debugBrkPluginHost', args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") }, @@ -66,8 +66,8 @@ export const options: Option[] = [ { id: 'max-memory', type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes).") }, { id: 'remote', type: 'string' }, - { id: 'locate-extension', type: 'string' }, - { id: 'extensionDevelopmentPath', type: 'string' }, + { id: 'locate-extension', type: 'string[]' }, + { id: 'extensionDevelopmentPath', type: 'string[]' }, { id: 'extensionTestsPath', type: 'string' }, { id: 'extension-development-confirm-save', type: 'boolean' }, { id: 'debugId', type: 'string' }, @@ -110,7 +110,7 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru } } - if (o.type === 'string') { + if (o.type === 'string' || o.type === 'string[]') { string.push(o.id); if (o.deprecates) { string.push(o.deprecates); @@ -132,6 +132,12 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru parsedArgs[o.id] = parsedArgs[o.deprecates]; delete parsedArgs[o.deprecates]; } + if (o.type === 'string[]') { + const val = parsedArgs[o.id]; + if (val && !Array.isArray(val)) { + parsedArgs[o.id] = [val]; + } + } } // https://github.com/microsoft/vscode/issues/58177 @@ -224,32 +230,6 @@ export function buildVersionMessage(version: string | undefined, commit: string return `${version || localize('unknownVersion', "Unknown version")}\n${commit || localize('unknownCommit', "Unknown commit")}\n${process.arch}`; } -/** - * Converts an argument into an array - * @param arg a argument value. Can be undefined, an entry or an array - */ -export function asArray(arg: string | string[] | undefined): string[] { - if (arg) { - if (Array.isArray(arg)) { - return arg; - } - return [arg]; - } - return []; -} - -/** - * Returns whether an argument is present. - */ -export function hasArgs(arg: string | string[] | undefined): boolean { - if (arg) { - if (Array.isArray(arg)) { - return !!arg.length; - } - return true; - } - return false; -} export function addArg(argv: string[], ...args: string[]): string[] { const endOfArgsMarkerIndex = argv.indexOf('--'); diff --git a/src/vs/platform/launch/electron-main/launchService.ts b/src/vs/platform/launch/electron-main/launchService.ts index 19e396d605263..876d2198d1fce 100644 --- a/src/vs/platform/launch/electron-main/launchService.ts +++ b/src/vs/platform/launch/electron-main/launchService.ts @@ -17,7 +17,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { URI } from 'vs/base/common/uri'; import { BrowserWindow, ipcMain, Event as IpcEvent, app } from 'electron'; import { Event } from 'vs/base/common/event'; -import { hasArgs } from 'vs/platform/environment/node/argv'; import { coalesce } from 'vs/base/common/arrays'; import { IDiagnosticInfoOptions, IDiagnosticInfo, IRemoteDiagnosticInfo, IRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics'; import { IMainProcessInfo, IWindowInfo } from 'vs/platform/launch/common/launchService'; @@ -173,7 +172,7 @@ export class LaunchService implements ILaunchService { } // Start without file/folder arguments - else if (!hasArgs(args._) && !hasArgs(args['folder-uri']) && !hasArgs(args['file-uri'])) { + else if (!args._.length && !args['folder-uri'] && !args['file-uri']) { let openNewWindow = false; // Force new window diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index d8ad2212ace83..d8037ae2470ec 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -583,13 +583,9 @@ export class RawDebugSession { const v = args[key]; if (v) { - if (Array.isArray(v)) { - v.push(value); - } else { - args[key] = [v, value]; - } + v.push(value); } else { - args[key] = value; + args[key] = [value]; } } else { From 7a67a54e5e8fa3fff5333b43f88cad062da3795c Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 15:39:01 +0200 Subject: [PATCH 099/204] extensionDevelopmentPath is string[] --- src/bootstrap-window.js | 2 +- .../electron-browser/workbench/workbench.js | 2 +- src/vs/code/electron-main/window.ts | 2 +- src/vs/code/electron-main/windows.ts | 6 +--- src/vs/code/node/cliProcessMain.ts | 15 ++-------- src/vs/code/node/windowsFinder.ts | 25 ++++------------- .../environment/common/environment.ts | 16 +++++------ .../environment/node/environmentService.ts | 5 ---- .../platform/windows/electron-main/windows.ts | 4 +-- .../windows/electron-main/windowsService.ts | 5 ++-- .../workbench/browser/web.simpleservices.ts | 28 ++++--------------- .../extensionsTipsService.test.ts | 2 +- .../common/remoteAgentEnvironmentChannel.ts | 2 +- 13 files changed, 33 insertions(+), 81 deletions(-) diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index 85548f5196536..72403b1e4137c 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -34,7 +34,7 @@ exports.load = function (modulePaths, resultCallback, options) { * // configuration: IWindowConfiguration * @type {{ * zoomLevel?: number, - * extensionDevelopmentPath?: string | string[], + * extensionDevelopmentPath?: string[], * extensionTestsPath?: string, * userEnv?: { [key: string]: string | undefined }, * appRoot?: string, diff --git a/src/vs/code/electron-browser/workbench/workbench.js b/src/vs/code/electron-browser/workbench/workbench.js index 22d5dbe329c81..2a2c6981c7ddb 100644 --- a/src/vs/code/electron-browser/workbench/workbench.js +++ b/src/vs/code/electron-browser/workbench/workbench.js @@ -49,7 +49,7 @@ bootstrapWindow.load([ * @param {{ * partsSplashPath?: string, * highContrast?: boolean, - * extensionDevelopmentPath?: string | string[], + * extensionDevelopmentPath?: string[], * folderUri?: object, * workspace?: object * }} configuration diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index c6d2f29b1bad5..157300bb64be3 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -32,7 +32,7 @@ const RUN_TEXTMATE_IN_WORKER = false; export interface IWindowCreationOptions { state: IWindowState; - extensionDevelopmentPath?: string | string[]; + extensionDevelopmentPath?: string[]; isExtensionTestHost?: boolean; } diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 8541606e61a53..d4b330e55c5e4 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -1170,7 +1170,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService { return { openFolderInNewWindow: !!openFolderInNewWindow, openFilesInNewWindow }; } - openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string | string[], openConfig: IOpenConfiguration): void { + openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): void { // Reload an existing extension development host window on the same path // We currently do not allow more than one extension development window @@ -1207,10 +1207,6 @@ export class WindowsManager extends Disposable implements IWindowsMainService { } } - if (!Array.isArray(extensionDevelopmentPath)) { - extensionDevelopmentPath = [extensionDevelopmentPath]; - } - let authority = ''; for (let p of extensionDevelopmentPath) { if (p.match(/^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/)) { diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index ee828c29374c5..94bb62a7518af 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -83,23 +83,14 @@ export class Main { async run(argv: ParsedArgs): Promise { if (argv['install-source']) { await this.setInstallSource(argv['install-source']); - } else if (argv['list-extensions']) { await this.listExtensions(!!argv['show-versions'], argv['category']); - } else if (argv['install-extension']) { - const arg = argv['install-extension']; - const args: string[] = typeof arg === 'string' ? [arg] : arg; - await this.installExtensions(args, !!argv['force']); - + await this.installExtensions(argv['install-extension'], !!argv['force']); } else if (argv['uninstall-extension']) { - const arg = argv['uninstall-extension']; - const ids: string[] = typeof arg === 'string' ? [arg] : arg; - await this.uninstallExtension(ids); + await this.uninstallExtension(argv['uninstall-extension']); } else if (argv['locate-extension']) { - const arg = argv['locate-extension']; - const ids: string[] = typeof arg === 'string' ? [arg] : arg; - await this.locateExtension(ids); + await this.locateExtension(argv['locate-extension']); } else if (argv['telemetry']) { console.log(buildTelemetryMessage(this.environmentService.appRoot, this.environmentService.extensionsPath ? this.environmentService.extensionsPath : undefined)); } diff --git a/src/vs/code/node/windowsFinder.ts b/src/vs/code/node/windowsFinder.ts index dc4b62e41ff4b..03e836c482702 100644 --- a/src/vs/code/node/windowsFinder.ts +++ b/src/vs/code/node/windowsFinder.ts @@ -14,7 +14,7 @@ export interface ISimpleWindow { openedWorkspace?: IWorkspaceIdentifier; openedFolderUri?: URI; - extensionDevelopmentPath?: string | string[]; + extensionDevelopmentPath?: string[]; lastFocusTime: number; } @@ -95,30 +95,17 @@ export function findWindowOnWorkspace(windows: W[], wor return null; } -export function findWindowOnExtensionDevelopmentPath(windows: W[], extensionDevelopmentPath: string | string[]): W | null { +export function findWindowOnExtensionDevelopmentPath(windows: W[], extensionDevelopmentPaths: string[]): W | null { const matches = (uriString: string): boolean => { - if (Array.isArray(extensionDevelopmentPath)) { - return extensionDevelopmentPath.some(p => extpath.isEqual(p, uriString, !platform.isLinux /* ignorecase */)); - } else if (extensionDevelopmentPath) { - return extpath.isEqual(extensionDevelopmentPath, uriString, !platform.isLinux /* ignorecase */); - } - return false; + return extensionDevelopmentPaths.some(p => extpath.isEqual(p, uriString, !platform.isLinux /* ignorecase */)); }; for (const window of windows) { // match on extension development path. The path can be one or more paths or uri strings, using paths.isEqual is not 100% correct but good enough - - if (window.extensionDevelopmentPath) { - if (Array.isArray(window.extensionDevelopmentPath)) { - if (window.extensionDevelopmentPath.some(p => matches(p))) { - return window; - } - } else if (window.extensionDevelopmentPath) { - if (matches(window.extensionDevelopmentPath)) { - return window; - } - } + const currPaths = window.extensionDevelopmentPath; + if (currPaths && currPaths.some(p => matches(p))) { + return window; } } diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 338a392f360ce..413381155d4bf 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -8,8 +8,8 @@ import { URI } from 'vs/base/common/uri'; export interface ParsedArgs { _: string[]; - 'folder-uri'?: string[]; - 'file-uri'?: string[]; + 'folder-uri'?: string[]; // undefined or array of 1 or more + 'file-uri'?: string[]; // undefined or array of 1 or more _urls?: string[]; help?: boolean; version?: boolean; @@ -36,7 +36,7 @@ export interface ParsedArgs { logExtensionHostCommunication?: boolean; 'extensions-dir'?: string; 'builtin-extensions-dir'?: string; - extensionDevelopmentPath?: string[]; // one or more local paths or URIs + extensionDevelopmentPath?: string[]; // // undefined or array of 1 or more local paths or URIs extensionTestsPath?: string; // either a local path or a URI 'extension-development-confirm-save'?: boolean; 'inspect-extensions'?: string; @@ -45,14 +45,14 @@ export interface ParsedArgs { 'inspect-search'?: string; 'inspect-brk-search'?: string; 'disable-extensions'?: boolean; - 'disable-extension'?: string[]; + 'disable-extension'?: string[]; // undefined or array of 1 or more 'list-extensions'?: boolean; 'show-versions'?: boolean; 'category'?: string; - 'install-extension'?: string[]; - 'uninstall-extension'?: string[]; - 'locate-extension'?: string[]; - 'enable-proposed-api'?: string[]; + 'install-extension'?: string[]; // undefined or array of 1 or more + 'uninstall-extension'?: string[]; // undefined or array of 1 or more + 'locate-extension'?: string[]; // undefined or array of 1 or more + 'enable-proposed-api'?: string[]; // undefined or array of 1 or more 'open-url'?: boolean; 'skip-getting-started'?: boolean; 'skip-release-notes'?: boolean; diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 3eb487a5c441e..e0cc96ad33b72 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -198,11 +198,6 @@ export class EnvironmentService implements IEnvironmentService { } return URI.file(path.normalize(p)); }); - } else if (s) { - if (/^[^:/?#]+?:\/\//.test(s)) { - return [URI.parse(s)]; - } - return [URI.file(path.normalize(s))]; } return undefined; } diff --git a/src/vs/platform/windows/electron-main/windows.ts b/src/vs/platform/windows/electron-main/windows.ts index 71479f9009ed5..d98d0727c5745 100644 --- a/src/vs/platform/windows/electron-main/windows.ts +++ b/src/vs/platform/windows/electron-main/windows.ts @@ -96,7 +96,7 @@ export interface IWindowsMainService { enterWorkspace(win: ICodeWindow, path: URI): Promise; closeWorkspace(win: ICodeWindow): void; open(openConfig: IOpenConfiguration): ICodeWindow[]; - openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string | string[], openConfig: IOpenConfiguration): void; + openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): void; pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickFileAndOpen(options: INativeOpenDialogOptions): Promise; @@ -140,4 +140,4 @@ export interface IOpenConfiguration { export interface ISharedProcess { whenReady(): Promise; toggle(): void; -} \ No newline at end of file +} diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index b02f54433d294..68863b9f4809a 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -309,8 +309,9 @@ export class WindowsService extends Disposable implements IWindowsService, IURLH async openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise { this.logService.trace('windowsService#openExtensionDevelopmentHostWindow ' + JSON.stringify(args)); - if (args.extensionDevelopmentPath) { - this.windowsMainService.openExtensionDevelopmentHostWindow(args.extensionDevelopmentPath, { + const extDevPaths = args.extensionDevelopmentPath; + if (extDevPaths) { + this.windowsMainService.openExtensionDevelopmentHostWindow(extDevPaths, { context: OpenContext.API, cli: args, userEnv: Object.keys(env).length > 0 ? env : undefined diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts index caf44465e739f..83f0c3b53c6b3 100644 --- a/src/vs/workbench/browser/web.simpleservices.ts +++ b/src/vs/workbench/browser/web.simpleservices.ts @@ -520,18 +520,9 @@ export class SimpleWindowsService implements IWindowsService { const f = args['folder-uri']; if (f) { - let u: URI | undefined; - if (Array.isArray(f)) { - if (f.length > 0) { - u = URI.parse(f[0]); - } - } else { - u = URI.parse(f); - } - if (u) { - gotFolder = true; - addQueryParameter('folder', u.path); - } + const u = URI.parse(f[0]); + gotFolder = true; + addQueryParameter('folder', u.path); } if (!gotFolder) { // request empty window @@ -540,17 +531,8 @@ export class SimpleWindowsService implements IWindowsService { const ep = args['extensionDevelopmentPath']; if (ep) { - let u: string | undefined; - if (Array.isArray(ep)) { - if (ep.length > 0) { - u = ep[0]; - } - } else { - u = ep; - } - if (u) { - addQueryParameter('edp', u); - } + let u = ep[0]; + addQueryParameter('edp', u); } const di = args['debugId']; diff --git a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts index 87deffa10018a..c019fde285db8 100644 --- a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts +++ b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts @@ -235,7 +235,7 @@ suite('ExtensionsTipsService Test', () => { }); setup(() => { - instantiationService.stub(IEnvironmentService, >{ extensionDevelopmentPath: false }); + instantiationService.stub(IEnvironmentService, >{}); instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []); instantiationService.stub(IExtensionGalleryService, 'isEnabled', true); instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(...mockExtensionGallery)); diff --git a/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts b/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts index fe15f2b644e0a..a1877e037aa0c 100644 --- a/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts +++ b/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts @@ -14,7 +14,7 @@ import { RemoteAuthorities } from 'vs/base/common/network'; export interface IGetEnvironmentDataArguments { language: string; remoteAuthority: string; - extensionDevelopmentPath: UriComponents | UriComponents[] | undefined; + extensionDevelopmentPath: UriComponents[] | undefined; } export interface IRemoteAgentEnvironmentDTO { From a00cb247b3d8baa95b35e10e88d7af68908ca957 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 15:46:00 +0200 Subject: [PATCH 100/204] cli: report unknown options --- src/vs/platform/environment/node/argv.ts | 40 ++++++++++++++----- .../platform/environment/node/argvHelper.ts | 12 ++++-- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 3d6d64e391062..0bd04cb3992c1 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -93,13 +93,12 @@ export const options: Option[] = [ { id: 'force', type: 'boolean' }, { id: 'trace-category-filter', type: 'string' }, { id: 'trace-options', type: 'string' }, - { id: '_', type: 'string' }, { id: 'js-flags', type: 'string' }, // chrome js flags { id: 'nolazy', type: 'boolean' }, // node inspect ]; -export function parseArgs(args: string[], isOptionSupported = (_: Option) => true): ParsedArgs { +export function parseArgs(args: string[], isOptionSupported = (_: Option) => true, reportUnknownOption: (id: string) => void = () => { }): ParsedArgs { const alias: { [key: string]: string } = {}; const string: string[] = []; const boolean: string[] = []; @@ -124,26 +123,47 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru } // remote aliases to avoid confusion const parsedArgs = minimist(args, { string, boolean, alias }); + + const cleanedArgs: any = {}; + for (const o of options) { if (o.alias) { delete parsedArgs[o.alias]; } - if (o.deprecates && parsedArgs.hasOwnProperty(o.deprecates) && !parsedArgs[o.id]) { - parsedArgs[o.id] = parsedArgs[o.deprecates]; + + let val = parsedArgs[o.id]; + if (o.deprecates && parsedArgs.hasOwnProperty(o.deprecates)) { + if (!val) { + val = parsedArgs[o.deprecates]; + } delete parsedArgs[o.deprecates]; } - if (o.type === 'string[]') { - const val = parsedArgs[o.id]; - if (val && !Array.isArray(val)) { - parsedArgs[o.id] = [val]; + + if (val) { + if (isOptionSupported(o)) { + if (o.type === 'string[]') { + if (val && !Array.isArray(val)) { + val = [val]; + } + } + cleanedArgs[o.id] = val; + + } else { + reportUnknownOption(o.id); } } + delete parsedArgs[o.id]; } // https://github.com/microsoft/vscode/issues/58177 - parsedArgs._ = parsedArgs._.filter(arg => arg.length > 0); + cleanedArgs._ = parsedArgs._.filter(arg => arg.length > 0); + delete parsedArgs._; + + for (let key in parsedArgs) { + reportUnknownOption(key); + } - return parsedArgs; + return cleanedArgs; } function formatUsage(option: Option) { diff --git a/src/vs/platform/environment/node/argvHelper.ts b/src/vs/platform/environment/node/argvHelper.ts index f2887c6191cdd..cdf620c33d205 100644 --- a/src/vs/platform/environment/node/argvHelper.ts +++ b/src/vs/platform/environment/node/argvHelper.ts @@ -10,7 +10,12 @@ import { ParsedArgs } from '../common/environment'; import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files'; import { parseArgs } from 'vs/platform/environment/node/argv'; -function validate(args: ParsedArgs): ParsedArgs { +function parseAndValidate(cmdLineArgs: string[]): ParsedArgs { + const onUnknownOption = (id: string) => { + throw new Error(localize('unknownOption', "Option '{0}' is unknown. Use --help for the list of supported options.", id)); + }; + + const args = parseArgs(cmdLineArgs, undefined, onUnknownOption); if (args.goto) { args._.forEach(arg => assert(/^(\w:)?[^:]+(:\d*){0,2}$/.test(arg), localize('gotoValidation', "Arguments in `--goto` mode should be in the format of `FILE(:LINE(:CHARACTER))`."))); } @@ -42,7 +47,7 @@ export function parseMainProcessArgv(processArgv: string[]): ParsedArgs { args = stripAppPath(args) || []; } - return validate(parseArgs(args)); + return parseAndValidate(args); } /** @@ -54,6 +59,7 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs { if (process.env['VSCODE_DEV']) { args = stripAppPath(args) || []; } + console.log(args.join(',')); - return validate(parseArgs(args)); + return parseAndValidate(args); } From d591cb7e6d4e986ac177bc4465b8c70f481b5a98 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 15:48:55 +0200 Subject: [PATCH 101/204] fixes #80054 --- .../extensions/common/extensionUrlHandler.ts | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts b/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts index f1afdb4562b94..4299e57ff73e7 100644 --- a/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts +++ b/src/vs/workbench/services/extensions/common/extensionUrlHandler.ts @@ -28,7 +28,6 @@ const FIVE_MINUTES = 5 * 60 * 1000; const THIRTY_SECONDS = 30 * 1000; const URL_TO_HANDLE = 'extensionUrlHandler.urlToHandle'; const CONFIRMED_EXTENSIONS_CONFIGURATION_KEY = 'extensions.confirmedUriHandlerExtensionIds'; -const CONFIRMED_EXTENSIONS_STORAGE_KEY = 'extensionUrlHandler.confirmedExtensions'; function isExtensionId(value: string): boolean { return /^[a-z0-9][a-z0-9\-]*\.[a-z0-9][a-z0-9\-]*$/i.test(value); @@ -128,7 +127,7 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler { } if (result.checkboxChecked) { - this.addConfirmedExtensionIdToStorage(extensionId); + await this.addConfirmedExtensionIdToStorage(extensionId); } } @@ -290,10 +289,8 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler { } private getConfirmedExtensionIds(): Set { - const ids = [ - ...this.getConfirmedExtensionIdsFromStorage(), - ...this.getConfirmedExtensionIdsFromConfiguration(), - ].map(extensionId => ExtensionIdentifier.toKey(extensionId)); + const ids = this.getConfirmedExtensionIdsFromConfiguration() + .map(extensionId => ExtensionIdentifier.toKey(extensionId)); return new Set(ids); } @@ -308,26 +305,12 @@ class ExtensionUrlHandler implements IExtensionUrlHandler, IURLHandler { return confirmedExtensionIds; } - private getConfirmedExtensionIdsFromStorage(): Array { - const confirmedExtensionIdsJson = this.storageService.get(CONFIRMED_EXTENSIONS_STORAGE_KEY, StorageScope.GLOBAL, '[]'); - - try { - return JSON.parse(confirmedExtensionIdsJson); - } catch (err) { - return []; - } - } + private async addConfirmedExtensionIdToStorage(extensionId: string): Promise { + const confirmedExtensionIds = this.configurationService.getValue>(CONFIRMED_EXTENSIONS_CONFIGURATION_KEY); + const set = new Set(confirmedExtensionIds); + set.add(extensionId); - private addConfirmedExtensionIdToStorage(extensionId: string): void { - const existingConfirmedExtensionIds = this.getConfirmedExtensionIdsFromStorage(); - this.storageService.store( - CONFIRMED_EXTENSIONS_STORAGE_KEY, - JSON.stringify([ - ...existingConfirmedExtensionIds, - ExtensionIdentifier.toKey(extensionId), - ]), - StorageScope.GLOBAL, - ); + await this.configurationService.updateValue(CONFIRMED_EXTENSIONS_CONFIGURATION_KEY, [...set.values()]); } dispose(): void { From 5ebf2ab887ed219e4937f2d950d5a1810e472bb5 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 5 Sep 2019 15:49:04 +0200 Subject: [PATCH 102/204] introduce debug.onTaskErrors fixes #68084 --- .../debug/browser/debug.contribution.ts | 5 +++ .../contrib/debug/browser/debugService.ts | 34 ++++++++++++++----- .../workbench/contrib/debug/common/debug.ts | 1 + 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debug.contribution.ts b/src/vs/workbench/contrib/debug/browser/debug.contribution.ts index f3dd71816953c..1118cac8180ad 100644 --- a/src/vs/workbench/contrib/debug/browser/debug.contribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debug.contribution.ts @@ -264,6 +264,11 @@ configurationRegistry.registerConfiguration({ type: 'boolean', description: nls.localize('debug.focusWindowOnBreak', "Controls whether the workbench window should be focused when the debugger breaks."), default: true + }, + 'debug.onTaskErrors': { + enum: ['debugAnyway', 'showErrors', 'prompt'], + description: nls.localize('debug.onTaskErrors', "Controls what to do when errors are encountered after running a preLaunchTask."), + default: 'prompt' } } }); diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index 95bd40e002aab..c0ffa798e9516 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -37,7 +37,7 @@ import { parse, getFirstFrame } from 'vs/base/common/console'; import { TaskEvent, TaskEventKind, TaskIdentifier } from 'vs/workbench/contrib/tasks/common/tasks'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { INotificationService } from 'vs/platform/notification/common/notification'; -import { IAction, Action } from 'vs/base/common/actions'; +import { IAction } from 'vs/base/common/actions'; import { deepClone, equals } from 'vs/base/common/objects'; import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession'; import { dispose, IDisposable } from 'vs/base/common/lifecycle'; @@ -686,13 +686,18 @@ export class DebugService implements IDebugService { private runTaskAndCheckErrors(root: IWorkspaceFolder | undefined, taskId: string | TaskIdentifier | undefined): Promise { - const debugAnywayAction = new Action('debug.debugAnyway', nls.localize('debugAnyway', "Debug Anyway"), undefined, true, () => Promise.resolve(TaskRunResult.Success)); return this.runTask(root, taskId).then((taskSummary: ITaskSummary) => { + const errorCount = taskId ? this.markerService.getStatistics().errors : 0; const successExitCode = taskSummary && taskSummary.exitCode === 0; const failureExitCode = taskSummary && taskSummary.exitCode !== undefined && taskSummary.exitCode !== 0; - if (successExitCode || (errorCount === 0 && !failureExitCode)) { - return TaskRunResult.Success; + const onTaskErrors = this.configurationService.getValue('debug').onTaskErrors; + if (successExitCode || onTaskErrors === 'debugAnyway' || (errorCount === 0 && !failureExitCode)) { + return TaskRunResult.Success; + } + if (onTaskErrors === 'showErrors') { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID); + return Promise.resolve(TaskRunResult.Failure); } const taskLabel = typeof taskId === 'string' ? taskId : taskId ? taskId.name : ''; @@ -702,14 +707,27 @@ export class DebugService implements IDebugService { ? nls.localize('preLaunchTaskError', "Error exists after running preLaunchTask '{0}'.", taskLabel) : nls.localize('preLaunchTaskExitCode', "The preLaunchTask '{0}' terminated with exit code {1}.", taskLabel, taskSummary.exitCode); - const showErrorsAction = new Action('debug.showErrors', nls.localize('showErrors', "Show Errors"), undefined, true, () => { + return this.dialogService.confirm({ + checkbox: { + label: nls.localize('remember', "Remember my choice in settings"), + }, + message, + type: 'warning', + primaryButton: nls.localize('debugAnyway', "Debug Anyway"), + secondaryButton: nls.localize('showErrors', "Show Errors"), + }).then(result => { + if (result.checkboxChecked) { + this.configurationService.updateValue('debug.onTaskErrors', result.confirmed ? 'debugAnyway' : 'showErrors'); + } + if (result.confirmed) { + return TaskRunResult.Success; + } + this.panelService.openPanel(Constants.MARKERS_PANEL_ID); return Promise.resolve(TaskRunResult.Failure); }); - - return this.showError(message, [debugAnywayAction, showErrorsAction]); }, (err: TaskError) => { - return this.showError(err.message, [debugAnywayAction, this.taskService.configureAction()]); + return this.showError(err.message, [this.taskService.configureAction()]); }); } diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 311d3ada0662e..18707656b9722 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -454,6 +454,7 @@ export interface IDebugConfiguration { wordWrap: boolean; }; focusWindowOnBreak: boolean; + onTaskErrors: 'debugAnyway' | 'showErrors' | 'prompt'; } export interface IGlobalConfig { From 02be15500c5da325336ee82b8a34e0c658df9b86 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 5 Sep 2019 15:49:39 +0200 Subject: [PATCH 103/204] debug: wording polish --- src/vs/workbench/contrib/debug/browser/debugService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index c0ffa798e9516..13898ad10bb72 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -709,7 +709,7 @@ export class DebugService implements IDebugService { return this.dialogService.confirm({ checkbox: { - label: nls.localize('remember', "Remember my choice in settings"), + label: nls.localize('remember', "Remember my choice in user settings"), }, message, type: 'warning', From 5a16d6e6176d4ed37539ee9ef1d66f67770371f4 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 15:56:28 +0200 Subject: [PATCH 104/204] Respect scheme of defaultUri in remote file picker Fixes https://github.com/microsoft/vscode-remote-release/issues/1271 --- .../services/dialogs/browser/remoteFileDialog.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts index 28fb4787d24a1..9354baad05866 100644 --- a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts +++ b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts @@ -101,7 +101,7 @@ export class RemoteFileDialog { } public async showOpenDialog(options: IOpenDialogOptions = {}): Promise { - this.scheme = this.getScheme(options.availableFileSystems); + this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri); this.userHome = await this.getUserHome(); const newOptions = await this.getOptions(options); if (!newOptions) { @@ -112,7 +112,7 @@ export class RemoteFileDialog { } public async showSaveDialog(options: ISaveDialogOptions): Promise { - this.scheme = this.getScheme(options.availableFileSystems); + this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri); this.userHome = await this.getUserHome(); this.requiresTrailing = true; const newOptions = await this.getOptions(options, true); @@ -157,8 +157,14 @@ export class RemoteFileDialog { return resources.toLocalResource(URI.from({ scheme: this.scheme, path }), this.scheme === Schemas.file ? undefined : this.remoteAuthority); } - private getScheme(available: string[] | undefined): string { - return available ? available[0] : Schemas.file; + private getScheme(available: string[] | undefined, defaultUri: URI | undefined): string { + if (available) { + if (defaultUri && (available.indexOf(defaultUri.scheme) >= 0)) { + return defaultUri.scheme; + } + return available[0]; + } + return Schemas.file; } private async getRemoteAgentEnvironment(): Promise { @@ -215,7 +221,7 @@ export class RemoteFileDialog { this.filePickBox.autoFocusOnList = false; this.filePickBox.ignoreFocusOut = true; this.filePickBox.ok = true; - if (this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) { + if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) { this.filePickBox.customButton = true; this.filePickBox.customLabel = nls.localize('remoteFileDialog.local', 'Show Local'); let action; From bcd154cc32b0b52050e14ce4e9d71d20d181b7b9 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 16:01:19 +0200 Subject: [PATCH 105/204] Keep mixin of the raw options --- src/vs/editor/browser/config/configuration.ts | 2 +- .../common/config/commonEditorConfig.ts | 97 +++++++------------ src/vs/editor/common/config/editorOptions.ts | 8 +- 3 files changed, 42 insertions(+), 65 deletions(-) diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts index 8e8a71d3345f5..9078c4fe7cf15 100644 --- a/src/vs/editor/browser/config/configuration.ts +++ b/src/vs/editor/browser/config/configuration.ts @@ -320,7 +320,7 @@ export class Configuration extends CommonEditorConfiguration { this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => this._onCSSBasedConfigurationChanged())); - if (this._validatedOptions2.get(EditorOption.automaticLayout)) { + if (this._validatedOptions.get(EditorOption.automaticLayout)) { this._elementSizeObserver.startObserving(); } diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index f751b1bcbcf47..73c1e7669c771 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -81,31 +81,7 @@ class EditorConfiguration2 { return result; } - private static _mix(a: any, b: any): any { - switch (typeof b) { - case 'bigint': return b; - case 'boolean': return b; - case 'function': return b; - case 'number': return b; - case 'object': return (Array.isArray(b) || typeof a !== 'object' ? b : objects.mixin(objects.mixin({}, a), b)); - case 'string': return b; - default: - return a; - } - } - - public static mixOptions(a: RawEditorOptions, _b: IEditorOptions): RawEditorOptions { - const b: { [key: string]: any; } = _b; - const result = new RawEditorOptions(); - for (const editorOption of editorOptionsRegistry) { - const bValue = b[editorOption.name]; - result._write(editorOption.id, EditorConfiguration2._mix(a._read(editorOption.id), bValue)); - } - return result; - } - public static validateOptions(options: RawEditorOptions): ValidatedEditorOptions { - // console.log(`validateOptions`, options); const result = new ValidatedEditorOptions(); for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.validate(options._read(editorOption.id))); @@ -114,7 +90,6 @@ class EditorConfiguration2 { } public static computeOptions(options: ValidatedEditorOptions, env: IEnvironmentalOptions): ComputedEditorOptions { - // console.log(`computeOptions`, options, env); const result = new ComputedEditorOptions(); for (const editorOption of editorOptionsRegistry) { result._write(editorOption.id, editorOption.compute(env, result, options._read(editorOption.id))); @@ -123,7 +98,6 @@ class EditorConfiguration2 { } public static checkEquals(a: ComputedEditorOptions, b: ComputedEditorOptions): ConfigurationChangedEvent | null { - // console.log(`equals`, a, b); const result: boolean[] = []; let somethingChanged = false; for (const editorOption of editorOptionsRegistry) { @@ -207,40 +181,38 @@ function migrateOptions(options: IEditorOptions): void { } } -export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { +function deepCloneAndMigrateOptions(_options: IEditorOptions): IEditorOptions { + const options = objects.deepClone(_options); + migrateOptions(options); + return options; +} - public readonly isSimpleWidget: boolean; - protected _rawOptions: IEditorOptions; - private _isDominatedByLongLines: boolean; - private _lineNumbersDigitCount: number; +export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration { private _onDidChange = this._register(new Emitter()); public readonly onDidChange: Event = this._onDidChange.event; - private _rawOptions2: RawEditorOptions; - protected _validatedOptions2: ValidatedEditorOptions; + public readonly isSimpleWidget: boolean; public options!: ComputedEditorOptions; - constructor(isSimpleWidget: boolean, options: IEditorOptions) { - super(); - migrateOptions(options); - - this.isSimpleWidget = isSimpleWidget; + private _isDominatedByLongLines: boolean; + private _lineNumbersDigitCount: number; - // Do a "deep clone of sorts" on the incoming options - this._rawOptions = objects.mixin({}, options || {}); - this._rawOptions.scrollbar = objects.mixin({}, this._rawOptions.scrollbar || {}); - this._rawOptions.minimap = objects.mixin({}, this._rawOptions.minimap || {}); - this._rawOptions.find = objects.mixin({}, this._rawOptions.find || {}); - this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {}); - this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {}); + private _rawOptions: IEditorOptions; + private _readOptions: RawEditorOptions; + protected _validatedOptions: ValidatedEditorOptions; - this._rawOptions2 = EditorConfiguration2.readOptions(options); - this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); + constructor(isSimpleWidget: boolean, _options: IEditorOptions) { + super(); + this.isSimpleWidget = isSimpleWidget; this._isDominatedByLongLines = false; this._lineNumbersDigitCount = 1; + this._rawOptions = deepCloneAndMigrateOptions(_options); + this._readOptions = EditorConfiguration2.readOptions(this._rawOptions); + this._validatedOptions = EditorConfiguration2.validateOptions(this._readOptions); + this._register(EditorZoom.onDidChangeZoomLevel(_ => this._recomputeOptions())); this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions())); } @@ -256,15 +228,17 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed const oldOptions = this.options; const newOptions = this._computeInternalOptions(); - const changeEvent = (oldOptions ? EditorConfiguration2.checkEquals(oldOptions, newOptions) : null); + if (!oldOptions) { + this.options = newOptions; + } else { + const changeEvent = EditorConfiguration2.checkEquals(oldOptions, newOptions); - if (oldOptions && changeEvent === null) { - return; - } - - this.options = newOptions; + if (changeEvent === null) { + // nothing changed! + return; + } - if (changeEvent) { + this.options = newOptions; this._onDidChange.fire(changeEvent); } } @@ -275,7 +249,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed private _computeInternalOptions(): ComputedEditorOptions { const partialEnv = this._getEnvConfiguration(); - const bareFontInfo = BareFontInfo.createFromValidatedSettings(this._validatedOptions2, partialEnv.zoomLevel, this.isSimpleWidget); + const bareFontInfo = BareFontInfo.createFromValidatedSettings(this._validatedOptions, partialEnv.zoomLevel, this.isSimpleWidget); const env: IEnvironmentalOptions = { outerWidth: partialEnv.outerWidth, outerHeight: partialEnv.outerHeight, @@ -288,7 +262,7 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed tabFocusMode: TabFocus.getTabFocusMode(), accessibilitySupport: partialEnv.accessibilitySupport }; - return EditorConfiguration2.computeOptions(this._validatedOptions2, env); + return EditorConfiguration2.computeOptions(this._validatedOptions, env); } private static _primitiveArrayEquals(a: any[], b: any[]): boolean { @@ -331,18 +305,17 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed return true; } - public updateOptions(newOptions: IEditorOptions): void { - if (typeof newOptions === 'undefined') { + public updateOptions(_newOptions: IEditorOptions): void { + if (typeof _newOptions === 'undefined') { return; } - migrateOptions(newOptions); + const newOptions = deepCloneAndMigrateOptions(_newOptions); if (CommonEditorConfiguration._subsetEquals(this._rawOptions, newOptions)) { return; } this._rawOptions = objects.mixin(this._rawOptions, newOptions || {}); - this._rawOptions2 = EditorConfiguration2.mixOptions(this._rawOptions2, newOptions); - - this._validatedOptions2 = EditorConfiguration2.validateOptions(this._rawOptions2); + this._readOptions = EditorConfiguration2.readOptions(this._rawOptions); + this._validatedOptions = EditorConfiguration2.validateOptions(this._readOptions); this._recomputeOptions(); } diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 702d1aa9f0ab8..8fb99020115ec 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -1556,7 +1556,9 @@ class EditorPixelRatio> extends EditorIntOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { - // The lineHeight is computed from the fontSize if it is 0 and the result of that computation is in the env.fontInfo + // The lineHeight is computed from the fontSize if it is 0. + // Moreover, the final lineHeight respects the editor zoom level. + // So take the result from env.fontInfo return env.fontInfo.lineHeight; } } @@ -1574,7 +1576,9 @@ class EditorFontSize return _clamp(r, 8, 100); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { - return value; + // The final fontSize respects the editor zoom level. + // So take the result from env.fontInfo + return env.fontInfo.fontSize; } } From c27d4e086e7409a19f67f4c8b514044187f1d295 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 16:03:45 +0200 Subject: [PATCH 106/204] enableProposedApiFor is string[] --- .../extensions/common/abstractExtensionService.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/services/extensions/common/abstractExtensionService.ts b/src/vs/workbench/services/extensions/common/abstractExtensionService.ts index bcfa887b1a462..8bd6d25f2ca96 100644 --- a/src/vs/workbench/services/extensions/common/abstractExtensionService.ts +++ b/src/vs/workbench/services/extensions/common/abstractExtensionService.ts @@ -443,7 +443,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx class ProposedApiController { - private readonly enableProposedApiFor: string | string[]; + private readonly enableProposedApiFor: string[]; private readonly enableProposedApiForAll: boolean; private readonly productAllowProposedApi: Set; @@ -451,15 +451,8 @@ class ProposedApiController { @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IProductService productService: IProductService ) { - this.enableProposedApiFor = environmentService.args['enable-proposed-api'] || []; - if (this.enableProposedApiFor.length) { - // Make enabled proposed API be lowercase for case insensitive comparison - if (Array.isArray(this.enableProposedApiFor)) { - this.enableProposedApiFor = this.enableProposedApiFor.map(id => id.toLowerCase()); - } else { - this.enableProposedApiFor = this.enableProposedApiFor.toLowerCase(); - } - } + // Make enabled proposed API be lowercase for case insensitive comparison + this.enableProposedApiFor = (environmentService.args['enable-proposed-api'] || []).map(id => id.toLowerCase()); this.enableProposedApiForAll = !environmentService.isBuilt || (!!environmentService.extensionDevelopmentLocationURI && productService.nameLong !== 'Visual Studio Code') || From ad3289c0eb1fc59b2f575716aa2e05ec5f8f91e0 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 5 Sep 2019 16:21:36 +0200 Subject: [PATCH 107/204] Remove IEditorOption.equals --- .../common/config/commonEditorConfig.ts | 18 ++- src/vs/editor/common/config/editorOptions.ts | 146 ------------------ 2 files changed, 17 insertions(+), 147 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 73c1e7669c771..a6442a9038c18 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -7,6 +7,7 @@ import * as nls from 'vs/nls'; import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; +import * as arrays from 'vs/base/common/arrays'; import * as platform from 'vs/base/common/platform'; import { IEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; @@ -97,11 +98,26 @@ class EditorConfiguration2 { return result; } + private static _deepEquals(a: T, b: T): boolean { + if (typeof a !== 'object' || typeof b !== 'object') { + return (a === b); + } + if (Array.isArray(a) || Array.isArray(b)) { + return (Array.isArray(a) && Array.isArray(b) ? arrays.equals(a, b) : false); + } + for (let key in a) { + if (!EditorConfiguration2._deepEquals(a[key], b[key])) { + return false; + } + } + return true; + } + public static checkEquals(a: ComputedEditorOptions, b: ComputedEditorOptions): ConfigurationChangedEvent | null { const result: boolean[] = []; let somethingChanged = false; for (const editorOption of editorOptionsRegistry) { - const changed = !editorOption.equals(a._read(editorOption.id), b._read(editorOption.id)); + const changed = !EditorConfiguration2._deepEquals(a._read(editorOption.id), b._read(editorOption.id)); result[editorOption.id] = changed; if (changed) { somethingChanged = true; diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 8fb99020115ec..13c42151c9d80 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -5,8 +5,6 @@ import * as nls from 'vs/nls'; import * as assert from 'vs/base/common/assert'; -import * as arrays from 'vs/base/common/arrays'; -import * as objects from 'vs/base/common/objects'; import * as platform from 'vs/base/common/platform'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { FontInfo } from 'vs/editor/common/config/fontInfo'; @@ -1144,10 +1142,6 @@ export interface IEditorOption> extends BaseEditorOption { @@ -1296,12 +1287,6 @@ class EditorRenderLineNumbersOption public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number[]): number[] { return value; } - public equals(a: number[], b: number[]): boolean { - return arrays.equals(a, b); - } } //#endregion @@ -1593,9 +1543,6 @@ class EditorFontInfo Date: Thu, 5 Sep 2019 16:25:48 +0200 Subject: [PATCH 108/204] cli: warn when singular argument is defined multiple times --- src/vs/platform/environment/node/argv.ts | 22 +++++++++++++++---- .../platform/environment/node/argvHelper.ts | 14 +++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 0bd04cb3992c1..9447623138000 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -98,7 +98,17 @@ export const options: Option[] = [ { id: 'nolazy', type: 'boolean' }, // node inspect ]; -export function parseArgs(args: string[], isOptionSupported = (_: Option) => true, reportUnknownOption: (id: string) => void = () => { }): ParsedArgs { +export interface ErrorReporter { + onUnknownOption(id: string): void; + onMultipleValues(id: string, usedValue: string): void; +} + +const ignoringReporter: ErrorReporter = { + onUnknownOption: () => { }, + onMultipleValues: () => { } +}; + +export function parseArgs(args: string[], isOptionSupported = (_: Option) => true, errorReporter: ErrorReporter = ignoringReporter): ParsedArgs { const alias: { [key: string]: string } = {}; const string: string[] = []; const boolean: string[] = []; @@ -145,11 +155,15 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru if (val && !Array.isArray(val)) { val = [val]; } + } else if (o.type === 'string') { + if (Array.isArray(val)) { + val = val.pop(); // take the last + errorReporter.onMultipleValues(o.id, val); + } } cleanedArgs[o.id] = val; - } else { - reportUnknownOption(o.id); + errorReporter.onUnknownOption(o.id); } } delete parsedArgs[o.id]; @@ -160,7 +174,7 @@ export function parseArgs(args: string[], isOptionSupported = (_: Option) => tru delete parsedArgs._; for (let key in parsedArgs) { - reportUnknownOption(key); + errorReporter.onUnknownOption(key); } return cleanedArgs; diff --git a/src/vs/platform/environment/node/argvHelper.ts b/src/vs/platform/environment/node/argvHelper.ts index cdf620c33d205..0f547fe4b031e 100644 --- a/src/vs/platform/environment/node/argvHelper.ts +++ b/src/vs/platform/environment/node/argvHelper.ts @@ -8,14 +8,19 @@ import { firstIndex } from 'vs/base/common/arrays'; import { localize } from 'vs/nls'; import { ParsedArgs } from '../common/environment'; import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files'; -import { parseArgs } from 'vs/platform/environment/node/argv'; +import { parseArgs, ErrorReporter } from 'vs/platform/environment/node/argv'; function parseAndValidate(cmdLineArgs: string[]): ParsedArgs { - const onUnknownOption = (id: string) => { - throw new Error(localize('unknownOption', "Option '{0}' is unknown. Use --help for the list of supported options.", id)); + const errorReporter: ErrorReporter = { + onUnknownOption: (id) => { + throw new Error(localize('unknownOption', "Option '{0}' is unknown. Use --help for the list of supported options.", id)); + }, + onMultipleValues: (id, val) => { + console.warn(localize('multipleValues', "Option '{0}' is defined more than once. Using value '{1}.'", id, val)); + } }; - const args = parseArgs(cmdLineArgs, undefined, onUnknownOption); + const args = parseArgs(cmdLineArgs, undefined, errorReporter); if (args.goto) { args._.forEach(arg => assert(/^(\w:)?[^:]+(:\d*){0,2}$/.test(arg), localize('gotoValidation', "Arguments in `--goto` mode should be in the format of `FILE(:LINE(:CHARACTER))`."))); } @@ -59,7 +64,6 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs { if (process.env['VSCODE_DEV']) { args = stripAppPath(args) || []; } - console.log(args.join(',')); return parseAndValidate(args); } From f9f58c32aed1ec0635bab0a2b1603965ccb8bb13 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 16:46:13 +0200 Subject: [PATCH 109/204] update distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae225a90bbfef..9310251ecc126 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.39.0", - "distro": "1bba48aa5a9271599af81fc8ca35b813c16e7c4b", + "distro": "dd0b9cd1073431de0640a4b0e1a5ba2b49e00658", "author": { "name": "Microsoft Corporation" }, From dea88d893b202fe55e81b35513293f3a979432ec Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 16:55:20 +0200 Subject: [PATCH 110/204] add disable-inspect to argv options --- src/vs/platform/environment/node/argv.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 9447623138000..c3cbae52feae3 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -93,6 +93,7 @@ export const options: Option[] = [ { id: 'force', type: 'boolean' }, { id: 'trace-category-filter', type: 'string' }, { id: 'trace-options', type: 'string' }, + { id: 'disable-inspect', type: 'boolean' }, { id: 'js-flags', type: 'string' }, // chrome js flags { id: 'nolazy', type: 'boolean' }, // node inspect From 27f011cb1ddd59a10352130e9cb21bdffaf33133 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 17:19:44 +0200 Subject: [PATCH 111/204] only warn when using unknown option --- src/vs/platform/environment/node/argvHelper.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vs/platform/environment/node/argvHelper.ts b/src/vs/platform/environment/node/argvHelper.ts index 0f547fe4b031e..74191bb01df1f 100644 --- a/src/vs/platform/environment/node/argvHelper.ts +++ b/src/vs/platform/environment/node/argvHelper.ts @@ -10,17 +10,17 @@ import { ParsedArgs } from '../common/environment'; import { MIN_MAX_MEMORY_SIZE_MB } from 'vs/platform/files/common/files'; import { parseArgs, ErrorReporter } from 'vs/platform/environment/node/argv'; -function parseAndValidate(cmdLineArgs: string[]): ParsedArgs { +function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): ParsedArgs { const errorReporter: ErrorReporter = { onUnknownOption: (id) => { - throw new Error(localize('unknownOption', "Option '{0}' is unknown. Use --help for the list of supported options.", id)); + console.warn(localize('unknownOption', "Option '{0}' is unknown. Ignoring.", id)); }, onMultipleValues: (id, val) => { console.warn(localize('multipleValues', "Option '{0}' is defined more than once. Using value '{1}.'", id, val)); } }; - const args = parseArgs(cmdLineArgs, undefined, errorReporter); + const args = parseArgs(cmdLineArgs, undefined, reportWarnings ? errorReporter : undefined); if (args.goto) { args._.forEach(arg => assert(/^(\w:)?[^:]+(:\d*){0,2}$/.test(arg), localize('gotoValidation', "Arguments in `--goto` mode should be in the format of `FILE(:LINE(:CHARACTER))`."))); } @@ -52,7 +52,9 @@ export function parseMainProcessArgv(processArgv: string[]): ParsedArgs { args = stripAppPath(args) || []; } - return parseAndValidate(args); + // If called from CLI, don't report warnings as they are already reported. + let reportWarnings = !process.env['VSCODE_CLI']; + return parseAndValidate(args, reportWarnings); } /** @@ -65,5 +67,5 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs { args = stripAppPath(args) || []; } - return parseAndValidate(args); + return parseAndValidate(args, true); } From 8cf8b523b9bb2be41c045ad3711b6fb0db2ea118 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 17:46:25 +0200 Subject: [PATCH 112/204] :lipstick: refactor AsyncDataTree tests --- .../browser/ui/tree/asyncDataTree.test.ts | 333 +++++------------- 1 file changed, 88 insertions(+), 245 deletions(-) diff --git a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts index 0c7d67a253a87..f57c017c0af22 100644 --- a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts +++ b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts @@ -27,30 +27,43 @@ function find(elements: Element[] | undefined, id: string): Element { throw new Error('element not found'); } +class Renderer implements ITreeRenderer { + readonly templateId = 'default'; + renderTemplate(container: HTMLElement): HTMLElement { + return container; + } + renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { + templateData.textContent = element.element.id; + } + disposeTemplate(templateData: HTMLElement): void { + // noop + } +} + +class IdentityProvider implements IIdentityProvider { + getId(element: Element) { + return element.id; + } +} + +class VirtualDelegate implements IListVirtualDelegate { + getHeight() { return 20; } + getTemplateId(element: Element): string { return 'default'; } +} + +class Model { + + constructor(readonly root: Element) { } + + get(id: string): Element { + return find(this.root.children, id); + } +} + suite('AsyncDataTree', function () { test('Collapse state should be preserved across refresh calls', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const dataSource = new class implements IAsyncDataSource { hasChildren(element: Element): boolean { @@ -61,70 +74,42 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a' }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); assert.equal(container.querySelectorAll('.monaco-list-row').length, 0); - await tree.setInput(root); + await tree.setInput(model.root); assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; assert(!hasClass(twistie, 'collapsible')); assert(!hasClass(twistie, 'collapsed')); - _('a').children = [ + model.get('a').children = [ { id: 'aa' }, { id: 'ab' }, { id: 'ac' } ]; - await tree.updateChildren(root); + await tree.updateChildren(model.root); assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); - await tree.expand(_('a')); + await tree.expand(model.get('a')); assert.equal(container.querySelectorAll('.monaco-list-row').length, 4); - _('a').children = []; - await tree.updateChildren(root); + model.get('a').children = []; + await tree.updateChildren(model.root); assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); }); test('issue #68648', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const getChildrenCalls: string[] = []; const dataSource = new class implements IAsyncDataSource { @@ -137,25 +122,17 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a' }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); - await tree.setInput(root); + await tree.setInput(model.root); assert.deepStrictEqual(getChildrenCalls, ['root']); let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; @@ -163,8 +140,8 @@ suite('AsyncDataTree', function () { assert(!hasClass(twistie, 'collapsed')); assert(tree.getNode().children[0].collapsed); - _('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]; - await tree.updateChildren(root); + model.get('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]; + await tree.updateChildren(model.root); assert.deepStrictEqual(getChildrenCalls, ['root', 'root']); twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; @@ -172,8 +149,8 @@ suite('AsyncDataTree', function () { assert(hasClass(twistie, 'collapsed')); assert(tree.getNode().children[0].collapsed); - _('a').children = []; - await tree.updateChildren(root); + model.get('a').children = []; + await tree.updateChildren(model.root); assert.deepStrictEqual(getChildrenCalls, ['root', 'root', 'root']); twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; @@ -181,8 +158,8 @@ suite('AsyncDataTree', function () { assert(!hasClass(twistie, 'collapsed')); assert(tree.getNode().children[0].collapsed); - _('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]; - await tree.updateChildren(root); + model.get('a').children = [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }]; + await tree.updateChildren(model.root); assert.deepStrictEqual(getChildrenCalls, ['root', 'root', 'root', 'root']); twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; @@ -193,26 +170,6 @@ suite('AsyncDataTree', function () { test('issue #67722 - once resolved, refreshed collapsed nodes should only get children when expanded', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const getChildrenCalls: string[] = []; const dataSource = new class implements IAsyncDataSource { @@ -225,63 +182,35 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }] }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); - await tree.setInput(root); - assert(tree.getNode(_('a')).collapsed); + await tree.setInput(model.root); + assert(tree.getNode(model.get('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root']); - await tree.expand(_('a')); - assert(!tree.getNode(_('a')).collapsed); + await tree.expand(model.get('a')); + assert(!tree.getNode(model.get('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root', 'a']); - tree.collapse(_('a')); - assert(tree.getNode(_('a')).collapsed); + tree.collapse(model.get('a')); + assert(tree.getNode(model.get('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root', 'a']); await tree.updateChildren(); - assert(tree.getNode(_('a')).collapsed); + assert(tree.getNode(model.get('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root', 'a', 'root'], 'a should not be refreshed, since it\' collapsed'); }); test('resolved collapsed nodes which lose children should lose twistie as well', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const dataSource = new class implements IAsyncDataSource { hasChildren(element: Element): boolean { @@ -292,64 +221,36 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }] }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); - await tree.setInput(root); - await tree.expand(_('a')); + await tree.setInput(model.root); + await tree.expand(model.get('a')); let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; assert(hasClass(twistie, 'collapsible')); assert(!hasClass(twistie, 'collapsed')); - assert(!tree.getNode(_('a')).collapsed); + assert(!tree.getNode(model.get('a')).collapsed); - tree.collapse(_('a')); - _('a').children = []; - await tree.updateChildren(root); + tree.collapse(model.get('a')); + model.get('a').children = []; + await tree.updateChildren(model.root); twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; assert(!hasClass(twistie, 'collapsible')); assert(!hasClass(twistie, 'collapsed')); - assert(tree.getNode(_('a')).collapsed); + assert(tree.getNode(model.get('a')).collapsed); }); test('support default collapse state per element', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const getChildrenCalls: string[] = []; const dataSource = new class implements IAsyncDataSource { @@ -362,47 +263,25 @@ suite('AsyncDataTree', function () { } }; - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a', children: [{ id: 'aa' }, { id: 'ab' }, { id: 'ac' }] }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { collapseByDefault: el => el.id !== 'a' }); tree.layout(200); - await tree.setInput(root); - assert(!tree.getNode(_('a')).collapsed); + await tree.setInput(model.root); + assert(!tree.getNode(model.get('a')).collapsed); assert.deepStrictEqual(getChildrenCalls, ['root', 'a']); }); test('issue #80098 - concurrent refresh and expand', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const calls: Function[] = []; const dataSource = new class implements IAsyncDataSource { @@ -414,32 +293,24 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a', children: [{ id: 'aa' }] }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); - const pSetInput = tree.setInput(root); + const pSetInput = tree.setInput(model.root); calls.pop()!(); // resolve getChildren(root) await pSetInput; - const pUpdateChildrenA = tree.updateChildren(_('a')); - const pExpandA = tree.expand(_('a')); + const pUpdateChildrenA = tree.updateChildren(model.get('a')); + const pExpandA = tree.expand(model.get('a')); assert.equal(calls.length, 1, 'expand(a) still hasn\'t called getChildren(a)'); calls.pop()!(); @@ -454,26 +325,6 @@ suite('AsyncDataTree', function () { test('issue #80098 - first expand should call getChildren', async () => { const container = document.createElement('div'); - container.style.width = '200px'; - container.style.height = '200px'; - - const delegate = new class implements IListVirtualDelegate { - getHeight() { return 20; } - getTemplateId(element: Element): string { return 'default'; } - }; - - const renderer = new class implements ITreeRenderer { - readonly templateId = 'default'; - renderTemplate(container: HTMLElement): HTMLElement { - return container; - } - renderElement(element: ITreeNode, index: number, templateData: HTMLElement): void { - templateData.textContent = element.element.id; - } - disposeTemplate(templateData: HTMLElement): void { - // noop - } - }; const calls: Function[] = []; const dataSource = new class implements IAsyncDataSource { @@ -485,31 +336,23 @@ suite('AsyncDataTree', function () { } }; - const identityProvider = new class implements IIdentityProvider { - getId(element: Element) { - return element.id; - } - }; - - const root: Element = { + const model = new Model({ id: 'root', children: [{ id: 'a', children: [{ id: 'aa' }] }] - }; - - const _: (id: string) => Element = find.bind(null, root.children); + }); - const tree = new AsyncDataTree('test', container, delegate, [renderer], dataSource, { identityProvider }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); tree.layout(200); - const pSetInput = tree.setInput(root); + const pSetInput = tree.setInput(model.root); calls.pop()!(); // resolve getChildren(root) await pSetInput; - const pExpandA = tree.expand(_('a')); + const pExpandA = tree.expand(model.get('a')); assert.equal(calls.length, 1, 'expand(a) should\'ve called getChildren(a)'); let race = await Promise.race([pExpandA.then(() => 'expand'), timeout(1).then(() => 'timeout')]); From 3aa0fc0b52ff16402268c7670f5b203c02124c3a Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 17:47:59 +0200 Subject: [PATCH 113/204] fixes #80414 --- build/azure-pipelines/product-compile.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/build/azure-pipelines/product-compile.yml b/build/azure-pipelines/product-compile.yml index 794dd8e3b99af..76e1f6a927a19 100644 --- a/build/azure-pipelines/product-compile.yml +++ b/build/azure-pipelines/product-compile.yml @@ -104,6 +104,7 @@ steps: AZURE_WEBVIEW_STORAGE_ACCESS_KEY="$(vscode-webview-storage-key)" \ ./build/azure-pipelines/common/publish-webview.sh displayName: Publish Webview + condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true')) - script: | set -e From 7af28da188e4c1f71275ded57f5ef93209706eff Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Thu, 5 Sep 2019 18:25:18 +0200 Subject: [PATCH 114/204] add cancel request to DAP --- .../contrib/debug/common/debugProtocol.d.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts b/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts index 8854146a48484..5091ba1a598dd 100644 --- a/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts +++ b/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts @@ -10,7 +10,7 @@ declare module DebugProtocol { /** Base class of requests, responses, and events. */ export interface ProtocolMessage { - /** Sequence number. */ + /** Sequence number. For protocol messages of type 'request' this number can be used to cancel the request. */ seq: number; /** Message type. Values: 'request', 'response', 'event', etc. @@ -59,6 +59,25 @@ declare module DebugProtocol { }; } + /** Cancel request; value of command field is 'cancel'. + This request can be used to cancel another request. Clients should only call this request if the capability 'supportsCancelRequest' is true. + A request that got canceled still needs to send a response back. This can either be a partial result or an error response. + */ + export interface CancelRequest extends Request { + // command: 'cancel'; + arguments?: CancelArguments; + } + + /** Arguments for 'cancel' request. */ + export interface CancelArguments { + /** The ID (attribute 'seq') of the request to cancel. */ + requestId?: number; + } + + /** Response to 'cancel' request. This is just an acknowledgement, so no body field is required. */ + export interface CancelResponse extends Response { + } + /** Event message for 'initialized' event type. This event indicates that the debug adapter is ready to accept configuration requests (e.g. SetBreakpointsRequest, SetExceptionBreakpointsRequest). A debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the 'initialize' request has finished). @@ -1330,6 +1349,8 @@ declare module DebugProtocol { supportsReadMemoryRequest?: boolean; /** The debug adapter supports the 'disassemble' request. */ supportsDisassembleRequest?: boolean; + /** The debug adapter supports the 'cancel' request. */ + supportsCancelRequest?: boolean; } /** An ExceptionBreakpointsFilter is shown in the UI as an option for configuring how exceptions are dealt with. */ From aed274d5aaf15bf903699286323fad60f4e528d5 Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 5 Sep 2019 09:28:06 -0700 Subject: [PATCH 115/204] Update new Octicons --- .../ui/octiconLabel/octicons/octicons2.css | 9 +-- .../ui/octiconLabel/octicons/octicons2.svg | 59 +++++++++--------- .../ui/octiconLabel/octicons/octicons2.ttf | Bin 35588 -> 35936 bytes 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.css b/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.css index 64ad6e37f6f5c..5a87b9095c0e5 100644 --- a/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.css +++ b/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.css @@ -1,7 +1,7 @@ @font-face { font-family: "octicons2"; - src: url("./octicons2.ttf?81972c7f658ef56eeefe672e514d35a3") format("truetype"), -url("./octicons2.svg?81972c7f658ef56eeefe672e514d35a3#octicons2") format("svg"); + src: url("./octicons2.ttf?d8711b2fb33d14ed72f2a5859ed5f80a") format("truetype"), +url("./octicons2.svg?d8711b2fb33d14ed72f2a5859ed5f80a#octicons2") format("svg"); } .octicon, .mega-octicon { @@ -247,5 +247,6 @@ body[data-octicons-update="enabled"] .octicon-warning:before { content: "\f02d" body[data-octicons-update="enabled"] .octicon-controls:before { content: "\26ad" } body[data-octicons-update="enabled"] .octicon-event:before { content: "\26ae" } body[data-octicons-update="enabled"] .octicon-record-keys:before { content: "\26af" } -body[data-octicons-update="enabled"] .octicon-archive:before { content: "\f101" } -body[data-octicons-update="enabled"] .octicon-arrow-both:before { content: "\f102" } +body[data-octicons-update="enabled"] .octicon-Vector:before { content: "\f101" } +body[data-octicons-update="enabled"] .octicon-archive:before { content: "\f102" } +body[data-octicons-update="enabled"] .octicon-arrow-both:before { content: "\f103" } diff --git a/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.svg b/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.svg index f80a5eab7fb5a..f84fb747a0a64 100644 --- a/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.svg +++ b/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.svg @@ -7,14 +7,17 @@ units-per-em="1000" ascent="820" descent="180" /> + + horiz-adv-x="1000" d=" M837.5 157.5C818.75 207.5018750000001 812.5 257.5018750000001 812.5 307.501875V432.501875C812.5 513.751875 787.5 588.751875 731.25 645.0018749999999C681.25 707.501875 606.25 745.001875 531.25 751.251875C487.5 757.5019374999999 443.75 757.5019374999999 400 738.751875C356.25 720.001875 318.75 707.501875 287.5 676.2518749999999C256.25 645.0018749999999 231.25 613.7518749999999 212.5 570.001875C193.75 532.5018749999999 187.5 488.751875 187.5 445.001875V307.501875C187.5 257.5018750000001 175 207.5018750000001 162.5 157.5L125 51.25L156.25 7.5H375C375 -23.75 387.5 -55 412.5 -80C431.25 -105 462.5 -117.5 500 -117.5C537.5 -117.5 562.5 -105 587.5 -80C612.5 -55 625 -23.75 625 7.5H843.75L875 51.25L837.5 157.5zM543.75 -36.25C531.25 -48.75 512.5 -55 500 -55C487.5 -55 468.75 -48.75 456.25 -36.25C443.75 -23.75 437.5 -11.25 437.5 7.5H500H562.5C562.5 -11.25 556.25 -23.75 543.75 -36.25zM587.5 70H562.5H437.5H412.5H200L225 138.75C237.5 195.0018750000001 250 251.251875 250 307.501875V445.001875C250 482.501875 256.25 513.751875 268.75 545.001875C281.25 576.2518749999999 306.25 607.5018749999999 331.25 626.251875C356.25 651.251875 387.5 670.0018749999999 418.75 676.2518749999999C456.25 695.001875 487.5 695.001875 525 695.001875C587.5 688.751875 643.75 657.501875 687.5 607.5018749999999C731.25 557.5018749999999 750 495.001875 750 432.501875V307.501875C750 251.251875 756.25 195.0018750000001 775 138.75L800 70H587.5z" /> @@ -210,7 +213,7 @@ horiz-adv-x="1000" d=" M660.625 748.75L865.625 542.5L875 520V-86.25L843.75 -117.5H156.25L125 -86.25V726.25L156.25 757.5H638.75L660.625 748.75zM625 507.5H812.5L625 695V507.5zM187.5 695V-55H812.5V445H593.75L562.5 476.25V695H187.5zM687.5 382.5H312.5V320H687.5V382.5zM312.5 257.5H687.5V195H312.5V257.5zM687.5 132.5H312.5V70H687.5V132.5z" /> + horiz-adv-x="1000" d=" M570.625 -117.5L537.5 -69.375C555.5625 -45.7437500000001 563.8225 -16.05625 560.563125 13.50625C557.30375 43.075 542.77625 70.24375 520 89.375C481.715 121.36875 455.48 165.4625 445.625 214.375C348.125 75 398.75 -1.875 445.625 -70L411.25 -117.5C345.975 -105.2 287.3575 -69.6937499999999 246.228125 -17.53125C205.09875 34.625 184.238125 99.90625 187.5 166.25C187.5 166.25 174.375 301.25 330 433.125C330 433.125 506.25 596.25 445 716.875L489.375 757.5C557.074375 710.03 608.86625 643.2275 637.9749999999999 565.835C667.0749999999999 488.443125 672.1437500000001 404.0675 652.5 323.75C667.3187499999999 338.21125 679.20625 355.401875 687.5 374.375L741.875 378.75C746.25 371.25 856.875 195.625 797.5 47.5C776.35 3.3249999999999 744.5374999999999 -34.8875 704.93125 -63.6937499999999C665.325 -92.5 619.16625 -110.99375 570.625 -117.5zM445.625 316.875L500 292.5C497.10125 263.988125 500.776875 235.1906250000001 510.745 208.320625C520.7125 181.4500000000001 536.7075 157.225 557.5 137.5C584.289375 117.9812499999999 604.58 90.85 615.728125 59.6374999999999C626.875 28.4187499999999 628.3625000000001 -5.425 620 -37.5C645.83125 -28.45 669.56875 -14.2625 689.7624999999999 4.2125C709.95625 22.69375 726.1999999999999 45.06875 737.5 70C758.71875 146.0875 749.53125 227.4400000000001 711.875 296.875C700.0375 277.6756250000001 682.84375 262.3575 662.4124999999999 252.806875C641.9749999999999 243.2568749999999 619.1975 239.89125 596.875 243.125L575 285.625C602.376875 344.8275 611.70125 410.7850000000001 601.808125 475.25625C591.915 539.728125 563.2437500000001 599.855 519.375 648.125C510.625 515.625 375 393.125 370.625 386.25C241.25 276.25 250 174.375 250 170C247.559375 131.4 255.48625 92.85 272.959375 58.34375C290.4325 23.8312500000001 316.815625 -5.36875 349.375 -26.25C312.5 61.25 312.5 166.25 447.5 316.875H445.625z" /> @@ -228,7 +231,7 @@ horiz-adv-x="1000" d=" M843.75 570H743.75C750 595 750 620 750 645C743.75 663.75 737.5 682.5 725 701.25C712.5 720 700 732.5 681.25 738.75C662.5 745 643.75 757.5 625 757.5C606.25 757.5 587.5 757.5 568.75 745C525 732.5 493.75 701.25 468.75 663.75C443.75 701.25 412.5 732.5 368.75 745C350 751.25 331.25 757.5 312.5 757.5C293.75 757.5 275 751.25 256.25 738.75C237.5 732.5 225 720 212.5 701.25C200 688.75 193.75 663.75 187.5 645C187.5 620 187.5 595 193.75 570H93.75L62.5 538.75V-23.75L93.75 -55H843.75L875 -23.75V538.75L843.75 570zM437.5 7.5H125V507.5H437.5V7.5zM437.5 570H250C250 576.25 250 576.25 250 582.5C243.75 601.25 243.75 613.75 243.75 632.5C250 645 250 657.5 262.5 663.75C268.75 676.25 281.25 682.5 293.75 688.75C300 695 312.5 695 325 695C337.5 695 350 695 362.5 688.75C381.25 682.5 400 670 412.5 651.25C425 632.5 437.5 613.75 437.5 588.75V570zM500 588.75C500 613.75 512.5 632.5 525 651.25C537.5 670 556.25 682.5 575 688.75C587.5 695 600 695 612.5 695C625 695 637.5 695 650 688.75C662.5 682.5 668.75 676.25 681.25 663.75C687.5 657.5 687.5 645 693.75 632.5C693.75 613.75 693.75 601.25 687.5 582.5C687.5 576.25 687.5 576.25 681.25 570H500V588.75zM812.5 7.5H500V507.5H812.5V7.5z" /> + horiz-adv-x="1000" d=" M187.5 -55H437.5V-111.875L443.126875 -117.5H156.25L125 -86.25V726.25L156.25 757.5H638.75L660.625 748.749375L865.625 542.5037500000001L875 519.996875V361.251875C858.8187499999999 385.2593750000001 837.4625 405.330625 812.5 419.9987500000001V445H593.75L562.5 476.25V695H187.5V-55zM812.5 507.5L625 695V507.5H812.5zM843.75 257.5V195H906.25L937.5 163.75V-86.25L906.25 -117.5H531.25L500 -86.25V163.75L531.25 195H593.75V257.5C593.75 290.651875 606.92125 322.444375 630.3625000000001 345.88625C653.80625 369.32875 685.6 382.5 718.75 382.5C751.9 382.5 783.69375 369.32875 807.1374999999999 345.88625C830.5812500000001 322.444375 843.75 290.651875 843.75 257.5zM674.55625 301.696875C662.8375 289.97625 656.25 274.07625 656.25 257.5V195H781.25V257.5C781.25 274.07625 774.6625 289.97625 762.94375 301.696875C751.225 313.4181250000001 735.325 320 718.75 320C702.175 320 686.275 313.4181250000001 674.55625 301.696875zM562.5 132.5V-55H875V132.5H562.5z" /> @@ -237,16 +240,16 @@ horiz-adv-x="1000" d=" M875.28125 477.43C875.425 506.336875 867.51875 534.713125 852.4562500000001 559.3812499999999C837.3812499999999 584.049375 815.74375 604.035625 789.9562500000001 617.10125C764.1687499999999 630.166875 735.2562499999999 635.795625 706.45625 633.358125C677.64375 630.9200000000001 650.09375 620.51125 626.86875 603.2975C603.645625 586.084375 585.671875 562.7462499999999 574.96375 535.89625C564.255625 509.045625 561.2287500000001 479.744375 566.2318750000001 451.273125C571.235 422.8025 584.060625 396.28375 603.2800000000001 374.693125C622.5 353.09875 647.3562499999999 337.28375 675.0500000000001 329.016875C664.825 308.2325 649 290.706875 629.3625000000001 278.420625C609.724375 266.13125 587.05 259.5625 563.8818749999999 259.450625H439.3225C393.21 259.2887500000001 348.80875 241.9706250000001 314.7625 210.8718749999999V511.74625C352.5675 519.463125 386.160625 540.9425 409.029375 572.020625C431.8981250000001 603.098125 442.41125 641.56 438.5331250000001 679.9493749999999C434.655625 718.33875 416.66125 753.920625 388.039375 779.797C359.4175 805.673125 322.2075 820 283.6225 820C245.0375 820 207.8275 805.673125 179.205 779.797C150.583125 753.920625 132.589375 718.33875 128.71125 679.9493749999999C124.8325 641.56 135.3475 603.098125 158.215625 572.020625C181.08375 540.9425 214.6775 519.463125 252.4825 511.74625V131.8375C214.748125 124.625 180.95875 103.84375 157.488125 73.43125C134.0175 43.0124999999999 122.4875 5.0625 125.073125 -33.2687500000001C127.65875 -71.5999999999999 144.18125 -107.6624999999999 171.524375 -134.6437500000001C198.8675 -161.6312499999999 235.140625 -177.68125 273.5025 -179.7687499999999C311.8643750000001 -181.8499999999999 349.6625 -169.8249999999999 379.7675 -145.9562499999999C409.873125 -122.09375 430.2043750000001 -88.03125 436.9262500000001 -50.20625C443.64875 -12.3812499999999 436.299375 26.59375 416.260625 59.375C396.223125 92.15625 364.883125 116.46875 328.1525000000001 127.7312500000001C338.3975000000001 148.49375 354.226875 165.9875 373.8643750000001 178.25625C393.501875 190.525 416.16875 197.070625 439.3225 197.170625H563.8818749999999C602.744375 197.349375 640.58125 209.643125 672.1312499999999 232.338125C703.6750000000001 255.0325000000001 727.35625 286.99875 739.8875 323.7856250000001C777.2125 328.693125 811.5 346.96625 836.4 375.21625C861.2937499999999 403.46625 875.1062499999999 439.7775 875.28125 477.43zM190.2025 664.27C190.2025 682.746875 195.68125 700.808125 205.94625 716.17125C216.211875 731.53375 230.801875 743.5074999999999 247.871875 750.57875C264.9425000000001 757.649 283.72625 759.499125 301.8475 755.894375C319.969375 752.29 336.615 743.3925 349.68 730.3275C362.745625 717.2625 371.6425 700.6168749999999 375.2475 682.495C378.851875 664.3731250000001 377.001875 645.589375 369.93125 628.5193750000001C362.86 611.449375 350.88625 596.85875 335.52375 586.59375C320.160625 576.32875 302.099375 570.85 283.6225 570.85C258.8456250000001 570.85 235.084375 580.6925 217.564375 598.211875C200.045 615.73125 190.2025 639.493125 190.2025 664.27zM377.0425 -20.80625C377.0425 -39.2875 371.563125 -57.34375 361.2981250000001 -72.7062500000001C351.033125 -88.06875 336.443125 -100.04375 319.3725 -107.11875C302.3025 -114.1875 283.51875 -116.0375 265.3975000000001 -112.4375C247.275625 -108.8312499999999 230.63 -99.93125 217.564375 -86.86875C204.499375 -73.8000000000001 195.6025 -57.15625 191.9975 -39.0375C188.393125 -20.9124999999999 190.243125 -2.13125 197.31375 14.9375C204.384375 32.0125 216.35875 46.6 231.72125 56.86875C247.08375 67.13125 265.145625 72.6125000000001 283.6225 72.6125000000001C308.39875 72.6125000000001 332.160625 62.76875 349.68 45.25C367.2000000000001 27.725 377.0425 3.96875 377.0425 -20.80625zM719.58125 384.01C701.10625 384.01 683.0437499999999 389.490625 667.68125 399.754375C652.3187499999999 410.0193750000001 640.34375 424.61 633.275 441.68C626.20625 458.75 624.351875 477.53375 627.95625 495.655C631.5625 513.776875 640.45625 530.423125 653.525 543.488125C666.5875 556.5531249999999 683.2375000000001 565.45 701.35625 569.0550000000001C719.475 572.659375 738.2625 570.809375 755.33125 563.73875C772.40625 556.668125 786.9937500000001 544.694375 797.25625 529.33125C807.51875 513.96875 813 495.906875 813 477.43C813 452.65375 803.15625 428.8918750000001 785.6375 411.3725C768.11875 393.854375 744.35625 384.01 719.58125 384.01z" /> + horiz-adv-x="1000" d=" M686.175 507.5C652.6875 541.7506249999999 608.665625 563.76125 561.1725 570V820H498.6725V570C447.8575 562.346875 401.35875 537.05125 367.330625 498.543125C333.3025 460.035 313.916875 410.776875 312.5743750000001 359.405625C311.2325 308.035 328.02 257.8306250000001 359.99125 217.598125C391.9625 177.36875 437.076875 149.6687499999999 487.423125 139.375H498.6725V-110.625H561.1725V139.375C579.265 141.65625 596.941875 146.49375 613.6724999999999 153.75C653.7937499999999 170.0625 688.0125 198.18 711.8 234.375C735.75 270.284375 748.575 312.4575 748.675 355.6218750000001C748.61875 412.495625 726.16875 467.06375 686.175 507.5zM642.4250000000001 242.500625C613.02375 213.2731250000001 573.2525 196.87125 531.7975 196.8768750000001C500.914375 196.8562500000001 470.7175 205.983125 445.02125 223.114375C419.3243750000001 240.245 399.281875 264.60625 387.423125 293.1218750000001C378.4468750000001 314.4525 374.340625 337.51625 375.404375 360.634375C376.468125 383.7518750000001 382.6756250000001 406.341875 393.5718750000001 426.758125C404.46875 447.174375 419.7806250000001 464.91 438.395 478.660625C457.00875 492.411875 478.45625 501.833125 501.173125 506.24875C511.360625 507.17 521.61 507.17 531.7975 506.24875C553.2325000000001 506.709375 574.525625 502.6675 594.2975 494.3775C622.813125 482.518125 647.175 462.471875 664.30625 436.775625C681.4375 411.0793750000001 690.5687499999999 380.881875 690.55 349.9987500000001C689.81875 329.375 685.025 309.0975 676.44375 290.3293750000001C667.8625000000001 271.5606250000001 655.66875 254.67 640.55 240.62375L642.4250000000001 242.500625z" /> + horiz-adv-x="1000" d=" M829.55625 336.840625C800.15625 366.068125 760.38125 382.4700000000001 718.9250000000001 382.464375C688.0437499999999 382.485 657.85 373.350625 632.15 356.219375C606.454375 339.08875 586.411875 314.7275 574.5525 286.2118750000001C570.90625 277.3493749999999 568.183125 268.1375 566.4275 258.7156250000001C502.53125 265.7275000000001 442.93875 294.318125 397.4856250000001 339.770625C352.033125 385.223125 323.43875 444.8193750000001 316.4275 508.715625C325.84875 510.47125 335.0643750000001 513.194375 343.9275 516.84125C372.443125 528.7 396.8037500000001 548.739375 413.935 574.435625C431.065625 600.131875 440.196875 630.32875 440.17625 661.211875C440.636875 682.646875 436.59125 703.94 428.3012500000001 723.711875C420.50875 742.653125 409.0425 759.866125 394.56 774.3484375C380.0775 788.83075 362.8687500000001 800.3013125 343.9275 808.09325C324.1550000000001 816.38343125 302.8625 820.4254025 281.4275 819.9645975C250.544375 819.9851908125 220.346875 810.850375 194.650625 793.7195C168.954375 776.5885625 148.911875 752.2275 137.0525 723.711875C125.3025 695.1 122.23875 663.661875 128.240625 633.319375C134.2425 602.97625 149.043125 575.0725 170.80125 553.088125C192.708125 531.700625 220.2325 516.968125 250.1775 510.5925V191.8375000000001C230.268125 187.9500000000001 211.346875 180.0875 194.551875 168.7125C169.065625 151.3812499999999 149.10625 127.08125 137.0525 98.7125C125.123125 70.125 121.96 38.6437500000001 127.9625 8.25625C133.964375 -22.13125 148.86125 -50.05 170.763125 -71.95C192.665 -93.85 220.58375 -108.75 250.97125 -114.75C281.3581250000001 -120.75 312.844375 -117.59375 341.42875 -105.6625C369.944375 -93.8062500000001 394.305625 -73.75625 411.4362500000001 -48.0625C428.5668750000001 -22.36875 437.698125 7.83125 437.6775 38.7125C438.138125 60.15 434.0925 81.44375 425.8025 101.2125C418.010625 120.15625 406.54375 137.3625 392.06125 151.84375C377.579375 166.3250000000001 360.37 177.7937500000001 341.42875 185.5875C332.156875 189.4437499999999 322.525625 192.375 312.6775 194.3375V344.340625C344.968125 298.703125 387.865625 261.598125 437.6775 236.2168750000001C478.380625 215.3768749999999 522.745 202.6425000000001 568.3043749999999 198.718125C572.82375 176.05625 582.311875 154.675 596.086875 136.125C609.86125 117.5750000000001 627.58125 102.3125 647.9625 91.43125C668.34375 80.5562500000001 690.8874999999999 74.33125 713.96875 73.2125C737.05 72.09375 760.0875 76.1062499999999 781.4250000000001 84.9625C809.9437499999999 96.8249999999999 834.30625 116.86875 851.4375 142.5687499999999C868.56875 168.2625000000001 877.69375 198.459375 877.675 229.3425000000001C876.20625 270.06625 858.95 308.618125 829.55625 336.840625zM317.053125 125.5875C334.3062500000001 118.28125 349.06875 106.11875 359.5525 90.5875C371.56625 72.5562500000001 376.96125 50.9250000000001 374.8225 29.3625C372.684375 7.8 363.14375 -12.3625 347.8225 -27.6812500000001C332.500625 -43.00625 312.346875 -52.5437499999999 290.7850000000001 -54.6875C269.223125 -56.8249999999999 247.58375 -51.425 229.55125 -39.4125C214.02 -28.9250000000001 201.8625 -14.1625 194.551875 3.09375C187.615 20.125 185.8775 38.825 189.554375 56.84375C193.083125 75.09375 201.9925 91.8625 215.135625 105.00625C228.27875 118.15 245.054375 127.05625 263.30375 130.5875C281.32125 134.2625000000001 300.023125 132.5250000000001 317.053125 125.5875zM281.4275 569.964375C262.975 569.954375 244.92875 575.389375 229.55125 585.589375C214.02 596.073125 201.8625 610.839375 194.551875 628.093125C187.615 645.1231250000001 185.8775 663.8243749999999 189.554375 681.8418750000001C193.083125 700.09125 201.9925 716.863125 215.135625 730.00625C228.27875 743.149375 245.054375 752.05875 263.30375 755.5875C281.32125 759.2644375 300.023125 757.5274375 317.053125 750.590625C334.3062500000001 743.28 349.06875 731.118125 359.5525 715.586875C368.9362500000001 701.4612500000001 374.3125 685.056875 375.10875 668.1168749999999C375.905 651.176875 372.09375 634.339375 364.0768750000001 619.395625C356.059375 604.45125 344.13875 591.959375 329.584375 583.255C315.03 574.550625 298.38625 569.958125 281.4275 569.964375zM785.175 159.9625C769.8812499999999 144.65625 749.76875 135.1125000000001 728.2375 132.9437499999999C706.70625 130.78125 685.0875 136.13125 667.0500000000001 148.0875C651.5187500000001 158.5749999999999 639.3625 173.3375 632.05 190.59375C625.1125 207.623125 623.3775 226.3243749999999 627.05625 244.341875C630.58125 262.59125 639.49375 279.363125 652.6374999999999 292.50625C665.78125 305.6493750000001 682.55625 314.5587500000001 700.80625 318.0875000000001C718.8187499999999 321.764375 737.525 320.0275000000001 754.5500000000001 313.090625C771.80625 305.78 786.56875 293.618125 797.0500000000001 278.086875C809.0125 260.051875 814.3625 238.436875 812.19375 216.906875C810.03125 195.3762499999999 800.4875000000001 175.25625 785.175 159.9625z" /> + horiz-adv-x="1000" d=" M382.431875 149.96875L461.808125 70.5875H346.183125C321.31875 70.5875 297.4725 80.46875 279.89125 98.0500000000001C262.309375 115.63125 252.433125 139.4749999999999 252.433125 164.3375V508.09C262.280625 510.053125 271.9106250000001 512.985 281.1825 516.84125C309.6975 528.7 334.060625 548.739375 351.1912500000001 574.435625C368.3225 600.131875 377.45375 630.32875 377.433125 661.211875C377.89375 682.646875 373.848125 703.94 365.5575 723.711875C357.765625 742.653125 346.296875 759.866125 331.8150000000001 774.3484375C317.3325000000001 788.83075 300.123125 800.3013125 281.1825 808.09325C261.41 816.38343125 240.1175 820.4254025 218.6825 819.9645975C187.799375 819.9851908125 157.60375 810.850375 131.9075 793.7195C106.21125 776.5885625 86.166875 752.2275 74.3075 723.711875C62.5575 695.1 59.4916875 663.661875 65.49375 633.319375C71.495625 602.97625 86.3 575.0725 108.058125 553.088125C129.965 531.700625 157.4875 516.968125 187.4325 510.5925V163.7125C187.349375 143.175 191.335625 122.81875 199.15875 103.8250000000001C206.981875 84.83125 218.486875 67.56875 233.0125 53.04375C247.538125 38.51875 264.796875 27.0125 283.791875 19.1937499999999C302.78625 11.36875 323.14 7.38125 343.6825 7.4625H459.3075L379.933125 -71.9125L424.308125 -116.28125L557.433125 16.84375V60.5875L424.308125 193.7125L382.431875 149.96875zM221.183125 570.59C202.73 570.5799999999999 184.685625 576.015 169.30875 586.215C153.776875 596.69875 141.6175 611.465 134.306875 628.71875C127.37 645.74875 125.63125 664.45 129.3075 682.4675C132.836875 700.716875 141.745625 717.48875 154.889375 730.631875C168.0325 743.775 184.808125 752.684375 203.0575 756.213125C221.074375 759.8900625 239.778125 758.1530625 256.808125 751.21625C274.061875 743.905625 288.8243750000001 731.74375 299.308125 716.2125C308.691875 702.086875 314.0675 685.6825 314.864375 668.7425000000001C315.660625 651.8025 311.8475000000001 634.965 303.83 620.02125C295.813125 605.076875 283.8918750000001 592.585 269.3375000000001 583.880625C254.78375 575.17625 238.14125 570.58375 221.183125 570.59z M894.3125 149.9625000000001C872.575 171.58125 844.975 186.3499999999999 814.93125 192.4625V539.3375000000001C815.0187500000001 559.879375 811.03125 580.23375 803.20625 599.228125C795.3875 618.2225 783.875 635.48375 769.35 650.009375C754.8249999999999 664.535 737.56875 676.038125 718.5749999999999 683.8612499999999C699.5812500000001 691.684375 679.225 695.67 658.68125 695.5875H543.06L622.4325 774.9636875L578.0600000000001 819.33624375L444.933125 686.21125V642.46375L578.0600000000001 509.33875L622.4325 553.7112500000001L543.06 633.0875H658.68125C683.55 633.0875 707.3937500000001 623.210625 724.975 605.629375C742.55625 588.0475 752.43125 564.20125 752.43125 539.3375000000001V192.4625C732.525 188.5749999999999 713.60625 180.7125 696.80625 169.3375C671.3249999999999 152 651.3625 127.6999999999999 639.30625 99.3375C627.38125 70.75 624.2162500000001 39.2687500000001 630.21875 8.88125C636.21875 -21.50625 651.11875 -49.425 673.01875 -71.325C694.91875 -93.23125 722.8375 -108.125 753.225 -114.125C783.6125000000001 -120.13125 815.1 -116.96875 843.6875 -105.04375C872.1999999999999 -93.1812500000001 896.5625 -73.1375 913.69375 -47.4375C930.825 -21.74375 939.95625 8.45625 939.93125 39.3375C939.9375 80.7937500000001 923.5375 120.5625 894.3125 149.9625000000001zM849.93125 -26.91875C834.6375 -42.225 814.5250000000001 -51.76875 792.9937500000001 -53.9312500000001C771.4625000000001 -56.09375 749.84375 -50.7437500000001 731.80625 -38.7875C716.275 -28.3062500000001 704.11875 -13.5375 696.80625 3.71875C689.86875 20.74375 688.13125 39.45 691.8125 57.4625C695.3375000000001 75.7125 704.25 92.4875 717.3937500000001 105.63125C730.5374999999999 118.775 747.3125 127.68125 765.5625 131.2125C783.575 134.8874999999999 802.28125 133.1500000000001 819.30625 126.2125C836.5625 118.9000000000001 851.325 106.74375 861.80625 91.2125C873.76875 73.1750000000001 879.11875 51.5625 876.95 30.03125C874.7875 8.5 865.24375 -11.625 849.93125 -26.91875z" /> @@ -261,13 +264,13 @@ horiz-adv-x="1000" d=" M93.75 -55H937.5V7.5H125V820H62.5V-23.75L93.75 -55zM187.5 101.25V601.25L218.75 632.5H343.75L375 601.25V101.25L343.75 70H218.75L187.5 101.25zM312.5 132.5V570H250V132.5H312.5zM687.5 726.25V101.25L718.75 70H843.75L875 101.25V726.25L843.75 757.5H718.75L687.5 726.25zM812.5 695V132.5H750V695H812.5zM437.5 101.25V476.25L468.75 507.5H593.75L625 476.25V101.25L593.75 70H468.75L437.5 101.25zM562.5 132.5V445H500V132.5H562.5z" /> + horiz-adv-x="1000" d=" M930 521.24625C924.95625 540.984375 917.175 559.9200000000001 906.875 577.498125C896.9875000000001 595.78375 884.3312500000001 612.439375 869.375 626.875625C847.6875 648.4918749999999 822 665.681875 793.75 677.4962499999999C736.8875 700.834375 673.1125 700.834375 616.249375 677.4962499999999C589.5475 666.19375 565.016875 650.3325 543.75125 630.6212499999999L540.6268749999999 626.875625L500.000625 586.24875L459.374375 626.875625L456.25 630.6212499999999C434.984375 650.3325 410.45375 666.19375 383.75125 677.4962499999999C326.88625 700.834375 263.115 700.834375 206.25 677.4962499999999C177.99875 665.681875 152.31625 648.4918749999999 130.6275 626.875625C115.656875 612.294375 102.82125 595.669375 92.50125 577.498125C82.66125 559.770625 75.100625 540.869375 70 521.24625C64.70125 500.845 62.1788125 479.821875 62.500625 458.74625C62.533125 438.9262500000001 65.0525 419.1925 70 400C75.24 380.6225 82.795 361.945 92.50125 344.374375C102.98375 326.31125 115.803125 309.7075 130.6275 294.996875L500.000625 -74.38125L869.375 294.996875C884.19375 309.556875 896.8249999999999 326.190625 906.875 344.374375C917.05625 361.78875 924.8375 380.500625 930 400C934.95 419.1925 937.46875 438.9262500000001 937.5 458.74625C937.825 479.821875 935.3 500.845 930 521.24625zM867.5 419.3712500000001C863.8249999999999 405.395 858.3625000000001 391.95 851.25 379.37C843.825 366.411875 834.8 354.445625 824.375 343.74875L498.749375 18.75L173.126875 343.74875C162.515625 354.435 153.2775 366.39875 145.626875 379.37C138.426875 392.2025 132.761875 405.8400000000001 128.750625 419.996875C125.548125 434.151875 123.8725 448.613125 123.75125 463.125625C123.83625 478.053125 125.51125 492.92625 128.750625 507.498125C132.644375 521.6956250000001 138.315 535.346875 145.626875 548.125C153.123125 561.2 162.37625 573.183125 173.126875 583.7462499999999C189.183125 599.5875 208.0425 612.301875 228.74875 621.245C270.475 637.936875 317.024375 637.936875 358.75 621.245C379.323125 612.676875 398.01125 600.15 413.750625 584.371875L498.749375 498.7475L583.7525 584.371875C599.49125 600.15 618.175625 612.676875 638.75 621.245C680.475 637.936875 727.025 637.936875 768.75 621.245C789.45625 612.301875 808.31875 599.5875 824.375 583.7462499999999C835.26875 573.46 844.35 561.42125 851.25 548.125C858.3625000000001 535.545 863.8249999999999 522.1 867.5 508.12375C871.2562499999999 493.84375 873.14375 479.141875 873.125 464.376875C873.98125 449.275625 872.71875 434.1225 869.375 419.3712500000001H867.5z" /> + horiz-adv-x="1000" d=" M522.499375 734.375L920 371.875625L875.625 327.500625L812.5 384.743125V-23.125L781.25 -54.375H593.750625L562.500625 -23.125V195.6237500000001H437.500625V-23.125L406.250625 -54.375H218.750625L187.500625 -23.125L187.5 384.27125L125.000625 327.500625L80.625625 371.875625L477.499375 734.375H478.124375H521.874375H522.499375zM250.000625 441.0425V8.125H375.000625V226.8737500000001L406.250625 258.1237500000001H593.750625L625 226.8737500000001V8.125H750V441.419375L499.999375 668.125L250.000625 441.0425z" /> @@ -300,16 +303,16 @@ horiz-adv-x="1000" d=" M250 320C250 307.63875 246.334375 295.555 239.466875 285.276875C232.599375 274.99875 222.838125 266.988125 211.4175 262.2575C199.9975 257.526875 187.430625 256.289375 175.306875 258.700625C163.183125 261.1125000000001 152.046875 267.0650000000001 143.305625 275.805625C134.565 284.546875 128.6125 295.683125 126.20125 307.806875C123.789375 319.930625 125.026875 332.4975 129.7575 343.9175C134.488125 355.338125 142.49875 365.099375 152.776875 371.966875C163.055 378.834375 175.13875 382.5 187.5 382.5C204.07625 382.5 219.973125 375.915 231.694375 364.1943750000001C243.415 352.473125 250 336.57625 250 320z M562.5 320C562.5 307.63875 558.834375 295.555 551.966875 285.276875C545.099375 274.99875 535.338125 266.988125 523.9175 262.2575C512.4975000000001 257.526875 499.930625 256.289375 487.806875 258.700625C475.683125 261.1125000000001 464.546875 267.0650000000001 455.805625 275.805625C447.065 284.546875 441.1125 295.683125 438.70125 307.806875C436.289375 319.930625 437.526875 332.4975 442.2575000000001 343.9175C446.9881250000001 355.338125 454.99875 365.099375 465.276875 371.966875C475.555 378.834375 487.63875 382.5 500 382.5C516.57625 382.5 532.473125 375.915 544.194375 364.1943750000001C555.9150000000001 352.473125 562.5 336.57625 562.5 320z M875 320C875 307.63875 871.3375 295.555 864.46875 285.276875C857.6 274.99875 847.8375 266.988125 836.41875 262.2575C825 257.526875 812.4312500000001 256.289375 800.30625 258.700625C788.1812500000001 261.1125000000001 777.04375 267.0650000000001 768.30625 275.805625C759.5625 284.546875 753.6125000000001 295.683125 751.1999999999999 307.806875C748.7875 319.930625 750.0250000000001 332.4975 754.75625 343.9175C759.4875 355.338125 767.5 365.099375 777.775 371.966875C788.05625 378.834375 800.1374999999999 382.5 812.5 382.5C829.075 382.5 844.975 375.915 856.69375 364.1943750000001C868.4125 352.473125 875 336.57625 875 320z" /> + horiz-adv-x="1000" d=" M465.276875 -44.46875C475.555 -51.3375 487.63875 -55 500 -55C516.575625 -55 532.473125 -48.4125 544.19375 -36.69375C555.9150000000001 -24.975 562.5 -9.075 562.5 7.5C562.5 19.8625000000001 558.834375 31.94375 551.966875 42.225C545.09875 52.5 535.338125 60.5125000000001 523.9175 65.24375C512.4968749999999 69.9749999999999 499.930625 71.2125 487.806875 68.8000000000001C475.683125 66.3874999999999 464.54625 60.4375 455.805625 51.69375C447.065 42.95625 441.1125 31.8187499999999 438.700625 19.69375C436.289375 7.5687499999999 437.526875 -5 442.2575000000001 -16.41875C446.9875 -27.8375 454.99875 -37.6 465.276875 -44.46875zM500 257.5C487.638125 257.5 475.554375 261.165625 465.276875 268.0331250000001C454.99875 274.900625 446.9875 284.661875 442.2575000000001 296.0825C437.526875 307.5025 436.289375 320.069375 438.700625 332.193125C441.1125 344.3168750000001 447.065 355.453125 455.805625 364.1943750000001C464.54625 372.935 475.683125 378.8875 487.806875 381.299375C499.930625 383.710625 512.4968749999999 382.4731250000001 523.9175 377.7425C535.338125 373.011875 545.09875 365.00125 551.966875 354.7231250000001C558.834375 344.445 562.5 332.36125 562.5 320C562.5 303.4237500000001 555.9150000000001 287.526875 544.19375 275.805625C532.473125 264.0849999999999 516.575625 257.5 500 257.5zM500 570C487.63875 570 475.555 573.665625 465.276875 580.533125C454.99875 587.400625 446.9881250000001 597.161875 442.2575000000001 608.5825C437.526875 620.0025 436.289375 632.569375 438.70125 644.693125C441.1125 656.816875 447.065 667.95375 455.805625 676.694375C464.546875 685.435 475.683125 691.3875 487.806875 693.7993749999999C499.930625 696.210625 512.4975000000001 694.973125 523.9175 690.2425000000001C535.338125 685.511875 545.099375 677.50125 551.966875 667.223125C558.834375 656.9449999999999 562.5 644.8612499999999 562.5 632.5C562.5 615.92375 555.9150000000001 600.026875 544.194375 588.305625C532.473125 576.585 516.57625 570 500 570z" /> + horiz-adv-x="1000" d=" M709.4375 751.80875C763.99375 740.700625 814.0625 713.745625 853.375 674.316875C886.6125000000001 640.80125 911.03125 599.564375 924.44375 554.306875C937.85625 509.04125 939.85625 461.166875 930.25 414.948125C916.3375 351.578125 881.33125 294.815625 830.9499999999999 253.9375C780.56875 213.066875 717.80625 190.50625 652.9375 189.94375C625.56875 189.8937500000001 598.339375 193.88125 572.124375 201.76L522.125 143.1937499999999L498.43625 132.25625H437.5V38.50625L406.25 7.25625H312.5V-86.49375L281.25 -117.74375H93.75L62.5 -86.49375V57.69375L71.625 79.75625L382.5 390.5725C373.67625 418.984375 369.4575 448.631875 369.99875 478.38625C370.765625 534.050625 387.931875 588.265 419.3575 634.224375C450.77875 680.18375 495.06375 715.859375 546.66125 736.77125C598.25875 757.6910625 654.88125 762.9171875 709.4375 751.80875zM791.83125 301.8350000000001C831.0875 333.6262500000001 858.38125 377.808125 869.25 427.1325L869.5 426.819375C877.21875 462.88375 875.80625 500.305625 865.39375 535.6912500000001C854.975 571.07625 835.89375 603.295 809.8625000000001 629.425625C783.8375 655.55625 751.69375 674.775 716.35625 685.33375C681.0125 695.893125 643.59375 697.456875 607.498125 689.88125C558.8 679.0699999999999 515.11375 652.283125 483.4025 613.77C451.686875 575.264375 433.7693750000001 527.253125 432.49875 477.379375C431.82375 448.9525000000001 436.905 420.678125 447.4375 394.2575L440.563125 360.3825L125 44.75625V-55.24375H250V38.50625L281.25 69.75625H375V163.50625L406.25 194.75625H484.0625L538.810625 258.255625L573.875625 267.00625C599.1475 257.134375 626.05 252.083125 653.1875 252.1368750000001C703.7 252.518125 752.58125 270.0431250000001 791.83125 301.8350000000001zM739.46875 472.535C746.33125 482.811875 750 494.896875 750 507.25625C750 523.835 743.41875 539.7268750000001 731.69375 551.453125C719.975 563.171875 704.075 569.75625 687.5 569.75625C675.1374999999999 569.75625 663.05625 566.094375 652.78125 559.22C642.5 552.35375 634.4875 542.595625 629.75625 531.174375C625.0250000000001 519.753125 623.7906250000001 507.1875 626.1999999999999 495.064375C628.6125000000001 482.94125 634.5625 471.8025 643.30625 463.059375C652.04375 454.32375 663.1812500000001 448.365 675.30625 445.95375C687.4312500000001 443.543125 700 444.786875 711.41875 449.516875C722.8375 454.246875 732.6 462.258125 739.46875 472.535z" /> + horiz-adv-x="1000" d=" M914.375 382.5L812.5 632.5H875V695H562.5V757.5H500V695H187.5V632.5H250L148.75 382.5H125V320H134.375C144.149375 288.880625 163.9225 261.8575 190.625 243.125C216.978125 224.015 248.6975 213.725 281.25 213.725C313.8025 213.725 345.521875 224.015 371.875 243.125C398.5850000000001 261.989375 418.52375 288.9400000000001 428.75 320H437.5V382.5H409.375L305 632.5H500V132.5H375L350.625 121.25L225.625 -35.625L250 -86.25H812.5L836.875 -35.625L711.875 121.25L687.5 132.5H562.5V632.5H758.125L653.75 382.5H625V320H634.375C644.5999999999999 289.035 664.325 262.0825000000001 690.75 242.9775C717.175 223.8725 748.95625 213.58875 781.5625 213.58875C814.16875 213.58875 845.9499999999999 223.8725 872.375 242.9775C898.8000000000001 262.0825000000001 918.525 289.035 928.75 320H937.5V382.5H914.375zM326.25 288.125C312.466875 280.4968750000001 297.0025 276.41625 281.25 276.25C265.68375 276.3318750000001 250.4012500000001 280.42125 236.875 288.125C223.081875 295.685625 211.46125 306.66125 203.125 320H359.375C351.109375 306.823125 339.734375 295.8781250000001 326.25 288.125zM341.875 382.5H216.875L279.375 532.5L341.875 382.5zM672.5 70L750 -23.75H312.5L390 70H672.5zM783.75 531.25L846.25 381.25H721.25L783.75 531.25zM826.25 286.875C812.5875 278.955625 797.04375 274.854375 781.25 275C765.64375 274.7781250000001 750.28125 278.88875 736.875 286.875C723.0625 294.9593749999999 711.46875 306.3400000000001 703.125 320H859.375C851.625 306.09375 840.15625 294.6225 826.25 286.875z" /> @@ -327,7 +330,7 @@ horiz-adv-x="1000" d=" M125.015 632.5H62.515V570H125.015V632.5zM125.015 445H62.515V382.5H125.015V445zM62.515 257.5H125.015V195H62.515V257.5zM125.015 70H62.515V7.5H125.015V70zM250.015 632.5H937.5125V570H250.015V632.5zM937.5125 445H250.015V382.5H937.5125V445zM250.015 257.5H937.5125V195H250.015V257.5zM937.5125 70H250.015V7.5H937.5125V70z" /> + horiz-adv-x="1000" d=" M677.04375 652.025625C630.3562499999999 698.714375 567.29375 725.344375 501.27125 726.25H498.77125C432.7487500000001 725.344375 369.685 698.714375 322.995625 652.025625C276.30625 605.3362500000001 249.676875 542.2725 248.77125 476.25C247.931875 429.3575 261.1212500000001 383.283125 286.64625 343.9375L483.361875 -55H516.680625L713.3937500000001 343.9375C738.9187499999999 383.283125 752.1125 429.3575 751.2687500000001 476.25C750.36875 542.2725 723.7375000000001 605.3362500000001 677.04375 652.025625zM495.27125 663.75L500.39625 663.125L505.02125 663.75C554.119375 661.611875 600.5325 640.745625 634.71875 605.441875C668.90625 570.138125 688.275 523.0787499999999 688.83125 473.9375C689.30625 439.0612500000001 679.125 404.8712500000001 659.64375 375.9375L658.39375 373.8125L657.3312500000001 371.625L500.02125 52.5625L342.70875 371.3125L341.64625 373.75L340.39625 375.875C320.9175 404.80875 310.734375 438.99875 311.20875 473.875C311.741875 523.073125 331.1287500000001 570.191875 365.374375 605.51875C399.62 640.8456249999999 446.1131250000001 661.688125 495.27125 663.75zM533.4875 528.2168750000001C523.209375 535.084375 511.125625 538.75 498.764375 538.75C482.188125 538.75 466.29125 532.165 454.57 520.444375C442.84875 508.723125 436.264375 492.82625 436.264375 476.25C436.264375 463.88875 439.929375 451.805 446.7975 441.526875C453.665 431.2487500000001 463.42625 423.2381250000001 474.84625 418.5075000000001C486.266875 413.776875 498.83375 412.539375 510.9575 414.950625C523.0812500000001 417.3625 534.2175 423.315 542.958125 432.055625C551.69875 440.796875 557.651875 451.933125 560.063125 464.056875C562.4749999999999 476.180625 561.2368749999999 488.7475 556.5068749999999 500.1675C551.77625 511.588125 543.7650000000001 521.349375 533.4875 528.2168750000001zM429.318125 580.18375C449.8737500000001 593.91875 474.04125 601.25 498.764375 601.25C531.91625 601.25 563.710625 588.080625 587.1524999999999 564.638125C610.594375 541.19625 623.76375 509.401875 623.76375 476.25C623.76375 451.5275 616.433125 427.36 602.698125 406.8037500000001C588.9625000000001 386.2475 569.4399999999999 370.22625 546.599375 360.765C523.7587500000001 351.304375 498.625625 348.82875 474.3775 353.651875C450.13 358.475 427.8575 370.38 410.375625 387.861875C392.8943750000001 405.3431250000001 380.989375 427.6162500000001 376.165625 451.86375C371.3425000000001 476.11125 373.818125 501.244375 383.279375 524.0856249999999C392.74 546.92625 408.761875 566.44875 429.318125 580.18375z" /> @@ -336,7 +339,7 @@ horiz-adv-x="1000" d=" M515.625 721.878125H483.75L62.5 472.503125V-23.74375L93.75 -54.99375H906.25L937.5 -23.74375V472.503125L515.625 721.878125zM500 658.753125L851.875 451.253125L766.25 351.878125H233.75L151.875 451.253125L500 658.753125zM875 7.50625H125V387.503125L194.375 301.253125L218.75 289.378125H781.25L805.625 301.253125L875 387.503125V7.50625z" /> + horiz-adv-x="1000" d=" M62.5 601.25L93.75 632.5H906.25L937.5 601.25V584.435V38.75L906.25 7.5H93.75L62.5 38.75V584.435V601.25zM125 536.568125V70H875V536.499375L519.375 263.74875H481.250625L125 536.568125zM814.375 570H185.625L500 328.1862500000001L814.375 570z" /> @@ -357,7 +360,7 @@ horiz-adv-x="1000" d=" M535.625 757.5L923.125 507.5L937.5 483.75V-91.25L890 -117.5L500 132.5L110 -117.5L62.5 -91.25V483.75L76.875 507.5L464.375 757.5H535.625zM531.875 186.875L875 -34.375V466.875L531.875 685.625V507.5H469.375V686.875L125 465.625V-34.375L469.375 188.125V186.875H531.875zM588.125 485.62375L632.5 529.37375L786.875 374.37375V329.99875L633.125 176.25L589.375 219.998125L688.75 319.9987500000001H559.375H442.5H313.75L412.5 219.998125L368.75 176.25L215 329.99875V374.37375L370 529.37375L413.75 485.62375L311.25 382.49875H442.5H559.375H691.25L588.125 485.62375z" /> + horiz-adv-x="1000" d=" M937.5 466.25L511.25 632.5H488.75L62.5 466.25V70H125V382.5L269.375 326.25C237.483125 280.83375 220.253125 226.745 220 171.25C219.3825 164.3874999999999 219.3825 157.4875000000001 220 150.625V143.75L237.5 118.75L486.25 7.5H511.8749999999999L758.125 120.625L775.625 145.625V153.125C775.625 159.375 775.625 166.25 775.625 173.125C775.26875 228.315 758.28125 282.1162500000001 726.875 327.5L937.5 409.375V466.25zM717.5 173.75V169.375L500 70L281.25 170C280.9575000000001 171.2312500000001 280.9575000000001 172.51875 281.25 173.75C281.5900000000001 221.9206250000001 298.0975000000001 268.581875 328.125 306.25L489.375 243.75H511.8749999999999L671.875 306.25C701.625 268.5125 717.7125 221.805 717.5 173.75zM500 304.375L157.5 437.5L500 570L842.5 436.25L500 304.375z" /> @@ -378,16 +381,16 @@ horiz-adv-x="1000" d=" M538.125 632.5L896.875 536.875L937.5 507.5V86.25L914.375 56.25L531.25 -49.375L147.5 56.25L125 86.25V507.5L163.125 536.875L521.25 632.5H538.125zM532.5 570L282.5 507.5L316.875 495L531.25 438.75L718.75 489.375L778.125 507.5L532.5 570zM187.5 110L500 24.375V382.5L187.5 466.25V110zM562.5 382.5V24.375L875 110V468.125L748.75 433.5325V273.124375L686.25 256.874375V416.4075L562.5 382.5z" /> + horiz-adv-x="1000" d=" M908.7875 81.80625L837.5375 276.8143750000001V280.560625L530.6625 587.4375V664.936875C530.555 677.334375 528.2275 689.60875 523.78875 701.184375C518.92625 712.565 511.8287500000001 722.85375 502.918125 731.4425C494.0075 740.03125 483.464375 746.7475 471.9125 751.1875C460.398125 755.779375 448.04875 757.907 435.66125 757.435625C423.433125 757.6960625 411.289375 755.35375 400.035625 750.561875C388.8125 745.943125 378.615 739.146875 370.0331250000001 730.565C361.45125 721.983125 354.655 711.7825 350.036875 700.55875C345.245 689.305625 342.9025 677.165 343.1625 664.936875V461.18625L151.9125 273.68625C134.655625 255.95125 125 232.1781249999999 125 207.433125C125 182.6875 134.655625 158.9250000000001 151.9125 141.1875L378.788125 -85.6875C387.53875 -94.5124999999999 397.945625 -101.5187500000001 409.4125 -106.3125C432.275625 -115.4875000000001 457.8 -115.4875000000001 480.663125 -106.3125C492.13 -101.5187500000001 502.536875 -94.5124999999999 511.2875 -85.6875L819.4125 221.8143749999999L778.1625 84.3125C776.29375 74.81875 776.29375 65.05625 778.1625 55.5625C780.1687499999999 46.05625 784.21875 37.09375 790.0374999999999 29.30625C796.09375 21.75 803.5124999999999 15.3937500000001 811.9125 10.5625C820.68125 6.1875 830.25 3.6375 840.0375 3.0625C850.35 2.4312500000001 860.65625 4.3625 870.0375 8.6875C879.36875 12.90625 887.6875 19.09375 894.4125 26.8125C901.2125 34.69375 905.9375 44.14375 908.1625 54.3125C910.125 63.3562500000001 910.3375 72.6875 908.7875 81.80625zM408.786875 664.936875C407.87 669.053125 407.87 673.3175 408.786875 677.43375C410.5456250000001 681.4449999999999 413.09625 685.061875 416.2862500000001 688.061875C419.674375 690.73875 423.473125 692.8475 427.53625 694.31C431.861875 695.239375 436.336875 695.239375 440.6625 694.31C448.248125 693.72375 455.36 690.389375 460.663125 684.93375C465.574375 679.19125 468.238125 671.8668749999999 468.1625 664.31125V585.560625L405.6625 523.0606250000001L408.786875 664.936875zM471.286875 -44.4375C468.64625 -47.6 465.18875 -49.975 461.2887500000001 -51.3125C457.548125 -52.9625 453.503125 -53.81875 449.4131250000001 -53.81875C445.32375 -53.81875 441.27875 -52.9625 437.538125 -51.3125C433.638125 -49.975 430.176875 -47.6 427.53625 -44.4375L200.660625 181.8125C197.81375 184.7312499999999 195.489375 188.1062499999999 193.786875 191.80625C192.15375 195.6637499999999 191.315 199.8125 191.315 203.999375C191.315 208.186875 192.15375 212.328125 193.786875 216.1837499999999C195.489375 219.885625 197.81375 223.27 200.660625 226.185625L472.538125 498.059375V319.935625C467.775625 315.57125 463.97875 310.2543750000001 461.395 304.33375C458.811875 298.4131250000001 457.499375 292.0175 457.53875 285.5575C456.77625 277.3318750000001 458.201875 269.053125 461.67 261.555625C465.138125 254.058125 470.525 247.60875 477.2875 242.86375C484.049375 238.11875 491.945 235.24375 500.175625 234.5325000000001C508.405625 233.8212500000001 516.6787499999999 235.2981249999999 524.154375 238.8125C531.630625 242.326875 538.0443750000001 247.753125 542.7475000000001 254.544375C547.450625 261.3356250000001 550.276875 269.2512500000001 550.9375 277.4856250000001C551.5981250000001 285.7206250000001 550.0693749999999 293.988125 546.50875 301.441875C542.948125 308.89625 537.4825 315.274375 530.6625 319.935625V496.808125L771.2875 254.933125L471.286875 -44.4375z" /> + horiz-adv-x="1000" d=" M500 695C512.36125 695 524.445 691.334375 534.723125 684.466875C545.000625 677.599375 553.011875 667.838125 557.7425000000001 656.4175C562.4725000000001 644.9975 563.710625 632.430625 561.2987499999999 620.306875C558.8874999999999 608.183125 552.9343749999999 597.046875 544.19375 588.305625C535.453125 579.565 524.316875 573.6125 512.193125 571.200625C500.06875 568.789375 487.5025 570.026875 476.081875 574.7574999999999C464.661875 579.488125 454.900625 587.49875 448.033125 597.776875C441.165 608.0550000000001 437.5 620.1387500000001 437.5 632.5C437.5 649.07625 444.084375 664.973125 455.805625 676.694375C467.526875 688.415 483.42375 695 500 695zM500 757.5C475.276875 757.5 451.109375 750.16875 430.5537500000001 736.43375C409.9975 722.69875 393.975625 703.17625 384.515 680.3356249999999C375.0537500000001 657.494375 372.578125 632.36125 377.401875 608.11375C382.225 583.86625 394.13 561.5931250000001 411.61125 544.111875C429.0931250000001 526.63 451.365625 514.7249999999999 475.613125 509.901875C499.86125 505.07875 524.994375 507.554375 547.8349999999999 517.015C570.675625 526.4762499999999 590.198125 542.4975 603.9331249999999 563.05375C617.66875 583.61 625 607.7775 625 632.5C625 665.651875 611.83 697.44625 588.3881250000001 720.888125C564.94625 744.330625 533.151875 757.5 500 757.5V757.5zM576.875 476.875H423.125C393.785 476.875 365.6475000000001 465.22 344.90125 444.47375C324.1550000000001 423.7275 312.5 395.589375 312.5 366.25V201.25C311.816875 183.88125 317.9862500000001 166.94375 329.6775 154.08125C341.36875 141.21875 357.64625 133.46875 375 132.5V-13.125C375 -33.0187500000001 382.90125 -52.09375 396.966875 -66.15625C411.031875 -80.225 430.10875 -88.125 450 -88.125H550C560.0625 -88.1312499999999 570.0243750000001 -86.1124999999999 579.290625 -82.1875C588.556875 -78.2624999999999 596.9387499999999 -72.5125 603.936875 -65.28125C610.934375 -58.0499999999999 616.405625 -49.4875 620.024375 -40.09375C623.6431249999999 -30.70625 625.3375 -20.6812500000001 625 -10.625V132.5C642.3562499999999 133.46875 658.63125 141.21875 670.3249999999999 154.08125C682.0125 166.94375 688.18125 183.88125 687.5 201.25V366.25C687.5 395.589375 675.84375 423.7275 655.1 444.47375C634.35 465.22 606.214375 476.875 576.875 476.875zM375 195V366.25C374.915625 372.5931250000001 376.103125 378.88875 378.491875 384.765625C380.880625 390.6425 384.4225 395.98125 388.908125 400.466875C393.39375 404.9525 398.7325 408.494375 404.609375 410.883125C410.4856250000001 413.271875 416.781875 414.45875 423.125 414.375H576.875C583.218125 414.45875 589.51375 413.271875 595.390625 410.883125C601.266875 408.494375 606.605625 404.9525 611.09125 400.466875C615.576875 395.98125 619.1187500000001 390.6425 621.5074999999999 384.765625C623.89625 378.88875 625.0812500000001 372.5931250000001 625 366.25V195H562.5V-11.875C562.5 -15.1875 561.1825 -18.36875 558.83875 -20.7125C556.494375 -23.05625 553.315 -24.375 550 -24.375H450C446.6843750000001 -24.375 443.505 -23.05625 441.160625 -20.7125C438.816875 -18.36875 437.5 -15.1875 437.5 -11.875V195H375z" /> + horiz-adv-x="1000" d=" M615.001875 757.5L558.124375 735.000625V601.25L344.375625 446.876875C312.088125 462.23125 276.160625 468.293125 240.62375 464.37875C205.404375 460.41 172.033125 446.54 144.375 424.3775V378.74625L321.87625 206.253125L60.001375 -55H154.99875L369.99875 159.99375L525.623125 8.125H573.1237500000001C595.60375 34.58125 609.7418749999999 67.1 613.746875 101.5875C617.75125 136.06875 611.44625 170.96875 595.626875 201.874375L755 409.378125H892.5L915.625 464.37875L615.001875 757.5zM740 474.373125L713.125 461.250625L533.74875 226.875625L529.99875 195C547.994375 160.61875 553.0962499999999 120.9375 544.37625 83.125L419.3762500000001 208.1225000000001L371.875625 254.371875L224.99875 397.499375C263.8625 405.660625 304.34125 400.6025 340 383.125625L373.1268750000001 386.8718750000001L614.3762499999999 561.249375L627.5 586.87625V658.7525L815 476.25L740 474.373125z" /> @@ -417,7 +420,7 @@ horiz-adv-x="1000" d=" M447.5 601.248125C295.625 503.748125 221.875 403.123125 221.875 234.998125C231.875 238.1231250000001 240.625 238.1231250000001 249.375 238.1231250000001C328.75 238.1231250000001 405.625 184.375 405.625 87.5C405.625 -13.125 341.25 -75.625 249.375 -75.625C130.625 -75.625 62.5 19.375 62.5 190C62.5 427.498125 171.875 598.123125 376.25 716.248125L447.5 601.248125zM885 601.248125C733.125 503.748125 659.375 403.123125 659.375 234.998125C669.375 238.1231250000001 678.125 238.1231250000001 686.875 238.1231250000001C766.25 238.1231250000001 843.125 184.375 843.125 87.5C843.125 -13.125 778.75 -75.625 686.875 -75.625C568.75 -75.625 500.625 19.375 500.625 190C500.625 427.498125 610 598.123125 814.375 716.248125L885.625 601.248125H885z" /> + horiz-adv-x="1000" d=" M187.400625 471.2525C188.040625 562.236875 224.4025 649.326875 288.650625 713.753125L244.274375 757.5C206.480625 720.0231249999999 176.485 675.435 156.01375 626.3050000000001C135.541875 577.174375 125 524.4775 125 471.2525C125 418.0281250000001 135.541875 365.330625 156.01375 316.200625C176.485 267.07 206.480625 222.4825 244.274375 185.00625L288.650625 228.7525C224.4025 293.178125 188.040625 380.26875 187.400625 471.2525zM253.649375 471.2525C253.488125 434.3950000000001 260.705625 397.88 274.874375 363.8537500000001C289.0431250000001 329.8275 309.876875 298.9756250000001 336.15 273.125L380.52625 317.505C359.984375 337.270625 343.8037500000001 361.114375 333.025625 387.505C321.87125 414.0168750000001 316.1325 442.49 316.149375 471.2525C316.061875 499.820625 321.805 528.103125 333.025625 554.375C343.643125 581.03375 359.83875 605.114375 380.52625 625L336.15 669.380625C309.989375 643.445625 289.229375 612.5825 275.06875 578.575625C260.908125 544.5687499999999 253.6275 508.09 253.649375 471.2525zM731.775 270.63L687.4 315.0025C708.0125 334.9500000000001 724.1999999999999 359.01375 734.9 385.628125C746.05625 412.14 751.79375 440.613125 751.775 469.375625C751.8625 497.94375 746.125 526.23375 734.9 552.505625C724.28125 579.1643750000001 708.0875 603.245 687.4 623.13125L731.775 666.878125C757.8937500000001 640.915 778.61875 610.044375 792.75625 576.0425C806.9 542.040625 814.18125 505.575625 814.18125 468.75C814.18125 431.925 806.9 395.4675000000001 792.75625 361.465625C778.61875 327.46375 757.8937500000001 296.59375 731.775 270.63zM816.775 757.5L772.4 713.1275C804.4875000000001 681.54625 829.975 643.896875 847.36875 602.37125C864.7625 560.8456249999999 873.71875 516.274375 873.71875 471.2525C873.71875 426.23125 864.7625 381.659375 847.36875 340.13375C829.975 298.6081250000001 804.4875000000001 260.95875 772.4 229.3781250000001L816.775 185.00625C854.56875 222.4825 884.56875 267.07 905.04375 316.200625C925.5125 365.330625 936.05 418.0281250000001 936.05 471.2525C936.05 524.4775 925.5125 577.174375 905.04375 626.3050000000001C884.56875 675.435 854.56875 720.0231249999999 816.775 757.5zM624.54625 480.60625C626.6875 459.044375 621.2893750000001 437.413125 609.275625 419.380625C604.0875 414.09875 598.439375 409.281875 592.399375 404.999375L807.4 -78.125L749.9 -103.11875L701.7750000000001 5.00625H355.52625L307.4000000000001 -103.11875L249.900625 -78.125L464.90125 404.999375C451.840625 418.1925 442.9337500000001 434.924375 439.2775 453.125625C435.60125 471.1425 437.3381250000001 489.844375 444.275 506.874375C451.585625 524.128125 463.743125 538.894375 479.275 549.378125C497.306875 561.391875 518.9462500000001 566.79 540.508125 564.651875C562.0706250000001 562.51375 582.224375 552.973125 597.545625 537.65125C612.866875 522.3299999999999 622.4075 502.16875 624.54625 480.60625zM524.9025 501.8775C518.9775 500.48125 513.56375 497.44875 509.2775 493.12625C505.91875 489.15875 503.55875 484.445 502.399375 479.378125C500.530625 473.48125 500.530625 467.148125 502.399375 461.250625C504.861875 455.578125 508.7343749999999 450.630625 513.64875 446.876875C518.9143750000001 443.639375 524.97 441.9125 531.150625 441.8793750000001C539.38875 442.039375 547.24375 445.384375 553.0699999999999 451.2106250000001C558.89625 457.036875 562.240625 464.891875 562.400625 473.129375C562.368125 479.310625 560.6375 485.36625 557.4 490.63125C553.64625 495.54625 548.69875 499.415 543.02625 501.8775C537.1287500000001 503.74625 530.7993749999999 503.74625 524.9025 501.8775zM539.27625 373.749375H522.4L468.025 252.503125H593.025L539.27625 373.749375zM676.775 65L621.15125 190H441.150625L385.5250000000001 65H676.775z" /> @@ -429,16 +432,16 @@ horiz-adv-x="1000" d=" M812.5 195H249.998125V695H499.998125V757.5H233.7475C219.413125 757.34125 205.226875 754.588125 191.87375 749.375C178.3075 743.470625 166.16 734.731875 156.248125 723.7475C146.12 713.150625 138.2525 700.606875 133.12375 686.875C127.9825 674.5899999999999 125.225 661.44 124.998125 648.125V54.375C124.848125 40.0125 127.6125 25.7624999999999 133.12375 12.5C144.080625 -14.2874999999999 165.20625 -35.6375 191.87375 -46.875C205.226875 -52.0875 219.413125 -54.84375 233.7475 -55H249.998125V7.5H233.7475C227.51125 7.48125 221.340625 8.7625 215.62375 11.25625C204.455625 16.1625 195.53375 25.08125 190.6225 36.25C189.674375 42.25 189.674375 48.36875 190.6225 54.375V85.625C189.674375 91.63125 189.674375 97.75 190.6225 103.75C195.53375 114.9187500000001 204.455625 123.8375 215.62375 128.74375C221.340625 131.2375 227.51125 132.51875 233.7475 132.5H812.5V7.5H562.498125V-55H843.75L875 -23.75V257.5H812.5V195zM375 632.5H312.5V570H375V632.5zM312.5 507.5H375V445H312.5V507.5zM312.5 382.5H375V320H312.5V382.5zM330 -117.5H312.5V70H500V-117.5H482.5L406.25 -23.125L330 -117.5zM625 757.5H906.25L937.5 726.25V351.25L906.25 320H750V257.5H687.5V320H625C608.42375 320 592.5275 326.5818750000001 580.806875 338.303125C569.085625 350.02375 562.5 365.92375 562.5 382.5V695C562.5 711.57625 569.085625 727.4762499999999 580.806875 739.196875C592.5275 750.918125 608.42375 757.5 625 757.5zM656.25 382.5H687.5V445H656.25C647.9625 445 640.0124999999999 441.705 634.15 435.845C628.2937499999999 429.984375 625 422.038125 625 413.75C625 405.461875 628.2937499999999 397.515625 634.15 391.6550000000001C640.0124999999999 385.795 647.9625 382.5 656.25 382.5zM750 382.5H875V445H750V382.5zM687.5 507.5H875V695H687.5V507.5z" /> + horiz-adv-x="1000" d=" M233.75125 757.5H843.75L875 726.25V-23.75L843.75 -55H625V7.5H812.5V132.5H625V195H812.5V695H250.001875V195H437.501875V132.5H250.001875H233.75125C227.625 132.5 221.559375 131.2875 215.90625 128.9187500000001C212.781875 127.6187500000001 209.818125 125.96875 207.06375 124.025C204.839375 122.4500000000001 202.749375 120.68125 200.826875 118.7375C196.52375 114.375 193.12875 109.2000000000001 190.84 103.5187500000001C188.555 97.83125 187.418125 91.75 187.501875 85.625V54.375C187.418125 48.25 188.555 42.16875 190.84 36.4812499999999C193.12875 30.8 196.52375 25.625 200.826875 21.2625C205.129375 16.90625 210.25625 13.44375 215.90625 11.08125C218.446875 10.0187500000001 221.07125 9.1875 223.749375 8.59375C225.49625 8.2 227.26625 7.91875 229.0475 7.7375C230.608125 7.575 232.179375 7.5 233.75125 7.5H437.501875V-55H233.75125C219.419375 -55 205.225 -52.16875 191.991875 -46.6625C178.755 -41.1625 166.73875 -33.0875 156.633125 -22.9250000000001C146.524375 -12.7624999999999 138.52875 -0.6999999999999 133.100625 12.5687499999999C127.671875 25.8312500000001 124.918125 40.0375 125.001875 54.375V648.125C124.918125 662.4606249999999 127.671875 676.666875 133.100625 689.934375C138.52875 703.201875 146.524375 715.26375 156.633125 725.42625C166.73875 735.588125 178.755 743.66 191.991875 749.16125C205.225 754.669375 219.419375 757.5 233.75125 757.5zM333.7537500000001 455.6275L378.12625 411.873125L500.001875 533.745V443.123125L336.251875 279.37375L380.6287500000001 235.6262500000001L500.6275 355.6293750000001V-117.5H563.1275V361.984375L690 235.6262500000001L733.75 279.37375L562.501875 451.233125V536.369375L687.5 411.873125L731.25 455.6275L555.0018749999999 632.5H510.625625L333.7537500000001 455.6275z" /> + horiz-adv-x="1000" d=" M875 570.0025C875.04375 593.474375 868.4812499999999 616.485 856.0625 636.40125C843.6437500000001 656.316875 825.8625000000001 672.333125 804.7625 682.6168749999999C783.6625 692.9 760.09375 697.035 736.75625 694.548125C713.41875 692.06125 691.25 683.05375 672.7875 668.5550000000001C654.3312500000001 654.056875 640.325 634.654375 632.38125 612.56875C624.435 590.4825 622.8675000000001 566.605625 627.85625 543.670625C632.85 520.735625 644.2 499.669375 660.6062499999999 482.8825C677.0125 466.09625 697.8125 454.268125 720.625 448.7525V382.5025C720.7249999999999 376.786875 719.1875 371.1625 716.1999999999999 366.290625C713.2125 361.41875 708.8875 357.5025 703.75 355.0025L530.625 265.0025L358.125 352.5025C352.63 355.2362500000001 348.083125 359.558125 345.07375 364.9075C342.065 370.256875 340.7325 376.386875 341.25 382.5025V448.7525C370.708125 456.358125 396.380625 474.446875 413.45625 499.6275C430.53125 524.808125 437.836875 555.3518750000001 434.0037500000001 585.53375C430.17 615.715 415.460625 643.4625 392.6318750000001 663.575C369.80375 683.686875 340.4237500000001 694.783125 310 694.783125C279.575625 694.783125 250.195625 683.686875 227.3675 663.575C204.539375 643.4625 189.829375 615.715 185.99625 585.53375C182.1625 555.3518750000001 189.468125 524.808125 206.54375 499.6275C223.61875 474.446875 249.291875 456.358125 278.75 448.7525V382.5025C278.785625 365.184375 283.58625 348.209375 292.625625 333.4375C301.665625 318.665625 314.5950000000001 306.66625 330 298.7525000000001L500 211.2525000000001V128.75C470.541875 121.1437500000001 444.86875 103.05625 427.79375 77.875C410.718125 52.69375 403.4125 22.1500000000001 407.24625 -8.03125C411.0793750000001 -38.2125000000001 425.789375 -65.9562499999999 448.6175 -86.06875C471.445625 -106.18125 500.8256250000001 -117.28125 531.25 -117.28125C561.6737499999999 -117.28125 591.05375 -106.18125 613.881875 -86.06875C636.7125 -65.9562499999999 651.41875 -38.2125000000001 655.25625 -8.03125C659.0875000000001 22.1500000000001 651.78125 52.69375 634.7062500000001 77.875C617.630625 103.05625 591.958125 121.1437500000001 562.5 128.75V211.2525000000001L731.25 296.2525C747.13125 304.2368750000001 760.4 316.601875 769.48125 331.885625C778.5625 347.169375 783.08125 364.7337500000001 782.5 382.5025V450.0025C808.93125 457.118125 832.29375 472.7125 849 494.390625C865.7125 516.06875 874.84375 542.631875 875 570.0025zM250 570.0025C250 582.36375 253.665625 594.4475 260.533125 604.725625C267.400625 615.00375 277.161875 623.014375 288.581875 627.745C300.0025 632.475 312.569375 633.713125 324.693125 631.30125C336.8168750000001 628.89 347.953125 622.9375 356.69375 614.19625C365.435 605.455625 371.3875 594.319375 373.7987500000001 582.195625C376.210625 570.071875 374.9725 557.505 370.2425 546.084375C365.511875 534.6643750000001 357.50125 524.903125 347.2231250000001 518.035625C336.945 511.168125 324.86125 507.5025 312.5 507.5025C295.92375 507.5025 280.026875 514.086875 268.305625 525.808125C256.584375 537.5293750000001 250 553.42625 250 570.0025zM591.875 7.5C591.875 -4.8562499999999 588.209375 -16.94375 581.341875 -27.21875C574.47375 -37.5 564.713125 -45.5125 553.2925 -50.2375C541.871875 -54.96875 529.305625 -56.20625 517.181875 -53.79375C505.0575000000001 -51.3874999999999 493.92125 -45.43125 485.180625 -36.69375C476.44 -27.9499999999999 470.4875 -16.8125 468.075625 -4.69375C465.664375 7.4312500000001 466.901875 20 471.6325 31.41875C476.3625 42.8375 484.37375 52.6 494.651875 59.46875C504.93 66.3375 517.013125 70 529.375 70C537.5825 70 545.709375 68.3874999999999 553.2925 65.24375C560.875625 62.1062499999999 567.765 57.5 573.5687499999999 51.69375C579.3725 45.89375 583.9762499999999 39 587.1175 31.41875C590.258125 23.8375 591.875 15.7125 591.875 7.5zM750 507.5025C737.6374999999999 507.5025 725.55625 511.168125 715.275 518.035625C705 524.903125 696.9875 534.6643750000001 692.25625 546.084375C687.5250000000001 557.505 686.2875 570.071875 688.6999999999999 582.195625C691.1125000000001 594.319375 697.0625 605.455625 705.80625 614.19625C714.54375 622.9375 725.6812500000001 628.89 737.80625 631.30125C749.9312500000001 633.713125 762.5 632.475 773.91875 627.745C785.3375 623.014375 795.1 615.00375 801.96875 604.725625C808.83125 594.4475 812.5 582.36375 812.5 570.0025C812.5 553.42625 805.9125 537.5293750000001 794.19375 525.808125C782.475 514.086875 766.575 507.5025 750 507.5025z" /> + horiz-adv-x="1000" d=" M843.75 757.5H233.75C219.415625 757.50025 205.223125 754.666875 191.988125 749.1625C178.753125 743.658125 166.736875 735.591875 156.63 725.4275C146.52375 715.2625 138.52625 703.2 133.098125 689.93375C127.669375 676.6675 124.9175 662.45875 125 648.125V54.375C124.9175 40.0437499999999 127.669375 25.8312500000001 133.098125 12.5687499999999C138.52625 -0.6999999999999 146.52375 -12.7624999999999 156.63 -22.9250000000001C166.736875 -33.09375 178.753125 -41.15625 191.988125 -46.6625C205.223125 -52.16875 219.415625 -55 233.75 -55H437.5V7.5H233.75C227.623125 7.5 221.5575 8.71875 215.905 11.08125C210.2525 13.44375 205.12625 16.90625 200.823125 21.26875C196.52 25.625 193.126875 30.8 190.839375 36.4812499999999C188.5525 42.16875 187.416875 48.25 187.5 54.375V85.625C187.416875 91.75 188.5525 97.83125 190.839375 103.5187500000001C193.126875 109.2000000000001 196.52 114.375 200.823125 118.7312500000001C205.12625 123.09375 210.2525 126.55625 215.905 128.9187500000001C221.555 131.28125 227.618125 132.5 233.741875 132.5C233.744375 132.5 233.7475 132.5 233.75 132.5H250H437.5V195H250V695H812.5V195H625V132.5H812.5V7.5H625V-55H843.75L875 -23.75V726.25L843.75 757.5zM187.5 649.38375C187.494375 648.964375 187.494375 648.5450000000001 187.5 648.125V184.375L187.5 649.38375zM375 632.5H312.5V570H375V632.5zM336.25 279.378125L380.625 235.6281250000001L500.625625 355.62875V-117.5H563.125625V361.99125L690 235.6281250000001L733.75 279.378125L557.5 456.253125H513.125L336.25 279.378125zM312.5 507.5H375V445H312.5V507.5z" /> @@ -450,7 +453,7 @@ horiz-adv-x="1000" d=" M906.25 757.5H93.75L62.5 726.25V101.25L93.75 70H250V-86.25L303.375 -108.375L481.6875 70H906.25L937.5 101.25V726.25L906.25 757.5zM875 132.5H468.75L446.625 123.375L312.5 -10.8125V101.25L281.25 132.5H125V695H875V132.5zM625 195H375V258.8425H625V195zM468.75 632.5H531.25V507.5H656.25V445H531.25V320H468.75V445H343.75V507.5H468.75V632.5z" /> + horiz-adv-x="1000" d=" M905.6875 757.5C680.7875 757.21875 489.8325 633.581875 353.521875 507.5H93.75L62.5 476.25V288.75L71.6875 266.625L133.6225 204.69L133.686875 204.125L383.686875 -45.875L384.25 -45.9375L446.6875 -108.375L468.75 -117.5H656.25L687.5 -86.25V173.375C813.6875 309.475625 937.25 500.436875 937 726.25L905.6875 757.5zM125 445H290.191875C224.529375 375.9993750000001 176.98125 312.5025 151.151875 275.56625L125 301.6875V445zM481.25 -55L455.030625 -28.5374999999999C492.038125 -2.84375 555.621875 44.46875 624.6875 109.93125V-55H481.25zM409.811875 16.5L195.999375 230.1875C257.999375 320 523.686875 672.8125 873.625 694C853.25 343.25 499.436875 78.1875 409.811875 16.5zM250 -117.5V-55H125V70H62.5V-117.5H250zM671.71875 361.6975C682.0125 377.1075 687.5 395.220625 687.5 413.7493750000001C687.5 426.0875 685.0625 438.30375 680.3312500000001 449.698125C675.6 461.093125 668.66875 471.441875 659.93125 480.15125C651.19375 488.86125 640.81875 495.76 629.4125 500.453125C618 505.14625 605.775 507.540625 593.4375 507.499375C574.9087499999999 507.4375 556.8143749999999 501.886875 541.438125 491.548125C526.0625 481.209375 514.0949999999999 466.54625 507.046875 449.4100000000001C499.999375 432.274375 498.186875 413.43375 501.839375 395.26875C505.4925 377.10375 514.4456250000001 360.4287500000001 527.569375 347.34875C540.6925 334.26875 557.3981249999999 325.370625 575.5749999999999 321.77875C593.751875 318.1862500000001 612.58625 320.0612500000001 629.7 327.16625C646.8125 334.270625 661.43125 346.286875 671.71875 361.6975z" /> @@ -486,7 +489,7 @@ horiz-adv-x="1000" d=" M256.938125 683.769375C328.885 731.8425 413.4700000000001 757.5 499.999375 757.5C616.031875 757.5 727.3125 711.40375 809.3625 629.356875C891.40625 547.309375 937.5 436.0325 937.5 320C937.5 233.470625 911.84375 148.88125 863.76875 76.9375C815.69375 4.9875 747.3625000000001 -51.0812500000001 667.4250000000001 -84.2C587.48 -117.3125 499.5125 -125.975 414.645625 -109.09375C329.77875 -92.2125 251.824375 -50.5437499999999 190.63875 10.64375C129.45375 71.83125 87.788125 149.78125 70.906875 234.65C54.026 319.516875 62.688125 407.484375 95.801875 487.426875C128.915 567.37 184.991875 635.69625 256.938125 683.769375zM291.66 8.2C353.328125 -33.0062499999999 425.83125 -55 499.999375 -55C599.455625 -55 694.8375 -15.4937500000001 765.1625 54.8312500000001C835.4875000000001 125.15625 875 220.5437499999999 875 320C875 394.168125 853.0062499999999 466.6675 811.8 528.335625C770.59375 590.004375 712.025 638.075625 643.5062499999999 666.458125C574.9825 694.84125 499.58375 702.2675 426.84125 687.798125C354.098125 673.328125 287.280625 637.611875 234.83625 585.1675C182.39125 532.7225 146.675 465.90125 132.205625 393.1581250000001C117.73625 320.415625 125.161875 245.013125 153.545 176.4937500000001C181.9275 107.96875 229.99125 49.40625 291.66 8.2zM406.25 382.5C406.25 347.9825 378.2675 320 343.75 320C309.2325 320 281.25 347.9825 281.25 382.5C281.25 417.0175 309.2325 445 343.75 445C378.2675 445 406.25 417.0175 406.25 382.5zM718.75 382.5C718.75 347.9825 690.7687500000001 320 656.25 320C621.7318750000001 320 593.75 347.9825 593.75 382.5C593.75 417.0175 621.7318750000001 445 656.25 445C690.7687500000001 445 718.75 417.0175 718.75 382.5zM500 132.5C466.038125 132.4187499999999 432.689375 141.55625 403.51875 158.9499999999999C374.348125 176.34375 350.44875 201.3306250000001 334.3737500000001 231.2475L279.9987500000001 201.24875C301.883125 160.75 334.5250000000001 127.08125 374.3250000000001 103.9500000000001C414.124375 80.81875 459.536875 69.13125 505.558125 70.1687500000001C551.57875 71.1999999999999 596.423125 84.9187499999999 635.14375 109.8125C673.8625000000001 134.70625 704.95625 169.8125 725 211.250625L668.75 238.1212500000001C653.375 206.4475000000001 629.39375 179.74375 599.551875 161.0625C569.70875 142.3875000000001 535.2075 132.4875000000001 500 132.5z" /> + horiz-adv-x="1000" d=" M347.380625 654.87375C344.81 655.121875 342.2362500000001 655.3275 339.659375 655.489375C338.5925000000001 659.740625 337.220625 663.919375 335.549375 667.993125C330.93 679.253125 324.12 689.483125 315.51375 698.089375C306.908125 706.6949999999999 296.6775 713.505625 285.4175 718.125C274.1575 722.74375 262.091875 725.08 249.92125 724.996875V643.288125C202.60875 624.485 160.730625 594.176875 128.08125 555.10625C95.3475 515.935 72.929375 469.199375 62.866875 419.153125V394.788125C91.5475 342.4875 181.98875 324.104375 197.481875 320.955625C199.2 320.60625 199.99625 320.444375 199.684375 320.444375C48.4976875 300.4525 62.866875 179.88125 62.866875 179.88125C63.975625 164.08125 71.04375 149.2874999999999 82.641875 138.50625C94.24 127.71875 109.501875 121.7375 125.340625 121.775C142.28125 122.90625 158.938125 126.6999999999999 174.695 133.025H303.390625C292.2356250000001 113.6999999999999 284.619375 92.5437499999999 280.9 70.5500000000001H260.90875C223.106875 64.85 188.61375 45.75 163.725625 16.7375C138.8375 -12.28125 125.21375 -49.28125 125.340625 -87.5125C124.815 -91.10625 125.04125 -94.7687500000001 126.005 -98.2687499999999C126.968125 -101.7687500000001 128.64875 -105.03125 130.93875 -107.8499999999999C133.229375 -110.66875 136.079375 -112.9812499999999 139.31 -114.6437499999999C142.54 -116.30625 146.08 -117.275 149.705 -117.5H567.0300000000001C600.978125 -119.2312499999999 634.9 -113.575 666.4499999999999 -100.9249999999999C698 -88.2750000000001 726.425 -68.9249999999999 749.76875 -44.2125000000001C773.1125 -19.50625 790.81875 9.975 801.65625 42.19375C812.49375 74.4125 816.2125 108.6 812.55 142.3937500000001C810.875 189.725 794.49375 235.3631250000001 765.7 272.964375L758.8249999999999 281.7106250000001C731.9625 316.07125 716.34375 338.561875 724.4625 362.301875C732.5875 386.041875 747.25 387.2912500000001 747.25 387.2912500000001C747.25 387.2912500000001 758.8249999999999 389.1656250000001 775.6937499999999 381.66875C789.4625 373.6675 804.44375 367.9700000000001 820.05 364.800625C834.7 362.03125 849.7875 362.6162500000001 864.1750000000001 366.51125C878.56875 370.406875 891.8875 377.51125 903.1375 387.2912500000001C913.95 396.693125 922.6125 408.30875 928.5375 421.35125C934.46875 434.39375 937.525 448.558125 937.5 462.884375C937.86875 507.773125 916.84375 553.790625 892.19375 593.35625C867.5500000000001 632.92125 834.35625 666.46875 795.0625 691.5387499999999C744.56875 718.51375 686.34375 727.335625 630.13125 716.528125C590.3362500000001 709.524375 553.8 690.053125 525.7975 660.926875C503.459375 636.565625 486.815 607.544375 477.068125 575.9625C465.615 592.9762499999999 452.285625 608.62875 437.3425000000001 622.629375V632.5375C437.511875 656.680625 428.166875 679.919375 411.33 697.22375C394.493125 714.52875 371.519375 724.506875 347.380625 724.99875V654.87375zM678.86875 108.6999999999999C685.83125 62.3499999999999 692.5812500000001 -5.14375 624.703125 -43.9187499999999C606.1775 -50.4 586.7168750000001 -53.95 567.0300000000001 -54.4H200.93375C200.883125 -38.6625 206.775 -23.4812499999999 217.430625 -11.9C228.086875 -0.31875 242.721875 6.81875 258.41 8.075H338.37625V39.3125C338.044375 54 340.609375 68.6062500000001 345.925 82.3C351.24 95.9937500000001 359.2018750000001 108.5124999999999 369.354375 119.125C379.5075 129.74375 391.6525000000001 138.25625 405.09625 144.175C416.70375 149.2937500000001 429.083125 152.3874999999999 441.7018750000001 153.34375L402.589375 208.8406250000001C387.825625 204.641875 373.628125 199.265625 366.489375 194.25H165.94875C160.558125 194.25 154.975 192.0375 149.42625 189.8375000000001C140.8275 186.4375 132.31 183.0625 124.715625 188C112.22125 196.1212499999999 131.588125 257.970625 187.814375 257.970625H250.288125C280.9 257.970625 285.898125 291.70625 285.898125 291.70625L303.390625 362.301875C271.244375 357.686875 238.4675 360.52625 207.594375 370.6006250000001C176.720625 380.675 148.5775 397.715 125.340625 420.4025000000001C135.285 465.783125 159.875625 506.635 195.32375 536.6643750000001C230.771875 566.693125 275.11 584.23375 321.508125 586.5825C323.320625 586.518125 325.058125 586.465 326.738125 586.4143750000001C343.02 585.92 353.91875 585.589375 375.2356250000001 575.9625C433.33625 549.723125 509.554375 421.651875 509.554375 421.651875L513.303125 416.029375H523.923125V420.4025000000001C520.18 448.078125 522.66875 511.850625 531.2075000000001 538.440625C539.7468749999999 565.03125 554.120625 589.3768749999999 573.2775 609.698125C595.2937499999999 631.705 623.735 646.144375 654.49375 650.930625C694.1374999999999 659.375625 735.50625 652.92625 770.6937499999999 632.813125C799.48125 615.063125 823.8375 590.9825 841.91875 562.4025C859.99375 533.823125 871.6625 510.136875 875.36875 476.523125C875.3 475.295625 875.3874999999999 473.545625 875.49375 471.433125C875.94375 462.50125 876.71875 447.085 867.49375 437.270625C859.56875 428.83625 839.50625 422.85125 825.6750000000001 426.025C815.775 428.2956250000001 806.29375 432.089375 797.55625 437.270625C787.04375 443.854375 775.19375 448.0012500000001 762.86875 449.40625C750.5437499999999 450.811875 738.0625 449.44 726.3375 445.391875C712.06875 440.79 699.1937499999999 432.64625 688.925 421.72125C678.65625 410.795625 671.3249999999999 397.445625 667.6125000000001 382.918125C661.34375 358.138125 661.74375 332.1418750000001 668.7687500000001 307.5650000000001C675.7875 282.988125 689.18125 260.705625 707.59375 242.9768750000001L714.46875 234.2306249999999C736.09375 207.145625 748.5625 173.89375 750.0812500000001 139.26875C750.9125 114.5 746.8249999999999 89.8125 738.05 66.63125C735.9312500000001 61.0375 733.5500000000001 55.55625 730.9187499999999 50.2125000000001C730.5 55.1999999999999 729.8625 60.1875 729 65.15C724.825 89.11875 715.54375 111.8125 701.9 131.7375L678.86875 108.6999999999999zM265 507.5C256.711875 507.5 248.763125 504.2075 242.903125 498.346875C237.0425 492.486875 233.75 484.538125 233.75 476.25C233.75 467.961875 237.0425 460.013125 242.903125 454.153125C248.763125 448.2925 256.711875 445 265 445C273.288125 445 281.236875 448.2925 287.096875 454.153125C292.9575 460.013125 296.25 467.961875 296.25 476.25C296.25 484.538125 292.9575 492.486875 287.096875 498.346875C281.236875 504.2075 273.288125 507.5 265 507.5z" /> @@ -516,10 +519,10 @@ horiz-adv-x="1000" d=" M875 507.5H125V632.5H875V507.5zM875 257.5H125V382.5H875V257.5zM125 7.5H875V132.5H125V7.5z" /> + horiz-adv-x="1000" d=" M341.25 -61.875C323.20125 -61.7874999999999 305.58375 -56.3499999999999 290.625 -46.25C274.4575000000001 -34.6 262.821875 -17.71875 257.694375 1.5375C252.5675 20.79375 254.265625 41.23125 262.5 59.375L323.125 195H148.75C134.4325 194.7312499999999 120.279375 198.088125 107.605 204.7531250000001C94.93 211.4181249999999 84.145 221.1775 76.25 233.125C68.31125 245.2375000000001 63.623125 259.19 62.638125 273.63875C61.6530625 288.0875 64.40375 302.546875 70.625 315.625C112.5 406.25 187.5 570 212.5 638.75C218.610625 655.22125 229.605625 669.4337499999999 244.014375 679.48625C258.4225 689.5387499999999 275.556875 694.9512500000001 293.125 695H851.25C874.2375 694.67125 896.1750000000001 685.308125 912.3125 668.9337499999999C928.45625 652.56 937.5 630.49125 937.5 607.5V388.125C937.5 376.79875 935.26875 365.583125 930.9375 355.11875C926.6 344.654375 920.25 335.14625 912.2375 327.136875C904.23125 319.128125 894.71875 312.775 884.2562499999999 308.440625C873.79375 304.1056250000001 862.5749999999999 301.875 851.25 301.875H765L400 -39.375C383.851875 -53.85 362.935 -61.85625 341.25 -61.875zM293.125 632.5C288.24125 632.45 283.484375 630.933125 279.4725000000001 628.146875C275.460625 625.36125 272.378125 621.43375 270.625 616.875C245.625 548.75 178.75 401.25 125 289.375C123.1925 285.900625 122.24875 282.041875 122.24875 278.125C122.24875 274.208125 123.1925 270.349375 125 266.875C127.60125 263.1531250000001 131.240625 260.2793750000001 135.46375 258.6125C139.6875 256.9450000000001 144.308125 256.558125 148.75 257.5H355L387.5 215V186.25L319.375 33.75C317.110625 28.76875 316.6843750000001 23.1500000000001 318.171875 17.8875C319.659375 12.625 322.964375 8.0562500000001 327.5 5C331.7375 1.55 337.035 -0.3375000000001 342.5 -0.3375000000001C347.9650000000001 -0.3375000000001 353.263125 1.55 357.5 5L736.25 354.375L765.625 362.5H851.25C854.53125 362.49 857.78125 363.160625 860.79375 364.469375C863.80625 365.778125 866.5125 367.6975 868.7437500000001 370.105625C870.975 372.51375 872.68125 375.358125 873.7625 378.459375C874.8375000000001 381.5612500000001 875.2625 384.851875 875 388.125V607.5C875.00625 613.919375 872.5437499999999 620.095625 868.125 624.75C863.70625 629.4043750000001 857.6625 632.17875 851.25 632.5H293.125z" /> + horiz-adv-x="1000" d=" M658.75 695.000625C676.8 694.9137499999999 694.4187499999999 689.4762499999999 709.375 679.375625C725.54375 667.72875 737.18125 650.8425 742.30625 631.5875C747.43125 612.3325 745.7375000000001 591.895625 737.5 573.75125L676.875 438.12625L851.25 438.125625C865.56875 438.3925 879.71875 435.038125 892.39375 428.3725C905.06875 421.7075 915.85625 411.948125 923.75 400.000625C931.6875 387.888125 936.375 373.9362500000001 937.3625 359.4875C938.35 345.0381250000001 935.59375 330.57875 929.375 317.500625C887.5 226.875625 812.5 63.125 787.5 -5.625C781.3875 -22.09375 770.39375 -36.3062500000001 755.9875000000001 -46.3625000000001C741.5749999999999 -56.4125 724.44375 -61.8249999999999 706.875 -61.875L148.75 -61.875C125.760625 -61.5437499999999 103.824375 -52.18125 87.684375 -35.80625C71.544375 -19.43125 62.4974375 2.6375 62.49975 25.625L62.4998125 245.0012500000001C62.4998125 256.3275 64.730625 267.5431250000001 69.065 278.0075000000001C73.399375 288.471875 79.7525 297.9799999999999 87.761875 305.98875C95.770625 313.998125 105.27875 320.3512500000001 115.743125 324.685625C126.2075 329.02 137.423125 331.25125 148.75 331.25125L235 331.25125L600 672.50125C616.148125 686.97375 637.0625 694.984375 658.75 695.000625zM706.875 0.625C711.75625 0.6750000000001 716.5125 2.19375 720.525 4.9812499999999C724.5374999999999 7.7625 727.61875 11.69375 729.375 16.25C754.375 84.375 821.25 231.875625 875 343.750625C876.80625 347.225625 877.75 351.084375 877.75 355.000625C877.75 358.9175 876.80625 362.77625 875 366.250625C872.4 369.9725 868.7625 372.84625 864.5374999999999 374.51375C860.3125 376.180625 855.69375 376.5675 851.25 375.625625L645 375.62625L612.5 418.125625L612.5 446.8762500000001L680.625 599.375625C682.8874999999999 604.355 683.31875 609.975625 681.83125 615.239375C680.34375 620.5025 677.0374999999999 625.06875 672.5 628.125625C668.2624999999999 631.5775 662.9625 633.4625 657.5 633.4625C652.0375 633.4625 646.7375 631.5775 642.5 628.12625L263.75 278.7512500000001L234.375 270.6262500000001L148.75 270.6262500000001C145.466875 270.6362499999999 142.216875 269.9656250000001 139.20625 268.6568749999999C136.195 267.3475 133.48875 265.4287500000001 131.256875 263.020625C129.025 260.6125 127.316875 257.768125 126.239375 254.66625C125.1625 251.565 124.740625 248.2737500000001 125 245.0012500000001L125 25.625C124.991875 19.2062500000001 127.453125 13.03125 131.875 8.375C136.29625 3.725 142.338125 0.95 148.75 0.625L706.875 0.625z" /> @@ -552,7 +555,7 @@ horiz-adv-x="1000" d=" M479.375 -100H523.75L631.25 7.5H781.25L812.5 38.75V190L921.25 297.4975000000001V341.8725L814.375 449.3725V601.8725L783.125 632.4975H631.25L523.75 739.3725H479.375L375 632.4975H220.625L187.5 601.2475V449.3725L81.875 341.8725V297.4975000000001L187.5 190V38.75L220.625 7.5H375L479.375 -100zM385 70H250V203.1225000000001L242.5 224.9975000000001L148.125 319.9975L240.625 414.3725L250 436.2475V569.9975H385L407.5 578.7475L500 673.1225L596.25 578.7475L618.125 569.9975H750V436.2475L760.625 414.3725L855.625 319.9975L758.75 224.9975000000001L750 203.1225000000001V70H618.125L594.375 60.625L500 -33.75L407.5 61.25L385 70zM420.6275 165.0062499999999H465.0025L700.625 400.625L656.25 445L443.1275 231.255625L356.875 317.51L312.5 273.135L420.6275 165.0062499999999z" /> + horiz-adv-x="1000" d=" M437.5 38.75L468.75 7.5H906.25L937.5 38.75V601.25L906.25 632.5H468.75L437.5 601.25V38.75zM562.5 507.5H812.5V132.5H562.5V507.5zM312.5 257.5V507.5H375V570H281.25L250 538.75V257.5V226.25V101.25L281.25 70H375V132.5H312.5V226.25V257.5zM125 320V445H187.5V507.5H93.75L62.5 476.25V320V288.75V163.75L93.75 132.5H187.5V195H125V288.75V320z" /> diff --git a/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.ttf b/src/vs/base/browser/ui/octiconLabel/octicons/octicons2.ttf index 108574251ca4c2717b8c2e305741f37086d1b236..60d7dfabfbf8f704e3f50a7b8277ea566b48020d 100644 GIT binary patch delta 5458 zcmY+I3v?XSdB^{EW@l!#t9?JUlJ+U>>it@+WP`MlW$>Gq6B{s84{U>>ws{F69NTM* zc@r?+l)8jx5Gfd%0HP_iIVs17^iWC@hjQE&62~Nz<8acRi%Mt?4O0K(OHNN$`t8iz z(cYQ4-}n9h-|E04+UdjE!Cd9nfOr7F#?3pXZn*!}C!Yo!Zvr0gHQR5ydehAxo&Z9t zfStRyZJpW@&3X>=Z%>nfZ5*)N`hRf$b<(tL$MnqG2NxGP-$#IUdi(X8r|x}u`y>!} zk7GCOn3}mkyf1#s{W$+Vy>n{E)>9u>{%ZwrJ1?kZZ@B*E>AOGs$%nulX8`9d5P;sl zxQ_2<>}mCr_Q?Nxy>@nlqtATad}6{k^gFn9eirz*NB+IxkK4t?#TEKVy~JZDG<%dU zd#2aKX;d>}r}$O%ptxLrYH@K+iWAx)%~^fJ5o%naE~k$|KfBk#t&6L(0uDV~m5$9q zpZmJeEh>{@QrskN;*1-x1WU03D{%=bxEF_bJcuW-6$kMxJcI|~#|$pUPGpe9W(@JC zjO7@?GZ@Aw_FxhhU>z>P&G-|H<4Qb*JnrIMAI56jgBS2Ps`xficnr6p8!sb<9TjXx zEi4!?u@`Ibb$lNMr1576;VL|U`%%IA2Hr$QB zMiU;vpCgJtMGuPTLq9I#6W@e5Za_T(coePJh^ui6{sxV>6W_(NSc}S~cp4F$i#GfP zdNF`oaXH*v>l!qm4hg)33o(XecoOUJ3U0(Mgz-IGj~1-LCcKDm;(P?L4@pd83y$D< zw8H~0eu(dI;dMCBg<1S1=I|Bg#4_6!9xC71;d8?_Y@2u^3N$4O5~qcFsR5MQ82v7e_v5Kdx4jEKp1o6 zUr{jnkQ}mM9zZhlY?u*{%tjmL2Be{2mOz>c<_n~yVCFzN70e;X8U?cn(#2ck8_Sdj zZUs{evR1)lgY+nvc932L(+|>~n4H}Ya-T3MAwvqLCuCT`M1_nfn6i*j1%|mqGNxc2 zL$bten9-1R3QTgFQZUOQ(+cK0WKO}%hip=?1|ahaRs&=~!McEKQLsWF+en3Pc#1pi z3YHCIhk^wJ*{QGvKz1ouRFK^YmKS7?f`tazt6<4N_9<9=kVOT{5VBvvf<#49Uu;;L zkOK-Uu$m#yRbU6Vc6bO29CBE}Qirs|Ls;~Xc1T9- z6txp*R6!+xT&AEVK#nP>4v=;{33USUJOvd4@_Yrg19F7|X>M04s3(xC6jT;Sd&LMf z267FrFF85o26CN(!UJi?nNWftFH}&BAniC4$`a&y1qBN7YYIvgIP{a6Y3n~l?o~zq@75F+6QST5}^u0PAI5{kdq23Bjl8V8VPAX zDWO_IZdOn?A-CA^=Nlyya;t)33VF4HvI=QmoKRpP?Fk5_7Sg^5q3A+>1?3lVyMjUt zxkEuohTN&3I78l`piHy=Z{z{7Jxbo9pmsyvs-TKPenUY$hn!JR*&)BFpvFVm%Sx#B zkb4x=eMmcx2pxdsrl1!?I~NAxL|P3GE2-D`-rR_7f4B2jpW4nib^Z z3fdOrlL{Ibq&x(25~XC}_%%KU2`2A>UQds3HGZLCc1GPXRmr@}z=34*4$%Iy&UPD(LNy z?@Mw7O~JMSpMC`! z2+T91ZP-d+o>^?erULW4aT~T5nBS*hqk;L`6>K>$zhA-T1M_z%*oI*KfPxJPD)Y>2 z8}=rcze`~!+B`GehW!fW?^UpK!TkLS_Ar=d*4wa~!8|kH1`iYaHNy_#UCfJGkr$(4 zqu4I?i^Jj-@ribw_L%m2J)w^~!j8&-<0Yfb7&RU=W{so93F9+!)O^(nT9ekB&Nk=8 z&i&5g&QEF@YT9bvaP_#Zb{%s4-ko%hy03E|bid*LRjspjw03Xpe|n;xU7o-9=Dl0I zk9t4zP5a*T$NiK3cLL796M^G_kAu$O{!mZoKsXw{Dm))~Fxn8Ej4s52mDrWB<8fDf zD84^_rY>2xv+lh_IM6~XP7G`ucy8d-VAEikORn=P!^Qd?{L0Wo ztEL<^7fPbkrF->8VR=P38WTy;H!vtHGpUy~kuPhNSW@t0$Sbn>g6I6<=J-QWX%w=NMm&b*p*6Z{HSFSZYUaw=} z4-V6Gh(TwKsEsuy0$OdY2=)BZAto-1au(rF79zhn>Eo2X;e|h(opbW>KqleWeDxXa zh~;%Tga~^#t^9JvGz?Q{hR5eI#K1o~!){-~uh+&K6VA66ev7%DP;;hopFXC2&OUaW zy+onRhbZvZw9HsEW_9UT+5^cRJU*p`6r(s2HZ#pGb8CBcVhfViXLn8UqVYaoIFd}}bFIz6SUj6)X==;1HeEHndnnpqh$ZD+S1iBGRS&PC4)`Xa^Ok$6`wEck(NC{Z4%Yd-e+>%iO#OV4Q5Fq^$gv8DRx&^bAS5%OvbXIay; z_PZS?ui)?5F`hN6|1-3-^~>KR0ztE9d3`+UZdu}L=(acg0k0PC6sKa#8#vrLSn`Lg z>eTSC??<($lt%D#VuZ`{$RL{{$s1{;sO0dR!^4Ia|y<)r-r+$-g3H@N%DW! z8!ESJ+TGRb$_dX{eC&@?2hD1=e4*z%aWm*I4Ys(E=wltOsf%H zT0hgQEc&7;wTUJ5>fbGEZd_qT{R_tyj{2i+chnyrSw0fqupwUNCJ=E~jj<+uWh7ti z8jBf)w$2#l){d>PgjGGX`aI|M!KTsfdLgR6SUpi4UUNpQtmfCAZ?K??X7%Q^%Z#2@ z&tvZDv980CLrGO>V_D-}y5kO>qcxvae$Ucu^0vJQ((#$2{bD+QQy)ro7;6{lh8 zmL-Jcsc|@rpS=@pN%{S$mR%jYW;Str7N0HDmK~a*TY;K% zO~B*O#7H378qwDCbAg3-J9b?$+di{U5Wn2p{^Ew+9WS2^_I>(x?HG$;gx~7eLW%w^ zJ`8Us5;m*9zouLr+&1eKXCk@gddrszC7Sq1XSUt0>r~Y0j_r5O{cigMW`$n8c(;B; zJIN`IgZ+uf=JJIuEk_l#BFxZOZ?u;>LM7=0bpurjGhB5EJxGE`@~EU8n21YW|nV8qrubphU?$-m*5vsdDEvSv8iH_)HA#1*q%IMmb^-{&{O4aMfLX1UCYc)EXLWya7uteE989Hzr?I9={=S4TG3)jX8n&^Fwj z^#x+0lo#tP)79CKTsV}8U+hnXgP}sg{gzSdbXYFk@9~Gr-Wp2}_l!3=n@Y=ahR>?? zCUSN4b#C2ZdK$Cc$)Wo82A@@N3LBm@yjK2O15x)6ny4uPUxSr>4;t_Pb3(6Lhi~ zcd`&&x_YP(_Bh?0%{_^Tt9d|tdAP5!C*g`WX{lIiy2dG%SWbuI5@E&?PFIcTy2wgp zvqPN;PNAE%Ee$O#j_3uU)>PIqYkc(`v0x--#$BeR=}wnnS(#{lZGBDaKy$9f>9m?s zVkX49PK3nV=hLl@Y|<_pBg-@x5q4!T;$>0H*k&E}YVCZ|>ey|gVtw_%ZI`pXW4SFJ z*I&?HV-q`C{p7Y()wRn$yKdK|bI>ytp`3ZnY{R4 DsK386 delta 5055 zcmY+H3y@UhnTFqUPIsTa_w>Ez+V}1m=04MNkxLH@!zIIj5s`}|1Bl=R0Y@Q-Kx{-H z#!EtSj4?_S1=+-~M3_WfLs71k-LP4A*GP(uk+|$`%4JiQ`#Z~8Ta*s_{`{nBGd<5a z|GA(3zxR8;uP;5V?|(`^l&$;$&>jb{eEpVnM<-wKYP@t*p{&G)Qdx9GjGoj~wS?i=5- zZs)l6p2qXF1W!tBUAJY!2On1cdp@vtJ1@wL-?MGI@2{(?fPGH`&dtyOqjYVA%gge% zTyoE!{k?X55BI({di>cnftmjUk2?3g$NaySXR7tJ`Nn0Vhnr65H?Eg=dQH0oE3IwS z{@psHt(y2mJFkC7w^_fih3kjZql_|)>!TK~<;)DhW`wLOw)L7mvC`hIRYtW@ZCo4Y z-Ik#b{g{XO_#z&}BltGAd+`I@iErU?d=pO~fctSXwjhNx?!XLwW?>Lzyoi|?z#go@ z2o_-p?!%YxWvs^Y$m0MX|2-_k*YPqA<2$g>fM>B2ZFmJSY_8yLc;J8yc6<$Az^(X8 z6p+M|2w@!_!=otSCgkuC_MrvM*p1t95+|?`d+`^@;42uzT{wuJB8%_hDMYae?dU=$ zy0HQ-+>1EwK@F<#eKg`WY`}KBiaPAa3pj>hRF>liBAAXQJdFd zaG`Ka!N8&Ll7b;b;kbgqMB#@Dh82Y$DHvcBURE&FD4eXw1s^OQa7w}Wqi|Y5B|z}7 zgqnb$0wq)j1XU@aP9W?GDh9%#pmrck1yuy$R8UV4E(Iz#b3lzsC^86-f^vi4+(;-q z2%mxygzzgUMTjcJ^>K(}LV-er6_hGOL_yI)L=}`TL=33N1(ggDS5VUsOmzv>4NV9FcBfT6--HplBB{1TO815B+OF?#$UpWg`h4Z z%v}fyPr@vQxJki$hM2BkW<$u35NzgJ&MINDL&%U2ragoV1EB#xR0g;p^a6<43c3Qs z90mOWLdKBLDIn%5=ot`03c3fxJOzCOV!nco04=6*Mr26$)Az#7YHC4Pupy|0-T^ zJ2!4Xr-N9npyxqI@esNngcJ|KUam(KbVP_X3VI{NS_NGaLVh_yzl69$LFa^6ufV|y z2X`uHrw|(yG*$@tKthX!kQWh}Erh%oq3uF!QqX`QWSj}D7-F-6rVOz~L3@VSs-RIr zjFSo%^lXTG6?AWiuPW%{5IYofbcp*E^mYg-NJ5u~kW)$M_Yiv&bbbh_9l{y_@t}g$ zfDcu$E-?T1a)Yo$K*$&p77K{|3YHCs0}2)ph_5SHN+2Flu&6*hu3&kActQcGfo~~r zgzIlBSbHFzybfPQrjMLf!h!_xJq1e>g!~qSMGE2>1xpFUVFe2p#19lKVGz$NWYrh) zfrMoZLcT0vfrEHa!BPitR8GZF9!PL4zXf6agLqlNN(doENLUjgUQw_*LYz`yHrJ;W zte6mT_6Tby#2X4$QHZk&)>DXIC{THTgTGO*$U>Y`u-roYoq~lI;#UfmV2HOBEXEN3 zq+nTwct^nk4e@IQOEtv13KngM^9q)4h~LQgbHOZxxS(K7hxlg&t2@MR6|D0Rzf-W{ zL%gqG?T5IiU>5-Kdjruy?`aV+wXLn0#Epeg>0NyF_+2{43DRcF}H6;v7D}70s=swCUP?+N7S- z_v$a|9~y^^v$lTQY1=t_%wB1+587AS_t?)lW;&j6TsB9{)8=oTZs)M`KIbv#Y1cy6 z>#mR8HSWFc}J>gfp?ElK5%jkJZzwk5qqD zv#@4Q&4t=X?ZH}6x3=zB-8=Oo^;a9Z8lGx+w_z%oOMaNDN{yt>ran%W(!0{Hq_1YC zWnRzs=eOtoSO^sk7TzjcEY=jeikpfDi?0@c*SNg#nWmPeB~3e;KAW~|+QsIP=9gO> zEz?_ewESCZqIIx!SL^Go1Cwocw4H44YQL}jbVp;yA3D*wvhzfjyQ|c-zw21ng|5l& z<=tW;Vo#~(jb3l>VDBTnFHZDF^6AQh#$x?b<|q9~YtxE_cCBDK zZhWGVcxNQ3MPo@VlGLLOT0|bn6pEcZ&zAkudC^FN5s&qiwZ7iI-k#o~>DNuaR&2BN zlzRI*xij9NcXySIA}=fy+w{JIJh!vAFBXqg;#`<9)96UuovhdLK3_K3n$5++n$50j zy3^(g=(^qJaG744+irKbowgR!X~Y74m#eyUV9~TMt!`eNnw{|KbuF%Zce3-|zT7}} zKH~H0cEjPV%SS_*YQJXM9WJ-&;w^nuz1e8oUY9Gk)+RKq;?dR&Z5%4k%WIk~5YD7q zo7>Dt#Pm50Lk}6IKW;NzZnxnw9Coki^h6>)r)jIt)Fv~z)@8#pn!WM3x4B{FvgXz= z%zZaKqa#%7_q%c(Gv?;%`l{_Nn1ez=8jJTB-0JJ@DV4SEF3woJ)*X+U#cVp7 zHnKh8XqHpm6^j~o{6lQ2KAF^#_N&_c$@dG1B)a|r9S&j(teZv@%!0ibu9n<=MN{ZUOzt`$+i!0eD#dp{qw0s0|V9he9gqo z(=Y30nN95N7_-W=rWcELzKvfmwrOQOZe-*t7H`n}T9#bj%i|8ydUn=Lt+CIq)dWM1 zj=8mon5VJ7CRf)k*QKCePqfx({~MoM#{*4$Jyl^dVSPSp*6iqcZ@g}9yBV%3^*4Il z+L@GG^Nyv~+Nq5RN2sc&ugMcj)D5x-U2g=h?Ke*Fmv4qMc`MdgJId`^)_SR&@>7-n z|9yU4ZZ>N47p$prO(52i82r(_ys_ zMxC*EC;uBXYyM!~?kqbz9&77h!shna9o8d*IeT(rG#s{mG8lJ6!qI4JeB$p1=bKv8 z3JnjLclYOJx7X^{=l#7Q4f(=bkeJPIywW;$hyH+1--Z@p&{^h~u6SwVYVa=Cq z{k2Dp&HB&T@eT0z(e2izu@QdTSI3U|yxNs$HeYK7lHr=%#MoCJGHk_Cn{Iuy`2g$S z#Q2sc92E|D{bjn_cKK64%lI`KS}YndOLQWBvc1yo7)!a84QMxPk3L5?qsWxMQN%no zgIe~F~!Haou^js-j>-AudR`r`6Xur8tN^(~=rL%Kc_j?dlp`6gee5~>M@^-sHQ?P{F2 zpn2hK>zB^&X|0a=J*LCvFkLR2q2(N=HxR8!fhHlq=?kc|-u+cfAHb=NRWZJzU zr!ShR%Qs{a@vz(Jb9-G~efJcb8}q4DZId$)GF@&@x_DsQ(9|#G^J+pe580Mndvs#y zj)3{M_yp8YZsn Ujykp1CfxhCYTVj);C;vc0f%yF1poj5 From 827796e167f876118da842deef23ce59ba3fe9b5 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 19:19:44 +0200 Subject: [PATCH 116/204] :lipstick: --- .../browser/ui/tree/asyncDataTree.test.ts | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts index f57c017c0af22..3192f789ac1b8 100644 --- a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts +++ b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts @@ -51,6 +51,15 @@ class VirtualDelegate implements IListVirtualDelegate { getTemplateId(element: Element): string { return 'default'; } } +class DataSource implements IAsyncDataSource { + hasChildren(element: Element): boolean { + return !!element.children && element.children.length > 0; + } + getChildren(element: Element): Promise { + return Promise.resolve(element.children || []); + } +} + class Model { constructor(readonly root: Element) { } @@ -65,15 +74,6 @@ suite('AsyncDataTree', function () { test('Collapse state should be preserved across refresh calls', async () => { const container = document.createElement('div'); - const dataSource = new class implements IAsyncDataSource { - hasChildren(element: Element): boolean { - return !!element.children && element.children.length > 0; - } - getChildren(element: Element): Promise { - return Promise.resolve(element.children || []); - } - }; - const model = new Model({ id: 'root', children: [{ @@ -81,7 +81,7 @@ suite('AsyncDataTree', function () { }] }); - const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], new DataSource(), { identityProvider: new IdentityProvider() }); tree.layout(200); assert.equal(container.querySelectorAll('.monaco-list-row').length, 0); @@ -212,15 +212,6 @@ suite('AsyncDataTree', function () { test('resolved collapsed nodes which lose children should lose twistie as well', async () => { const container = document.createElement('div'); - const dataSource = new class implements IAsyncDataSource { - hasChildren(element: Element): boolean { - return !!element.children && element.children.length > 0; - } - getChildren(element: Element): Promise { - return Promise.resolve(element.children || []); - } - }; - const model = new Model({ id: 'root', children: [{ @@ -228,7 +219,7 @@ suite('AsyncDataTree', function () { }] }); - const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], dataSource, { identityProvider: new IdentityProvider() }); + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], new DataSource(), { identityProvider: new IdentityProvider() }); tree.layout(200); await tree.setInput(model.root); From aff32e7b5cfe1a2c1a44202d21aa1c22dfaa647d Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 5 Sep 2019 19:53:12 +0200 Subject: [PATCH 117/204] wip --- src/vs/base/browser/ui/tree/asyncDataTree.ts | 9 ++++-- src/vs/base/browser/ui/tree/indexTreeModel.ts | 10 +++++++ .../browser/ui/tree/asyncDataTree.test.ts | 28 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/vs/base/browser/ui/tree/asyncDataTree.ts b/src/vs/base/browser/ui/tree/asyncDataTree.ts index f9380aaf2430a..04549cb817af7 100644 --- a/src/vs/base/browser/ui/tree/asyncDataTree.ts +++ b/src/vs/base/browser/ui/tree/asyncDataTree.ts @@ -451,7 +451,7 @@ export class AsyncDataTree implements IDisposable const viewStateContext = viewState && { viewState, focus: [], selection: [] } as IAsyncDataTreeViewStateContext; - await this.updateChildren(input, true, viewStateContext); + await this._updateChildren(input, true, viewStateContext); if (viewStateContext) { this.tree.setFocus(viewStateContext.focus); @@ -463,7 +463,11 @@ export class AsyncDataTree implements IDisposable } } - async updateChildren(element: TInput | T = this.root.element, recursive = true, viewStateContext?: IAsyncDataTreeViewStateContext): Promise { + async updateChildren(element: TInput | T = this.root.element, recursive = true): Promise { + await this._updateChildren(element, recursive); + } + + private async _updateChildren(element: TInput | T = this.root.element, recursive = true, viewStateContext?: IAsyncDataTreeViewStateContext): Promise { if (typeof this.root.element === 'undefined') { throw new TreeError(this.user, 'Tree input not set'); } @@ -873,6 +877,7 @@ export class AsyncDataTree implements IDisposable private render(node: IAsyncDataTreeNode, viewStateContext?: IAsyncDataTreeViewStateContext): void { const children = node.children.map(c => asTreeElement(c, viewStateContext)); + this.tree.setCollapsible(node.hasChildren); // TODO this.tree.setChildren(node === this.root ? null : node, children); this._onDidRender.fire(); } diff --git a/src/vs/base/browser/ui/tree/indexTreeModel.ts b/src/vs/base/browser/ui/tree/indexTreeModel.ts index 022d612c0a361..720138dd3e9ba 100644 --- a/src/vs/base/browser/ui/tree/indexTreeModel.ts +++ b/src/vs/base/browser/ui/tree/indexTreeModel.ts @@ -205,6 +205,16 @@ export class IndexTreeModel, TFilterData = voi return this.getTreeNode(location).collapsible; } + setCollapsible(location: number[], collapsible?: boolean): boolean { + const node = this.getTreeNode(location); + + if (typeof collapsible === 'undefined') { + collapsible = !node.collapsible; + } + + throw new Error('To be implemented'); + } + isCollapsed(location: number[]): boolean { return this.getTreeNode(location).collapsed; } diff --git a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts index 3192f789ac1b8..e26c5c66cb12e 100644 --- a/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts +++ b/src/vs/base/test/browser/ui/tree/asyncDataTree.test.ts @@ -355,4 +355,32 @@ suite('AsyncDataTree', function () { race = await Promise.race([pExpandA.then(() => 'expand'), timeout(1).then(() => 'timeout')]); assert.equal(race, 'expand', 'expand(a) should now be done'); }); + + test('issue #78388 - tree should react to hasChildren toggles', async () => { + const container = document.createElement('div'); + const model = new Model({ + id: 'root', + children: [{ + id: 'a' + }] + }); + + const tree = new AsyncDataTree('test', container, new VirtualDelegate(), [new Renderer()], new DataSource(), { identityProvider: new IdentityProvider() }); + tree.layout(200); + + await tree.setInput(model.root); + assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); + + let twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; + assert(!hasClass(twistie, 'collapsible')); + assert(!hasClass(twistie, 'collapsed')); + + model.get('a').children = [{ id: 'aa' }]; + await tree.updateChildren(model.get('a'), false); + assert.equal(container.querySelectorAll('.monaco-list-row').length, 1); + + twistie = container.querySelector('.monaco-list-row:first-child .monaco-tl-twistie') as HTMLElement; + assert(hasClass(twistie, 'collapsible')); + assert(hasClass(twistie, 'collapsed')); + }); }); From b283b2978139ea12cee702164bd991f055e3fb92 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 21:23:41 +0200 Subject: [PATCH 118/204] rawDebugSession: extensionDevelopmentPath is array. Fixes #80410 --- src/vs/workbench/contrib/debug/browser/rawDebugSession.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index d8037ae2470ec..7fde27d12310f 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -587,7 +587,13 @@ export class RawDebugSession { } else { args[key] = [value]; } - + } else if (key === 'extensionDevelopmentPath') { + const v = args[key]; + if (v) { + v.push(value); + } else { + args[key] = [value]; + } } else { (args)[key] = value; } From 9414b7e75bdbef887c76cb603e542db2b86b99b7 Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Thu, 5 Sep 2019 16:38:20 -0700 Subject: [PATCH 119/204] fixes #80404 --- src/vs/workbench/contrib/terminal/browser/media/terminal.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/media/terminal.css b/src/vs/workbench/contrib/terminal/browser/media/terminal.css index 4009bfe4cf50a..be6edf706dce4 100644 --- a/src/vs/workbench/contrib/terminal/browser/media/terminal.css +++ b/src/vs/workbench/contrib/terminal/browser/media/terminal.css @@ -72,8 +72,6 @@ } .monaco-workbench .panel.integrated-terminal .split-view-view { - /* Make relative as terminal absolute positioning needs it deeper in the tree */ - position: relative; box-sizing: border-box; } From 0739b0f0692e0a2f244ce2772d2defcaad0bdc08 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 6 Sep 2019 08:19:04 +0200 Subject: [PATCH 120/204] url service - create proper URIs --- src/vs/platform/url/node/urlService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/url/node/urlService.ts b/src/vs/platform/url/node/urlService.ts index adf857493e848..f73ff3fb045fb 100644 --- a/src/vs/platform/url/node/urlService.ts +++ b/src/vs/platform/url/node/urlService.ts @@ -10,7 +10,11 @@ import { AbstractURLService } from 'vs/platform/url/common/urlService'; export class URLService extends AbstractURLService { create(options?: Partial): URI { - const { authority, path, query, fragment } = options ? options : { authority: undefined, path: undefined, query: undefined, fragment: undefined }; + let { authority, path, query, fragment } = options ? options : { authority: undefined, path: undefined, query: undefined, fragment: undefined }; + + if (authority && path && path.indexOf('/') !== 0) { + path = `/${path}`; // URI validation requires a path if there is an authority + } return URI.from({ scheme: product.urlProtocol, authority, path, query, fragment }); } From a26961432c1ddb36367d2eca470086b32e506eb8 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 6 Sep 2019 08:43:09 +0200 Subject: [PATCH 121/204] notifications - never hide them when window does not have focus (fix #80285) --- .../parts/notifications/notificationsToasts.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts index 7f410544c6a52..b949d8b0e08c2 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsToasts.ts @@ -236,12 +236,11 @@ export class NotificationsToasts extends Themable { purgeTimeoutHandle = setTimeout(() => { - // If the notification is sticky or prompting and the window does not have - // focus, we wait for the window to gain focus again before triggering - // the timeout again. This prevents an issue where focussing the window - // could immediately hide the notification because the timeout was triggered - // again. - if ((item.sticky || item.hasPrompt()) && !this.windowService.hasFocus) { + // If the window does not have focus, we wait for the window to gain focus + // again before triggering the timeout again. This prevents an issue where + // focussing the window could immediately hide the notification because the + // timeout was triggered again. + if (!this.windowService.hasFocus) { if (!listener) { listener = this.windowService.onDidChangeFocus(focus => { if (focus) { From 4fa0b6543fdb4513bf753518f6130ebb8fa45821 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Fri, 6 Sep 2019 09:30:30 +0200 Subject: [PATCH 122/204] Open local files in same window when remote by default Fixes https://github.com/microsoft/vscode-remote-release/issues/980 --- .../dialogs/browser/fileDialogService.ts | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts index 7e9d2b3763a49..7dec2cfe039c6 100644 --- a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts @@ -20,6 +20,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IFileService } from 'vs/platform/files/common/files'; import { isWeb } from 'vs/base/common/platform'; +import { IOpenerService } from 'vs/platform/opener/common/opener'; export class FileDialogService implements IFileDialogService { @@ -32,7 +33,8 @@ export class FileDialogService implements IFileDialogService { @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IInstantiationService private readonly instantiationService: IInstantiationService, @IConfigurationService private readonly configurationService: IConfigurationService, - @IFileService private readonly fileService: IFileService + @IFileService private readonly fileService: IFileService, + @IOpenerService private readonly openerService: IOpenerService ) { } defaultFilePath(schemeFilter = this.getSchemeFilterForWindow()): URI | undefined { @@ -85,10 +87,10 @@ export class FileDialogService implements IFileDialogService { }; } - private shouldUseSimplified(schema: string): boolean { - const setting = this.configurationService.getValue('files.simpleDialog.enable'); + private shouldUseSimplified(schema: string): { useSimplified: boolean, isSetting: boolean } { + const setting = (this.configurationService.getValue('files.simpleDialog.enable') === true); - return (schema !== Schemas.file) || (setting === true); + return { useSimplified: (schema !== Schemas.file) || setting, isSetting: (schema === Schemas.file) && setting }; } private addFileSchemaIfNeeded(schema: string): string[] { @@ -108,7 +110,8 @@ export class FileDialogService implements IFileDialogService { options.defaultUri = this.defaultFilePath(schema); } - if (this.shouldUseSimplified(schema)) { + const shouldUseSimplified = this.shouldUseSimplified(schema); + if (shouldUseSimplified.useSimplified) { const title = nls.localize('openFileOrFolder.title', 'Open File Or Folder'); const availableFileSystems = this.addFileSchemaIfNeeded(schema); @@ -118,7 +121,11 @@ export class FileDialogService implements IFileDialogService { const stat = await this.fileService.resolve(uri); const toOpen: IURIToOpen = stat.isDirectory ? { folderUri: uri } : { fileUri: uri }; - return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow }); + if (stat.isDirectory || options.forceNewWindow || shouldUseSimplified.isSetting) { + return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow }); + } else { + return this.openerService.open(uri); + } } return; @@ -134,13 +141,18 @@ export class FileDialogService implements IFileDialogService { options.defaultUri = this.defaultFilePath(schema); } - if (this.shouldUseSimplified(schema)) { + const shouldUseSimplified = this.shouldUseSimplified(schema); + if (shouldUseSimplified.useSimplified) { const title = nls.localize('openFile.title', 'Open File'); const availableFileSystems = this.addFileSchemaIfNeeded(schema); const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems }); if (uri) { - return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow }); + if (options.forceNewWindow || shouldUseSimplified.isSetting) { + return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow }); + } else { + return this.openerService.open(uri); + } } return; @@ -156,7 +168,7 @@ export class FileDialogService implements IFileDialogService { options.defaultUri = this.defaultFolderPath(schema); } - if (this.shouldUseSimplified(schema)) { + if (this.shouldUseSimplified(schema).useSimplified) { const title = nls.localize('openFolder.title', 'Open Folder'); const availableFileSystems = this.addFileSchemaIfNeeded(schema); @@ -178,7 +190,7 @@ export class FileDialogService implements IFileDialogService { options.defaultUri = this.defaultWorkspacePath(schema); } - if (this.shouldUseSimplified(schema)) { + if (this.shouldUseSimplified(schema).useSimplified) { const title = nls.localize('openWorkspace.title', 'Open Workspace'); const filters: FileFilter[] = [{ name: nls.localize('filterName.workspace', 'Workspace'), extensions: [WORKSPACE_EXTENSION] }]; const availableFileSystems = this.addFileSchemaIfNeeded(schema); @@ -196,7 +208,7 @@ export class FileDialogService implements IFileDialogService { async pickFileToSave(options: ISaveDialogOptions): Promise { const schema = this.getFileSystemSchema(options); - if (this.shouldUseSimplified(schema)) { + if (this.shouldUseSimplified(schema).useSimplified) { if (!options.availableFileSystems) { options.availableFileSystems = this.addFileSchemaIfNeeded(schema); } @@ -225,7 +237,7 @@ export class FileDialogService implements IFileDialogService { async showSaveDialog(options: ISaveDialogOptions): Promise { const schema = this.getFileSystemSchema(options); - if (this.shouldUseSimplified(schema)) { + if (this.shouldUseSimplified(schema).useSimplified) { if (!options.availableFileSystems) { options.availableFileSystems = this.addFileSchemaIfNeeded(schema); } @@ -243,7 +255,7 @@ export class FileDialogService implements IFileDialogService { async showOpenDialog(options: IOpenDialogOptions): Promise { const schema = this.getFileSystemSchema(options); - if (this.shouldUseSimplified(schema)) { + if (this.shouldUseSimplified(schema).useSimplified) { if (!options.availableFileSystems) { options.availableFileSystems = this.addFileSchemaIfNeeded(schema); } From fe44d14e71ad3d0dc357bee26c9b5085651cd492 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 6 Sep 2019 09:39:56 +0200 Subject: [PATCH 123/204] fixes #80415 --- extensions/git/src/git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 8208ca6623e20..5d47228c45522 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1766,7 +1766,7 @@ export class Repository { } const raw = await readfile(templatePath, 'utf8'); - return raw.replace(/\n?#.*/g, ''); + return raw.replace(/^\s*#.*$\n?/gm, ''); } catch (err) { return ''; From 68c1123b33676df276f706e66caf2293a959155b Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Fri, 6 Sep 2019 10:46:49 +0200 Subject: [PATCH 124/204] Code-insiders started from WSL doesn't return to console/ doesn't connect Fixes microsoft/vscode-remote-release#1369 --- resources/win32/bin/code.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/win32/bin/code.sh b/resources/win32/bin/code.sh index 54da18c898c13..f925851fb957b 100644 --- a/resources/win32/bin/code.sh +++ b/resources/win32/bin/code.sh @@ -16,7 +16,7 @@ if grep -qi Microsoft /proc/version; then WSL_BUILD=0 fi - if [ $WSL_BUILD -ge 41955 -a $WSL_BUILD -lt 41959 ]; then + if [ $WSL_BUILD -ge 17063 ]; then # $WSL_DISTRO_NAME is available since WSL builds 18362, also for WSL2 # WSLPATH is available since WSL build 17046 # WSLENV is available since WSL build 17063 @@ -26,7 +26,7 @@ if grep -qi Microsoft /proc/version; then # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" - if [ $WSL_BUILD -ge 41955 ]; then + if [ $WSL_BUILD -ge 41955 -a $WSL_BUILD -lt 41959 ]; then # WSL2 in workaround for https://github.com/microsoft/WSL/issues/4337 CWD="$(pwd)" cd "$VSCODE_PATH" From 3d8aa73a312b377ab748504b842d079793a7eb02 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 6 Sep 2019 11:01:06 +0200 Subject: [PATCH 125/204] wip: tree model setCollapsible --- src/vs/base/browser/ui/tree/abstractTree.ts | 4 ++++ src/vs/base/browser/ui/tree/asyncDataTree.ts | 6 +++++- src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts | 9 +++++++++ src/vs/base/browser/ui/tree/indexTreeModel.ts | 8 ++++++-- src/vs/base/browser/ui/tree/objectTreeModel.ts | 5 +++++ src/vs/base/browser/ui/tree/tree.ts | 1 + 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/vs/base/browser/ui/tree/abstractTree.ts b/src/vs/base/browser/ui/tree/abstractTree.ts index 410368f5f4921..885e6bc5bafd2 100644 --- a/src/vs/base/browser/ui/tree/abstractTree.ts +++ b/src/vs/base/browser/ui/tree/abstractTree.ts @@ -1418,6 +1418,10 @@ export abstract class AbstractTree implements IDisposable return this.model.isCollapsible(location); } + setCollapsible(location: TRef, collapsible?: boolean): boolean { + return this.model.setCollapsible(location, collapsible); + } + isCollapsed(location: TRef): boolean { return this.model.isCollapsed(location); } diff --git a/src/vs/base/browser/ui/tree/asyncDataTree.ts b/src/vs/base/browser/ui/tree/asyncDataTree.ts index 04549cb817af7..a15bbb11c8bc6 100644 --- a/src/vs/base/browser/ui/tree/asyncDataTree.ts +++ b/src/vs/base/browser/ui/tree/asyncDataTree.ts @@ -877,7 +877,11 @@ export class AsyncDataTree implements IDisposable private render(node: IAsyncDataTreeNode, viewStateContext?: IAsyncDataTreeViewStateContext): void { const children = node.children.map(c => asTreeElement(c, viewStateContext)); - this.tree.setCollapsible(node.hasChildren); // TODO + + if (node !== this.root) { + this.tree.setCollapsible(node, node.hasChildren); + } + this.tree.setChildren(node === this.root ? null : node, children); this._onDidRender.fire(); } diff --git a/src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts b/src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts index 81cae3bcd0c59..22f9ce43205d0 100644 --- a/src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts +++ b/src/vs/base/browser/ui/tree/compressedObjectTreeModel.ts @@ -231,6 +231,11 @@ export class CompressedTreeModel, TFilterData extends return this.model.isCollapsible(compressedNode); } + setCollapsible(location: T | null, collapsible?: boolean): boolean { + const compressedNode = this.getCompressedNode(location); + return this.model.setCollapsible(compressedNode, collapsible); + } + isCollapsed(location: T | null): boolean { const compressedNode = this.getCompressedNode(location); return this.model.isCollapsed(compressedNode); @@ -397,6 +402,10 @@ export class CompressedObjectTreeModel, TFilterData e return this.model.isCollapsible(location); } + setCollapsible(location: T | null, collapsed?: boolean): boolean { + return this.model.setCollapsible(location, collapsed); + } + isCollapsed(location: T | null): boolean { return this.model.isCollapsed(location); } diff --git a/src/vs/base/browser/ui/tree/indexTreeModel.ts b/src/vs/base/browser/ui/tree/indexTreeModel.ts index 720138dd3e9ba..de1f03d3b37de 100644 --- a/src/vs/base/browser/ui/tree/indexTreeModel.ts +++ b/src/vs/base/browser/ui/tree/indexTreeModel.ts @@ -210,9 +210,13 @@ export class IndexTreeModel, TFilterData = voi if (typeof collapsible === 'undefined') { collapsible = !node.collapsible; + } else if (node.collapsible === collapsible) { + return false; } - throw new Error('To be implemented'); + node.collapsible = collapsible; + this.eventBufferer.bufferEvents(() => this._setCollapsed(location, node.collapsed)); + return true; } isCollapsed(location: number[]): boolean { @@ -397,7 +401,7 @@ export class IndexTreeModel, TFilterData = voi result.push(node); node.renderNodeCount = 1; - if (!node.collapsed) { + if (node.collapsible && !node.collapsed) { for (const child of node.children) { node.renderNodeCount += this._updateNodeAfterCollapseChange(child, result); } diff --git a/src/vs/base/browser/ui/tree/objectTreeModel.ts b/src/vs/base/browser/ui/tree/objectTreeModel.ts index df4dabcdbc694..e2f78b9ebea9f 100644 --- a/src/vs/base/browser/ui/tree/objectTreeModel.ts +++ b/src/vs/base/browser/ui/tree/objectTreeModel.ts @@ -216,6 +216,11 @@ export class ObjectTreeModel, TFilterData extends Non return this.model.isCollapsible(location); } + setCollapsible(element: T | null, collapsible?: boolean): boolean { + const location = this.getElementLocation(element); + return this.model.setCollapsible(location, collapsible); + } + isCollapsed(element: T | null): boolean { const location = this.getElementLocation(element); return this.model.isCollapsed(location); diff --git a/src/vs/base/browser/ui/tree/tree.ts b/src/vs/base/browser/ui/tree/tree.ts index 930e76634bb3b..5be49ab229f7f 100644 --- a/src/vs/base/browser/ui/tree/tree.ts +++ b/src/vs/base/browser/ui/tree/tree.ts @@ -120,6 +120,7 @@ export interface ITreeModel { getLastElementAncestor(location?: TRef): T | undefined; isCollapsible(location: TRef): boolean; + setCollapsible(location: TRef, collapsible?: boolean): boolean; isCollapsed(location: TRef): boolean; setCollapsed(location: TRef, collapsed?: boolean, recursive?: boolean): boolean; expandTo(location: TRef): void; From b11d96fedecd31283ae373cbcc4ec28bcddb6074 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 6 Sep 2019 11:06:12 +0200 Subject: [PATCH 126/204] Simplify editor options --- .../common/config/commonEditorConfig.ts | 8 +- src/vs/editor/common/config/editorOptions.ts | 409 +++++++++--------- src/vs/editor/editor.api.ts | 4 +- src/vs/monaco.d.ts | 214 +++++---- 4 files changed, 321 insertions(+), 314 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index a6442a9038c18..a778496a278a7 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -76,7 +76,7 @@ class EditorConfiguration2 { const options: { [key: string]: any; } = _options; const result = new RawEditorOptions(); for (const editorOption of editorOptionsRegistry) { - const value = options[editorOption.name]; + const value = (editorOption.name === '_never_' ? undefined : options[editorOption.name]); result._write(editorOption.id, value); } return result; @@ -1023,7 +1023,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.cursorBlinking': { 'type': 'string', 'enum': ['blink', 'smooth', 'phase', 'expand', 'solid'], - 'default': EditorOptions.cursorBlinking.defaultValue, + 'default': 'blink', 'description': nls.localize('cursorBlinking', "Control the cursor animation style.") }, 'editor.mouseWheelZoom': { @@ -1039,7 +1039,7 @@ const editorConfiguration: IConfigurationNode = { 'editor.cursorStyle': { 'type': 'string', 'enum': ['block', 'block-outline', 'line', 'line-thin', 'underline', 'underline-thin'], - 'default': EditorOptions.cursorStyle.defaultValue, + 'default': 'line', 'description': nls.localize('cursorStyle', "Controls the cursor style.") }, 'editor.cursorWidth': { @@ -1156,7 +1156,7 @@ const editorConfiguration: IConfigurationNode = { nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader."), nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."), ], - 'default': EditorOptions.accessibilitySupport.defaultValue, + 'default': 'auto', 'description': nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers.") }, 'editor.showUnused': { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 13c42151c9d80..af15232a310db 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import * as assert from 'vs/base/common/assert'; import * as platform from 'vs/base/common/platform'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { FontInfo } from 'vs/editor/common/config/fontInfo'; @@ -938,7 +937,7 @@ function _string(value: any, defaultValue: string): string { return value; } -function _stringSet(value: T | undefined, defaultValue: T, allowedValues: T[]): T { +function _stringSet(value: T | undefined, defaultValue: T, allowedValues: ReadonlyArray): T { if (typeof value !== 'string') { return defaultValue; } @@ -1121,6 +1120,20 @@ export class ComputedEditorOptions implements IComputedEditorOptions { //#region IEditorOption +export interface IEditorOption { + readonly id: K1; + readonly name: string; + readonly defaultValue: V; + /** + * @internal + */ + validate(input: any): V; + /** + * @internal + */ + compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V; +} + /** * @internal */ @@ -1130,116 +1143,149 @@ type PossibleKeyName0 = { [K in keyof IExtendedEditorOptions]: IExtendedEdito */ type PossibleKeyName = NonNullable>; -export interface IEditorOption, T3 = T2> { - readonly id: K1; - readonly name: K2; - readonly defaultValue: T2; - /** - * @internal - */ - validate(input: IExtendedEditorOptions[K2] | undefined): T2; - /** - * @internal - */ - compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; +/** + * @internal + */ +abstract class BaseEditorOption implements IEditorOption { + + public readonly id: K1; + public readonly name: K2; + public readonly defaultValue: V; + public readonly deps: EditorOption[] | null; + + constructor(id: K1, name: K2, defaultValue: V, deps: EditorOption[] | null = null) { + this.id = id; + this.name = name; + this.defaultValue = defaultValue; + this.deps = deps; + } + + public abstract validate(input: any): V; + + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V { + return value; + } } /** * @internal */ -abstract class BaseEditorOption implements IEditorOption { +abstract class ComputedEditorOption implements IEditorOption { public readonly id: K1; - public readonly name: K2; - public readonly defaultValue: T2; + public readonly name: '_never_'; + public readonly defaultValue: V; + public readonly deps: EditorOption[] | null; + + constructor(id: K1, deps: EditorOption[] | null = null) { + this.id = id; + this.name = '_never_'; + this.defaultValue = undefined; + this.deps = deps; + } + + public validate(input: any): V { + return this.defaultValue; + } + + public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V; +} + +/** + * @internal + */ +class SimpleEditorOption implements IEditorOption { + + public readonly id: K1; + public readonly name: PossibleKeyName; + public readonly defaultValue: V; + public readonly deps: EditorOption[] | null; - constructor(id: K1, name: K2, defaultValue: T2, deps: EditorOption[] = []) { + constructor(id: K1, name: PossibleKeyName, defaultValue: V, deps: EditorOption[] | null = null) { this.id = id; this.name = name; this.defaultValue = defaultValue; - for (const dep of deps) { - assert.ok(dep < id); + this.deps = deps; + } + + public validate(input: any): V { + if (typeof input === 'undefined') { + return this.defaultValue; } + return input as any; + } + + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V { + return value; } - public abstract validate(input: IExtendedEditorOptions[K2] | undefined): T2; - public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3; } -class EditorBooleanOption> extends BaseEditorOption { - public validate(input: boolean | undefined): boolean { +class EditorBooleanOption extends SimpleEditorOption { + public validate(input: any): boolean { return _boolean(input, this.defaultValue); } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { - return value; - } } -class EditorIntOption> extends BaseEditorOption { +class EditorIntOption extends SimpleEditorOption { public readonly minimum: number; public readonly maximum: number; - constructor(id: K1, name: K2, defaultValue: number, minimum: number, maximum: number, deps: EditorOption[] = []) { - super(id, name, defaultValue, deps); + constructor(id: K1, name: PossibleKeyName, defaultValue: number, minimum: number, maximum: number) { + super(id, name, defaultValue); this.minimum = minimum; this.maximum = maximum; } - public validate(input: number | undefined): number { + public validate(input: any): number { return _clampedInt(input, this.defaultValue, this.minimum, this.maximum); } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { - return value; - } } -class EditorFloatOption> extends BaseEditorOption { +class EditorFloatOption extends SimpleEditorOption { public readonly validationFn: (value: number) => number; - constructor(id: K1, name: K2, defaultValue: number, validationFn: (value: number) => number, deps: EditorOption[] = []) { - super(id, name, defaultValue, deps); + constructor(id: K1, name: PossibleKeyName, defaultValue: number, validationFn: (value: number) => number) { + super(id, name, defaultValue); this.validationFn = validationFn; } - public validate(input: number | undefined): number { + public validate(input: any): number { return this.validationFn(_float(input, this.defaultValue)); } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { - return value; - } } -class EditorStringOption> extends BaseEditorOption { - public validate(input: string | undefined): string { +class EditorStringOption extends SimpleEditorOption { + public validate(input: any): string { return _string(input, this.defaultValue); } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { - return value; - } } -class EditorEnumOption, T1 extends string, T2 = T1> extends BaseEditorOption { - public readonly allowedValues: T1[]; - public readonly convert: (value: T1) => T2; - constructor(id: K1, name: K2, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOption[] = []) { - super(id, name, defaultValue, deps); +class EditorStringEnumOption extends SimpleEditorOption { + public readonly allowedValues: ReadonlyArray; + constructor(id: K1, name: PossibleKeyName, defaultValue: V, allowedValues: ReadonlyArray) { + super(id, name, defaultValue); this.allowedValues = allowedValues; - this.convert = convert; } - public validate(input: IExtendedEditorOptions[K2] | undefined): T1 { - return _stringSet(input, this.defaultValue, this.allowedValues); - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T1): T2 { - return this.convert(value); + public validate(input: any): V { + return _stringSet(input, this.defaultValue, this.allowedValues); } } -class EditorPassthroughOption extends BaseEditorOption { - public validate(input: IExtendedEditorOptions[K2] | undefined): IExtendedEditorOptions[K2] { - if (typeof input === 'undefined') { +class EditorEnumOption extends BaseEditorOption, V> { + public readonly allowedValues: T[]; + public readonly convert: (value: T) => V; + constructor(id: K1, name: PossibleKeyName, defaultValue: V, allowedValues: T[], convert: (value: T) => V, deps: EditorOption[] = []) { + super(id, name, defaultValue, deps); + this.allowedValues = allowedValues; + this.convert = convert; + } + public validate(input: any): V { + if (typeof input !== 'string') { return this.defaultValue; } - return input; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: IExtendedEditorOptions[K2]): IExtendedEditorOptions[K2] { - return value; + if (this.allowedValues.indexOf(input) === -1) { + return this.defaultValue; + } + return this.convert(input); } } + //#endregion //#region renderLineNumbers @@ -1259,8 +1305,8 @@ export interface InternalEditorRenderLineNumbersOptions { readonly renderFn: ((lineNumber: number) => string) | null; } -class EditorRenderLineNumbersOption> extends BaseEditorOption { - public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions { +class EditorRenderLineNumbersOption> extends BaseEditorOption { + public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions { let renderType: RenderLineNumbersType = this.defaultValue.renderType; let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; @@ -1284,9 +1330,6 @@ class EditorRenderLineNumbersOption> extends BaseEditorOption { - public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions { - if (typeof input !== 'object') { +class EditorMinimap> extends BaseEditorOption { + public validate(_input: any): InternalEditorMinimapOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorMinimapOptions; return { enabled: _boolean(input.enabled, this.defaultValue.enabled), side: _stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']), @@ -1314,9 +1358,6 @@ class EditorMinimap> extends BaseEditorOption { - public validate(input: IEditorHoverOptions | undefined): InternalEditorHoverOptions { - if (typeof input !== 'object') { + public validate(_input: any): InternalEditorHoverOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorHoverOptions; return { enabled: _boolean(input.enabled, this.defaultValue.enabled), delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000), sticky: _boolean(input.sticky, this.defaultValue.sticky) }; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorHoverOptions): InternalEditorHoverOptions { - return value; - } } //#endregion @@ -1356,11 +1395,12 @@ class EditorQuickSuggestions>) { super(id, name, defaultValue); } - public validate(input: boolean | IQuickSuggestionsOptions | undefined): ValidQuickSuggestionsOptions { - if (typeof input === 'boolean') { - return input; + public validate(_input: any): ValidQuickSuggestionsOptions { + if (typeof _input === 'boolean') { + return _input; } - if (typeof input === 'object') { + if (typeof _input === 'object') { + const input = _input as IQuickSuggestionsOptions; return { other: _boolean(input.other, this.defaultValue.other), comments: _boolean(input.comments, this.defaultValue.comments), @@ -1369,28 +1409,27 @@ class EditorQuickSuggestions> extends BaseEditorOption { - public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' { - return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']); +class EditorAccessibilitySupportOption> extends BaseEditorOption { + public validate(input: any): AccessibilitySupport { + switch (input) { + case 'auto': return AccessibilitySupport.Unknown; + case 'off': return AccessibilitySupport.Disabled; + case 'on': return AccessibilitySupport.Enabled; + } + return this.defaultValue; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: 'auto' | 'off' | 'on'): AccessibilitySupport { - if (value === 'auto') { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: AccessibilitySupport): AccessibilitySupport { + if (value === AccessibilitySupport.Unknown) { // The editor reads the `accessibilitySupport` from the environment return env.accessibilitySupport; - } else if (value === 'on') { - return AccessibilitySupport.Enabled; - } else { - return AccessibilitySupport.Disabled; } + return value; } } @@ -1398,8 +1437,8 @@ class EditorAccessibilitySupportOption> extends BaseEditorOption { - public validate(input: number[] | undefined): number[] { +class EditorRulers extends SimpleEditorOption { + public validate(input: any): number[] { if (Array.isArray(input)) { let rulers: number[] = []; for (let value of input) { @@ -1410,17 +1449,14 @@ class EditorRulers } return this.defaultValue; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number[]): number[] { - return value; - } } //#endregion //#region ariaLabel -class EditorAriaLabel> extends BaseEditorOption { - public validate(input: string | undefined): string { +class EditorAriaLabel extends SimpleEditorOption { + public validate(input: any): string { return _string(input, this.defaultValue); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string { @@ -1436,12 +1472,12 @@ class EditorAriaLabel> extends BaseEditorOption { - public validate(input: boolean | undefined): boolean { +class EditorDisableMonospaceOptimizations extends SimpleEditorOption { + public validate(input: any): boolean { return _boolean(input, this.defaultValue); } public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { - return (value || options.get(EditorOption.folding)); + return (value || options.get(EditorOption.fontLigatures)); } } @@ -1449,11 +1485,8 @@ class EditorDisableMonospaceOptimizations> extends BaseEditorOption { - public validate(input: undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): string { +class EditorClassName extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string { let className = 'monaco-editor'; if (options.get(EditorOption.extraEditorClassName)) { className += ' ' + options.get(EditorOption.extraEditorClassName); @@ -1477,11 +1510,8 @@ class EditorClassName> extends BaseEditorOption { - public validate(input: undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): boolean { +class EditorTabFocusMode extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: boolean): boolean { const readOnly = options.get(EditorOption.readOnly); return (readOnly ? true : env.tabFocusMode); } @@ -1491,11 +1521,8 @@ class EditorTabFocusMode> extends BaseEditorOption { - public validate(input: undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): number { +class EditorPixelRatio extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number { return env.pixelRatio; } } @@ -1504,7 +1531,7 @@ class EditorPixelRatio> extends EditorIntOption { +class EditorLineHeight> extends EditorIntOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { // The lineHeight is computed from the fontSize if it is 0. // Moreover, the final lineHeight respects the editor zoom level. @@ -1517,8 +1544,8 @@ class EditorLineHeight> extends BaseEditorOption { - public validate(input: number | undefined): number { +class EditorFontSize extends SimpleEditorOption { + public validate(input: any): number { let r = _float(input, this.defaultValue); if (r === 0) { return EDITOR_FONT_DEFAULTS.fontSize; @@ -1536,11 +1563,8 @@ class EditorFontSize //#region fontInfo -class EditorFontInfo> extends BaseEditorOption { - public validate(input: number | undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): FontInfo { +class EditorFontInfo extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo { return env.fontInfo; } } @@ -1549,7 +1573,7 @@ class EditorFontInfo> extends EditorBooleanOption { +class EditorEmptySelectionClipboard extends EditorBooleanOption { public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { return value && env.emptySelectionClipboard; } @@ -1562,17 +1586,15 @@ class EditorEmptySelectionClipboard; class EditorLightbulb> extends BaseEditorOption { - public validate(input: IEditorLightbulbOptions | undefined): ValidEditorLightbulbOptions { - if (typeof input !== 'object') { + public validate(_input: any): ValidEditorLightbulbOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorLightbulbOptions; return { enabled: _boolean(input.enabled, this.defaultValue.enabled) }; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidEditorLightbulbOptions): ValidEditorLightbulbOptions { - return value; - } } //#endregion @@ -1593,11 +1615,12 @@ export interface InternalEditorScrollbarOptions { readonly verticalSliderSize: number; } -class EditorScrollbar> extends BaseEditorOption { - public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions { - if (typeof input !== 'object') { +class EditorScrollbar> extends BaseEditorOption { + public validate(_input: any): InternalEditorScrollbarOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorScrollbarOptions; const horizontalScrollbarSize = _clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000); const verticalScrollbarSize = _clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000); return { @@ -1614,17 +1637,12 @@ class EditorScrollbar>; - export interface InternalSuggestOptions { readonly filterGraceful: boolean; readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; @@ -1636,13 +1654,15 @@ export interface InternalSuggestOptions { readonly filteredTypes: Record; } -class EditorSuggest> extends BaseEditorOption { - public validate(input: ISuggestOptions | undefined): ValidSuggestOptions { - if (typeof input !== 'object') { +class EditorSuggest> extends BaseEditorOption { + public validate(_input: any): InternalSuggestOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as ISuggestOptions; return { filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful), + snippets: EditorOptions.snippetSuggestions.defaultValue, snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful), localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus), shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections), @@ -1651,7 +1671,7 @@ class EditorSuggest> extends BaseEditorOption { - public validate(input: IEditorParameterHintOptions | undefined): InternalParameterHintOptions { - if (typeof input !== 'object') { + public validate(_input: any): InternalParameterHintOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorParameterHintOptions; return { enabled: _boolean(input.enabled, this.defaultValue.enabled), cycle: _boolean(input.cycle, this.defaultValue.cycle) }; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalParameterHintOptions): InternalParameterHintOptions { - return value; - } } //#endregion @@ -1705,10 +1723,11 @@ export interface InternalEditorFindOptions { } class EditorFind> extends BaseEditorOption { - public validate(input: IEditorFindOptions | undefined): InternalEditorFindOptions { - if (typeof input !== 'object') { + public validate(_input: any): InternalEditorFindOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IEditorFindOptions; return { seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection), autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection), @@ -1716,9 +1735,6 @@ class EditorFind> extends BaseEditorOption { - public validate(input: IGotoLocationOptions | undefined): InternalGoToLocationOptions { - if (typeof input !== 'object') { + public validate(_input: any): InternalGoToLocationOptions { + if (typeof _input !== 'object') { return this.defaultValue; } + const input = _input as IGotoLocationOptions; return { multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']) }; } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalGoToLocationOptions): InternalGoToLocationOptions { - return value; - } } //#endregion @@ -1872,11 +1886,8 @@ export interface EditorLayoutInfo { /** * @internal */ -export class EditorLayoutInfoComputer> extends BaseEditorOption { - public validate(input: undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorLayoutInfo { +export class EditorLayoutInfoComputer extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorLayoutInfo): EditorLayoutInfo { const glyphMargin = options.get(EditorOption.glyphMargin); const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars); const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth); @@ -2063,11 +2074,8 @@ export interface EditorWrappingInfo { readonly wrappingColumn: number; } -class EditorWrappingInfoComputer> extends BaseEditorOption { - public validate(input: undefined): undefined { - return undefined; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorWrappingInfo { +class EditorWrappingInfoComputer extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorWrappingInfo): EditorWrappingInfo { const wordWrap = options.get(EditorOption.wordWrap); const wordWrapColumn = options.get(EditorOption.wordWrapColumn); const wordWrapMinified = options.get(EditorOption.wordWrapMinified); @@ -2143,7 +2151,7 @@ function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): */ export const editorOptionsRegistry: IEditorOption[] = []; -function registerEditorOption(option: IEditorOption): IEditorOption { +function registerEditorOption(option: IEditorOption): IEditorOption { editorOptionsRegistry[option.id] = option; return option; } @@ -2256,21 +2264,21 @@ export const enum EditorOption { export const EditorOptions = { acceptSuggestionOnCommitCharacter: registerEditorOption(new EditorBooleanOption(EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true)), - acceptSuggestionOnEnter: registerEditorOption(new EditorEnumOption(EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter', 'on', ['on', 'smart', 'off'], (x: 'on' | 'smart' | 'off') => x)), - accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', 'auto')), - autoClosingBrackets: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingBrackets, 'autoClosingBrackets', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], (x: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never') => x)), - autoClosingOvertype: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto', ['always', 'auto', 'never'], (x: 'always' | 'auto' | 'never') => x)), - autoClosingQuotes: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingQuotes, 'autoClosingQuotes', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], (x: 'always' | 'languageDefined' | 'beforeWhitespace' | 'never') => x)), + acceptSuggestionOnEnter: registerEditorOption(new EditorStringEnumOption(EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter', 'on' as 'on' | 'smart' | 'off', ['on', 'smart', 'off'] as const)), + accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', AccessibilitySupport.Unknown)), + autoClosingBrackets: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingBrackets, 'autoClosingBrackets', 'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never', ['always', 'languageDefined', 'beforeWhitespace', 'never'] as const)), + autoClosingOvertype: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto' as 'always' | 'auto' | 'never', ['always', 'auto', 'never'] as const)), + autoClosingQuotes: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingQuotes, 'autoClosingQuotes', 'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never', ['always', 'languageDefined', 'beforeWhitespace', 'never'] as const)), autoIndent: registerEditorOption(new EditorBooleanOption(EditorOption.autoIndent, 'autoIndent', true)), automaticLayout: registerEditorOption(new EditorBooleanOption(EditorOption.automaticLayout, 'automaticLayout', false)), - autoSurround: registerEditorOption(new EditorEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined', ['languageDefined', 'quotes', 'brackets', 'never'], (x: 'languageDefined' | 'quotes' | 'brackets' | 'never') => x)), + autoSurround: registerEditorOption(new EditorStringEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined' as 'languageDefined' | 'quotes' | 'brackets' | 'never', ['languageDefined', 'quotes', 'brackets', 'never'] as const)), codeLens: registerEditorOption(new EditorBooleanOption(EditorOption.codeLens, 'codeLens', true)), colorDecorators: registerEditorOption(new EditorBooleanOption(EditorOption.colorDecorators, 'colorDecorators', true)), contextmenu: registerEditorOption(new EditorBooleanOption(EditorOption.contextmenu, 'contextmenu', true)), copyWithSyntaxHighlighting: registerEditorOption(new EditorBooleanOption(EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true)), - cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', 'blink', ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)), + cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', TextEditorCursorBlinkingStyle.Blink, ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)), cursorSmoothCaretAnimation: registerEditorOption(new EditorBooleanOption(EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false)), - cursorStyle: registerEditorOption(new EditorEnumOption(EditorOption.cursorStyle, 'cursorStyle', 'line', ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString)), + cursorStyle: registerEditorOption(new EditorEnumOption(EditorOption.cursorStyle, 'cursorStyle', TextEditorCursorStyle.Line, ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString)), cursorSurroundingLines: registerEditorOption(new EditorIntOption(EditorOption.cursorSurroundingLines, 'cursorSurroundingLines', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)), cursorWidth: registerEditorOption(new EditorIntOption(EditorOption.cursorWidth, 'cursorWidth', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)), disableLayerHinting: registerEditorOption(new EditorBooleanOption(EditorOption.disableLayerHinting, 'disableLayerHinting', false)), @@ -2286,9 +2294,9 @@ export const EditorOptions = { })), fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)), folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)), - foldingStrategy: registerEditorOption(new EditorEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto', ['auto', 'indentation'], (x: 'auto' | 'indentation') => x)), + foldingStrategy: registerEditorOption(new EditorStringEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto' as 'auto' | 'indentation', ['auto', 'indentation'] as const)), fontFamily: registerEditorOption(new EditorStringOption(EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily)), - fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo, 'fontInfo', undefined)), + fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo)), fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), fontSize: registerEditorOption(new EditorFontSize(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize)), fontWeight: registerEditorOption(new EditorStringOption(EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight)), @@ -2310,7 +2318,7 @@ export const EditorOptions = { lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', { enabled: true })), - lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)), + lineDecorationsWidth: registerEditorOption(new SimpleEditorOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10 as number | string)), lineHeight: registerEditorOption(new EditorLineHeight(EditorOption.lineHeight, 'lineHeight', EDITOR_FONT_DEFAULTS.lineHeight, 0, 150)), lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })), lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)), @@ -2323,11 +2331,11 @@ export const EditorOptions = { renderCharacters: true, maxColumn: 120, })), - mouseStyle: registerEditorOption(new EditorEnumOption(EditorOption.mouseStyle, 'mouseStyle', 'text', ['text', 'default', 'copy'], (x: 'text' | 'default' | 'copy') => x)), + mouseStyle: registerEditorOption(new EditorStringEnumOption(EditorOption.mouseStyle, 'mouseStyle', 'text' as 'text' | 'default' | 'copy', ['text', 'default', 'copy'] as const)), mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))), mouseWheelZoom: registerEditorOption(new EditorBooleanOption(EditorOption.mouseWheelZoom, 'mouseWheelZoom', false)), multiCursorMergeOverlapping: registerEditorOption(new EditorBooleanOption(EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true)), - multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'alt', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)), + multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'altKey', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)), occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)), overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)), overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)), @@ -2345,8 +2353,8 @@ export const EditorOptions = { renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)), renderIndentGuides: registerEditorOption(new EditorBooleanOption(EditorOption.renderIndentGuides, 'renderIndentGuides', true)), renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOption.renderFinalNewline, 'renderFinalNewline', true)), - renderLineHighlight: registerEditorOption(new EditorEnumOption(EditorOption.renderLineHighlight, 'renderLineHighlight', 'line', ['none', 'gutter', 'line', 'all'], (x: 'none' | 'gutter' | 'line' | 'all') => x)), - renderWhitespace: registerEditorOption(new EditorEnumOption(EditorOption.renderWhitespace, 'renderWhitespace', 'none', ['none', 'boundary', 'selection', 'all'], (x: 'none' | 'boundary' | 'selection' | 'all') => x)), + renderLineHighlight: registerEditorOption(new EditorStringEnumOption(EditorOption.renderLineHighlight, 'renderLineHighlight', 'line' as 'none' | 'gutter' | 'line' | 'all', ['none', 'gutter', 'line', 'all'] as const)), + renderWhitespace: registerEditorOption(new EditorStringEnumOption(EditorOption.renderWhitespace, 'renderWhitespace', 'none' as 'none' | 'boundary' | 'selection' | 'all', ['none', 'boundary', 'selection', 'all'] as const)), revealHorizontalRightPadding: registerEditorOption(new EditorIntOption(EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding', 30, 0, 1000)), roundedSelection: registerEditorOption(new EditorBooleanOption(EditorOption.roundedSelection, 'roundedSelection', true)), rulers: registerEditorOption(new EditorRulers(EditorOption.rulers, 'rulers', [])), @@ -2368,34 +2376,35 @@ export const EditorOptions = { selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)), selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)), selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)), - showFoldingControls: registerEditorOption(new EditorEnumOption(EditorOption.showFoldingControls, 'showFoldingControls', 'mouseover', ['always', 'mouseover'], (x: 'always' | 'mouseover') => x)), + showFoldingControls: registerEditorOption(new EditorStringEnumOption(EditorOption.showFoldingControls, 'showFoldingControls', 'mouseover' as 'always' | 'mouseover', ['always', 'mouseover'] as const)), showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)), - snippetSuggestions: registerEditorOption(new EditorEnumOption(EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline', ['top', 'bottom', 'inline', 'none'], x => x)), + snippetSuggestions: registerEditorOption(new EditorStringEnumOption(EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline' as 'top' | 'bottom' | 'inline' | 'none', ['top', 'bottom', 'inline', 'none'] as const)), smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)), stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)), suggestFontSize: registerEditorOption(new EditorIntOption(EditorOption.suggestFontSize, 'suggestFontSize', 0, 0, 1000)), suggestLineHeight: registerEditorOption(new EditorIntOption(EditorOption.suggestLineHeight, 'suggestLineHeight', 0, 0, 1000)), suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)), - suggestSelection: registerEditorOption(new EditorEnumOption(EditorOption.suggestSelection, 'suggestSelection', 'recentlyUsed', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'], (x: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix') => x)), - tabCompletion: registerEditorOption(new EditorEnumOption(EditorOption.tabCompletion, 'tabCompletion', 'off', ['on', 'off', 'onlySnippets'], (x: 'on' | 'off' | 'onlySnippets') => x)), + suggestSelection: registerEditorOption(new EditorStringEnumOption(EditorOption.suggestSelection, 'suggestSelection', 'recentlyUsed' as 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'] as const)), + tabCompletion: registerEditorOption(new EditorStringEnumOption(EditorOption.tabCompletion, 'tabCompletion', 'off' as 'on' | 'off' | 'onlySnippets', ['on', 'off', 'onlySnippets'] as const)), useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)), wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)), - wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], (x: 'off' | 'on' | 'wordWrapColumn' | 'bounded') => x)), + wordWrap: registerEditorOption(new EditorStringEnumOption(EditorOption.wordWrap, 'wordWrap', 'off' as 'off' | 'on' | 'wordWrapColumn' | 'bounded', ['off', 'on', 'wordWrapColumn', 'bounded'] as const)), wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')), wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')), wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')), wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)), wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)), - wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), + wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', WrappingIndent.Same, ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)), // Leave these at the end (because they have dependencies!) ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])), disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])), - editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])), - pixelRatio: registerEditorOption(new EditorPixelRatio(EditorOption.pixelRatio, 'pixelRatio', undefined)), - tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])), + editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])), + pixelRatio: registerEditorOption(new EditorPixelRatio(EditorOption.pixelRatio)), + tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, [EditorOption.readOnly])), suggest: registerEditorOption(new EditorSuggest(EditorOption.suggest, 'suggest', { filterGraceful: true, + snippets: 'inline', snippetsPreventQuickSuggestions: true, localityBonus: false, shareSuggestSelections: false, @@ -2403,11 +2412,11 @@ export const EditorOptions = { maxVisibleSuggestions: 12, filteredTypes: Object.create(null) }, [EditorOption.snippetSuggestions])), - layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])), - wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), + layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])), + wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])), }; export type EditorOptionsType = typeof EditorOptions; export type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; -export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; +export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; export type FindComputedEditorOptionValueById = NonNullable]>>; diff --git a/src/vs/editor/editor.api.ts b/src/vs/editor/editor.api.ts index a4e36c33fe0be..5989b9a09eb95 100644 --- a/src/vs/editor/editor.api.ts +++ b/src/vs/editor/editor.api.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { EditorOptions } from 'vs/editor/common/config/editorOptions'; +import { EditorOptions, WrappingIndent } from 'vs/editor/common/config/editorOptions'; import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase'; import { createMonacoEditorAPI } from 'vs/editor/standalone/browser/standaloneEditor'; import { createMonacoLanguagesAPI } from 'vs/editor/standalone/browser/standaloneLanguages'; @@ -11,7 +11,7 @@ import { createMonacoLanguagesAPI } from 'vs/editor/standalone/browser/standalon const global: any = self; // Set defaults for standalone editor -(EditorOptions.wrappingIndent).defaultValue = 'none'; +(EditorOptions.wrappingIndent).defaultValue = WrappingIndent.None; (EditorOptions.glyphMargin).defaultValue = false; (EditorOptions.autoIndent).defaultValue = false; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index b6afdd0aafb59..c698ce3ad5a69 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3284,10 +3284,10 @@ declare namespace monaco.editor { get(id: T): FindComputedEditorOptionValueById; } - export interface IEditorOption, T3 = T2> { + export interface IEditorOption { readonly id: K1; - readonly name: K2; - readonly defaultValue: T2; + readonly name: string; + readonly defaultValue: V; } export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); @@ -3337,8 +3337,6 @@ declare namespace monaco.editor { readonly verticalSliderSize: number; } - export type ValidSuggestOptions = Readonly>; - export interface InternalSuggestOptions { readonly filterGraceful: boolean; readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; @@ -3590,108 +3588,108 @@ declare namespace monaco.editor { } export const EditorOptions: { - acceptSuggestionOnCommitCharacter: IEditorOption; - acceptSuggestionOnEnter: IEditorOption; - accessibilitySupport: IEditorOption; - autoClosingBrackets: IEditorOption; - autoClosingOvertype: IEditorOption; - autoClosingQuotes: IEditorOption; - autoIndent: IEditorOption; - automaticLayout: IEditorOption; - autoSurround: IEditorOption; - codeLens: IEditorOption; - colorDecorators: IEditorOption; - contextmenu: IEditorOption; - copyWithSyntaxHighlighting: IEditorOption; - cursorBlinking: IEditorOption; - cursorSmoothCaretAnimation: IEditorOption; - cursorStyle: IEditorOption; - cursorSurroundingLines: IEditorOption; - cursorWidth: IEditorOption; - disableLayerHinting: IEditorOption; - dragAndDrop: IEditorOption; - emptySelectionClipboard: IEditorOption; - extraEditorClassName: IEditorOption; - fastScrollSensitivity: IEditorOption; - find: IEditorOption; - fixedOverflowWidgets: IEditorOption; - folding: IEditorOption; - foldingStrategy: IEditorOption; - fontFamily: IEditorOption; - fontInfo: IEditorOption; - fontLigatures: IEditorOption; - fontSize: IEditorOption; - fontWeight: IEditorOption; - formatOnPaste: IEditorOption; - formatOnType: IEditorOption; - glyphMargin: IEditorOption; - gotoLocation: IEditorOption; - hideCursorInOverviewRuler: IEditorOption; - highlightActiveIndentGuide: IEditorOption; - hover: IEditorOption; - inDiffEditor: IEditorOption; - letterSpacing: IEditorOption; - lightbulb: IEditorOption; - lineDecorationsWidth: IEditorOption; - lineHeight: IEditorOption; - lineNumbers: IEditorOption; - lineNumbersMinChars: IEditorOption; - links: IEditorOption; - matchBrackets: IEditorOption; - minimap: IEditorOption; - mouseStyle: IEditorOption; - mouseWheelScrollSensitivity: IEditorOption; - mouseWheelZoom: IEditorOption; - multiCursorMergeOverlapping: IEditorOption; - multiCursorModifier: IEditorOption; - occurrencesHighlight: IEditorOption; - overviewRulerBorder: IEditorOption; - overviewRulerLanes: IEditorOption; - parameterHints: IEditorOption; - quickSuggestions: IEditorOption; - quickSuggestionsDelay: IEditorOption; - readOnly: IEditorOption; - renderControlCharacters: IEditorOption; - renderIndentGuides: IEditorOption; - renderFinalNewline: IEditorOption; - renderLineHighlight: IEditorOption; - renderWhitespace: IEditorOption; - revealHorizontalRightPadding: IEditorOption; - roundedSelection: IEditorOption; - rulers: IEditorOption; - scrollbar: IEditorOption; - scrollBeyondLastColumn: IEditorOption; - scrollBeyondLastLine: IEditorOption; - selectionClipboard: IEditorOption; - selectionHighlight: IEditorOption; - selectOnLineNumbers: IEditorOption; - showFoldingControls: IEditorOption; - showUnused: IEditorOption; - snippetSuggestions: IEditorOption; - smoothScrolling: IEditorOption; - stopRenderingLineAfter: IEditorOption; - suggestFontSize: IEditorOption; - suggestLineHeight: IEditorOption; - suggestOnTriggerCharacters: IEditorOption; - suggestSelection: IEditorOption; - tabCompletion: IEditorOption; - useTabStops: IEditorOption; - wordSeparators: IEditorOption; - wordWrap: IEditorOption; - wordWrapBreakAfterCharacters: IEditorOption; - wordWrapBreakBeforeCharacters: IEditorOption; - wordWrapBreakObtrusiveCharacters: IEditorOption; - wordWrapColumn: IEditorOption; - wordWrapMinified: IEditorOption; - wrappingIndent: IEditorOption; - ariaLabel: IEditorOption; - disableMonospaceOptimizations: IEditorOption; - editorClassName: IEditorOption; - pixelRatio: IEditorOption; - tabFocusMode: IEditorOption; - suggest: IEditorOption; - layoutInfo: IEditorOption; - wrappingInfo: IEditorOption; + acceptSuggestionOnCommitCharacter: IEditorOption; + acceptSuggestionOnEnter: IEditorOption; + accessibilitySupport: IEditorOption; + autoClosingBrackets: IEditorOption; + autoClosingOvertype: IEditorOption; + autoClosingQuotes: IEditorOption; + autoIndent: IEditorOption; + automaticLayout: IEditorOption; + autoSurround: IEditorOption; + codeLens: IEditorOption; + colorDecorators: IEditorOption; + contextmenu: IEditorOption; + copyWithSyntaxHighlighting: IEditorOption; + cursorBlinking: IEditorOption; + cursorSmoothCaretAnimation: IEditorOption; + cursorStyle: IEditorOption; + cursorSurroundingLines: IEditorOption; + cursorWidth: IEditorOption; + disableLayerHinting: IEditorOption; + dragAndDrop: IEditorOption; + emptySelectionClipboard: IEditorOption; + extraEditorClassName: IEditorOption; + fastScrollSensitivity: IEditorOption; + find: IEditorOption; + fixedOverflowWidgets: IEditorOption; + folding: IEditorOption; + foldingStrategy: IEditorOption; + fontFamily: IEditorOption; + fontInfo: IEditorOption; + fontLigatures: IEditorOption; + fontSize: IEditorOption; + fontWeight: IEditorOption; + formatOnPaste: IEditorOption; + formatOnType: IEditorOption; + glyphMargin: IEditorOption; + gotoLocation: IEditorOption; + hideCursorInOverviewRuler: IEditorOption; + highlightActiveIndentGuide: IEditorOption; + hover: IEditorOption; + inDiffEditor: IEditorOption; + letterSpacing: IEditorOption; + lightbulb: IEditorOption; + lineDecorationsWidth: IEditorOption; + lineHeight: IEditorOption; + lineNumbers: IEditorOption; + lineNumbersMinChars: IEditorOption; + links: IEditorOption; + matchBrackets: IEditorOption; + minimap: IEditorOption; + mouseStyle: IEditorOption; + mouseWheelScrollSensitivity: IEditorOption; + mouseWheelZoom: IEditorOption; + multiCursorMergeOverlapping: IEditorOption; + multiCursorModifier: IEditorOption; + occurrencesHighlight: IEditorOption; + overviewRulerBorder: IEditorOption; + overviewRulerLanes: IEditorOption; + parameterHints: IEditorOption; + quickSuggestions: IEditorOption; + quickSuggestionsDelay: IEditorOption; + readOnly: IEditorOption; + renderControlCharacters: IEditorOption; + renderIndentGuides: IEditorOption; + renderFinalNewline: IEditorOption; + renderLineHighlight: IEditorOption; + renderWhitespace: IEditorOption; + revealHorizontalRightPadding: IEditorOption; + roundedSelection: IEditorOption; + rulers: IEditorOption; + scrollbar: IEditorOption; + scrollBeyondLastColumn: IEditorOption; + scrollBeyondLastLine: IEditorOption; + selectionClipboard: IEditorOption; + selectionHighlight: IEditorOption; + selectOnLineNumbers: IEditorOption; + showFoldingControls: IEditorOption; + showUnused: IEditorOption; + snippetSuggestions: IEditorOption; + smoothScrolling: IEditorOption; + stopRenderingLineAfter: IEditorOption; + suggestFontSize: IEditorOption; + suggestLineHeight: IEditorOption; + suggestOnTriggerCharacters: IEditorOption; + suggestSelection: IEditorOption; + tabCompletion: IEditorOption; + useTabStops: IEditorOption; + wordSeparators: IEditorOption; + wordWrap: IEditorOption; + wordWrapBreakAfterCharacters: IEditorOption; + wordWrapBreakBeforeCharacters: IEditorOption; + wordWrapBreakObtrusiveCharacters: IEditorOption; + wordWrapColumn: IEditorOption; + wordWrapMinified: IEditorOption; + wrappingIndent: IEditorOption; + ariaLabel: IEditorOption; + disableMonospaceOptimizations: IEditorOption; + editorClassName: IEditorOption; + pixelRatio: IEditorOption; + tabFocusMode: IEditorOption; + suggest: IEditorOption; + layoutInfo: IEditorOption; + wrappingInfo: IEditorOption; }; export type EditorOptionsType = typeof EditorOptions; @@ -3700,7 +3698,7 @@ declare namespace monaco.editor { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never; }[keyof EditorOptionsType]; - export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; + export type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; export type FindComputedEditorOptionValueById = NonNullable]>>; From 45017f34b0259f5601311fb397b05e86e7bb73e9 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 6 Sep 2019 11:19:32 +0200 Subject: [PATCH 127/204] IndexTreeModel: complete setCollapsible() related to #78388 --- src/vs/base/browser/ui/tree/indexTreeModel.ts | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/vs/base/browser/ui/tree/indexTreeModel.ts b/src/vs/base/browser/ui/tree/indexTreeModel.ts index de1f03d3b37de..359b4ff4e065e 100644 --- a/src/vs/base/browser/ui/tree/indexTreeModel.ts +++ b/src/vs/base/browser/ui/tree/indexTreeModel.ts @@ -210,13 +210,9 @@ export class IndexTreeModel, TFilterData = voi if (typeof collapsible === 'undefined') { collapsible = !node.collapsible; - } else if (node.collapsible === collapsible) { - return false; } - node.collapsible = collapsible; - this.eventBufferer.bufferEvents(() => this._setCollapsed(location, node.collapsed)); - return true; + return this.eventBufferer.bufferEvents(() => this._setCollapseState(location, collapsible!, node.collapsed)); } isCollapsed(location: number[]): boolean { @@ -230,13 +226,13 @@ export class IndexTreeModel, TFilterData = voi collapsed = !node.collapsed; } - return this.eventBufferer.bufferEvents(() => this._setCollapsed(location, collapsed!, recursive)); + return this.eventBufferer.bufferEvents(() => this._setCollapseState(location, node.collapsible, collapsed!, recursive)); } - private _setCollapsed(location: number[], collapsed: boolean, recursive?: boolean): boolean { + private _setCollapseState(location: number[], collapsible: boolean, collapsed: boolean, recursive?: boolean): boolean { const { node, listIndex, revealed } = this.getTreeNodeWithListIndex(location); - const result = this._setListNodeCollapsed(node, listIndex, revealed, collapsed!, recursive || false); + const result = this._setListNodeCollapseState(node, listIndex, revealed, collapsible, collapsed, recursive || false); if (node !== this.root && this.autoExpandSingleChildren && !collapsed! && !recursive) { let onlyVisibleChildIndex = -1; @@ -255,15 +251,15 @@ export class IndexTreeModel, TFilterData = voi } if (onlyVisibleChildIndex > -1) { - this._setCollapsed([...location, onlyVisibleChildIndex], false, false); + this._setCollapseState([...location, onlyVisibleChildIndex], false, false); } } return result; } - private _setListNodeCollapsed(node: IMutableTreeNode, listIndex: number, revealed: boolean, collapsed: boolean, recursive: boolean): boolean { - const result = this._setNodeCollapsed(node, collapsed, recursive, false); + private _setListNodeCollapseState(node: IMutableTreeNode, listIndex: number, revealed: boolean, collapsible: boolean, collapsed: boolean, recursive: boolean): boolean { + const result = this._setNodeCollapseState(node, collapsible, collapsed, recursive, false); if (!revealed || !node.visible) { return result; @@ -277,20 +273,19 @@ export class IndexTreeModel, TFilterData = voi return result; } - private _setNodeCollapsed(node: IMutableTreeNode, collapsed: boolean, recursive: boolean, deep: boolean): boolean { - let result = node.collapsible && node.collapsed !== collapsed; + private _setNodeCollapseState(node: IMutableTreeNode, collapsible: boolean, collapsed: boolean, recursive: boolean, deep: boolean): boolean { + let result = node.collapsible !== collapsible || node.collapsed !== collapsed; - if (node.collapsible) { - node.collapsed = collapsed; + node.collapsible = collapsible; + node.collapsed = collapsed; - if (result) { - this._onDidChangeCollapseState.fire({ node, deep }); - } + if (result) { + this._onDidChangeCollapseState.fire({ node, deep }); } if (recursive) { for (const child of node.children) { - result = this._setNodeCollapsed(child, collapsed, true, true) || result; + result = this._setNodeCollapseState(child, collapsible, collapsed, true, true) || result; } } @@ -306,7 +301,7 @@ export class IndexTreeModel, TFilterData = voi location = location.slice(0, location.length - 1); if (node.collapsed) { - this._setCollapsed(location, false); + this._setCollapseState(location, node.collapsible, false); } } }); From b01cb4f8c05bdcfe499ca8162d3bce7050efd28c Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 6 Sep 2019 11:51:06 +0200 Subject: [PATCH 128/204] Fix default value --- src/vs/editor/common/config/editorOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index af15232a310db..5fbca25c2a8f6 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -2297,7 +2297,7 @@ export const EditorOptions = { foldingStrategy: registerEditorOption(new EditorStringEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto' as 'auto' | 'indentation', ['auto', 'indentation'] as const)), fontFamily: registerEditorOption(new EditorStringOption(EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily)), fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo)), - fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)), + fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', false)), fontSize: registerEditorOption(new EditorFontSize(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize)), fontWeight: registerEditorOption(new EditorStringOption(EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight)), formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)), From f6daf19f9a4ea3877457d16528d44dbb7cc579eb Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 6 Sep 2019 11:53:05 +0200 Subject: [PATCH 129/204] debt - remove unused service workr --- build/gulpfile.vscode.js | 1 - build/gulpfile.vscode.web.js | 1 - src/buildfile.js | 8 - .../browser/resourceServiceWorker.ts | 137 ------------------ .../browser/resourceServiceWorkerClient.ts | 36 ----- .../browser/resourceServiceWorkerMain.ts | 26 ---- src/vs/workbench/workbench.web.main.ts | 3 - 7 files changed, 212 deletions(-) delete mode 100644 src/vs/workbench/contrib/resources/browser/resourceServiceWorker.ts delete mode 100644 src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts delete mode 100644 src/vs/workbench/contrib/resources/browser/resourceServiceWorkerMain.ts diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index c891b8f48e021..3e97ef2fe3b8b 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -49,7 +49,6 @@ const nodeModules = ['electron', 'original-fs'] const vscodeEntryPoints = _.flatten([ buildfile.entrypoint('vs/workbench/workbench.desktop.main'), buildfile.base, - buildfile.serviceWorker, buildfile.workbenchDesktop, buildfile.code ]); diff --git a/build/gulpfile.vscode.web.js b/build/gulpfile.vscode.web.js index 1c21e3cd5a357..8f2e9c9f5a252 100644 --- a/build/gulpfile.vscode.web.js +++ b/build/gulpfile.vscode.web.js @@ -56,7 +56,6 @@ const buildfile = require('../src/buildfile'); const vscodeWebEntryPoints = _.flatten([ buildfile.entrypoint('vs/workbench/workbench.web.api'), buildfile.base, - buildfile.serviceWorker, buildfile.workerExtensionHost, buildfile.keyboardMaps, buildfile.workbenchWeb diff --git a/src/buildfile.js b/src/buildfile.js index 684954a321927..2df9bf24e732f 100644 --- a/src/buildfile.js +++ b/src/buildfile.js @@ -15,14 +15,6 @@ exports.base = [{ dest: 'vs/base/worker/workerMain.js' }]; -exports.serviceWorker = [{ - name: 'vs/workbench/contrib/resources/browser/resourceServiceWorker', - // include: ['vs/editor/common/services/editorSimpleWorker'], - prepend: ['vs/loader.js'], - append: ['vs/workbench/contrib/resources/browser/resourceServiceWorkerMain'], - dest: 'vs/workbench/contrib/resources/browser/resourceServiceWorkerMain.js' -}]; - exports.workerExtensionHost = [entrypoint('vs/workbench/services/extensions/worker/extensionHostWorker')]; exports.workbenchDesktop = require('./vs/workbench/buildfile.desktop').collectModules(); diff --git a/src/vs/workbench/contrib/resources/browser/resourceServiceWorker.ts b/src/vs/workbench/contrib/resources/browser/resourceServiceWorker.ts deleted file mode 100644 index dfad93af11f0a..0000000000000 --- a/src/vs/workbench/contrib/resources/browser/resourceServiceWorker.ts +++ /dev/null @@ -1,137 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { URI } from 'vs/base/common/uri'; - -//#region --- lib.webworker.d.ts madness --- - -interface ExtendableEvent extends Event { - waitUntil(f: any): void; -} - -interface FetchEvent extends ExtendableEvent { - readonly clientId: string; - readonly preloadResponse: Promise; - readonly replacesClientId: string; - readonly request: Request; - readonly resultingClientId: string; - respondWith(r: Response | Promise): void; -} -interface ExtendableMessageEvent extends ExtendableEvent { - readonly data: any; - readonly lastEventId: string; - readonly origin: string; - readonly ports: ReadonlyArray; - readonly source: ServiceWorker | MessagePort | null; -} - -interface ServiceWorkerGlobalScopeEventMap { - 'activate': ExtendableEvent; - 'fetch': FetchEvent; - 'install': ExtendableEvent; - 'message': ExtendableMessageEvent; - 'messageerror': MessageEvent; -} - -interface Clients { - claim(): Promise; - get(id: string): Promise; -} - -interface ServiceWorkerGlobalScope { - readonly clients: Clients; - onactivate: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; - onfetch: ((this: ServiceWorkerGlobalScope, ev: FetchEvent) => any) | null; - oninstall: ((this: ServiceWorkerGlobalScope, ev: ExtendableEvent) => any) | null; - onmessage: ((this: ServiceWorkerGlobalScope, ev: ExtendableMessageEvent) => any) | null; - onmessageerror: ((this: ServiceWorkerGlobalScope, ev: MessageEvent) => any) | null; - readonly registration: ServiceWorkerRegistration; - skipWaiting(): Promise; - addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -//#endregion - -declare var self: ServiceWorkerGlobalScope; - -//#region --- installing/activating - -self.addEventListener('install', _event => { - console.log('SW#install'); - self.skipWaiting(); -}); - -self.addEventListener('activate', event => { - console.log('SW#activate'); - event.waitUntil((async () => { - // (1) enable navigation preloads! - // (2) delete caches with each new version - // (3) become available to all pages - if (self.registration.navigationPreload) { - await self.registration.navigationPreload.enable(); - } - await caches.delete(_cacheName); - await self.clients.claim(); - })()); -}); - -//#endregion - -//#region --- fetching/caching - -const _cacheName = 'vscode-extension-resources'; -const _resourcePrefix = '/vscode-remote-resource'; -const _pendingFetch = new Map(); - -self.addEventListener('message', event => { - const fn = _pendingFetch.get(event.data.token); - if (fn) { - fn(event.data.data, event.data.isExtensionResource); - _pendingFetch.delete(event.data.token); - } -}); - -self.addEventListener('fetch', async (event: FetchEvent) => { - - const uri = URI.parse(event.request.url); - if (uri.path !== _resourcePrefix) { - // not a /vscode-resources/fetch-url and therefore - // not (yet?) interesting for us - event.respondWith(respondWithDefault(event)); - return; - } - - event.respondWith(respondWithResource(event, uri)); -}); - -async function respondWithDefault(event: FetchEvent): Promise { - if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') { - // https://bugs.chromium.org/p/chromium/issues/detail?id=823392 - // https://stackoverflow.com/questions/48463483/what-causes-a-failed-to-execute-fetch-on-serviceworkerglobalscope-only-if#49719964 - // https://developer.mozilla.org/en-US/docs/Web/API/Request/cache - return new Response(undefined, { status: 504, statusText: 'Gateway Timeout (dev tools: https://bugs.chromium.org/p/chromium/issues/detail?id=823392)' }); - } - return await event.preloadResponse || await fetch(event.request); -} - -async function respondWithResource(event: FetchEvent, uri: URI): Promise { - - const cachedValue = await caches.open(_cacheName).then(cache => cache.match(event.request)); - if (cachedValue) { - return cachedValue; - } - - const response: Response = await event.preloadResponse || await fetch(event.request); - if (response.headers.get('X-VSCode-Extension') === 'true') { - await caches.open(_cacheName).then(cache => cache.put(event.request, response.clone())); - } - - return response; -} - -//#endregion diff --git a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts b/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts deleted file mode 100644 index 935753f002de4..0000000000000 --- a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerClient.ts +++ /dev/null @@ -1,36 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Registry } from 'vs/platform/registry/common/platform'; -import { IWorkbenchContributionsRegistry, Extensions } from 'vs/workbench/common/contributions'; -import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; -import { ILogService } from 'vs/platform/log/common/log'; - -class ResourceServiceWorker { - - private static _url = require.toUrl('./resourceServiceWorkerMain.js'); - - constructor( - @ILogService private readonly _logService: ILogService, - ) { - navigator.serviceWorker.register(ResourceServiceWorker._url, { scope: '/' }).then(reg => { - this._logService.trace('SW#reg', reg); - return reg.update(); - }).then(() => { - this._logService.info('SW#ready'); - }).catch(err => { - this._logService.error('SW#init', err); - }); - - } - -} - -Registry.as(Extensions.Workbench).registerWorkbenchContribution( - ResourceServiceWorker, - LifecyclePhase.Ready -); - - diff --git a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerMain.ts b/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerMain.ts deleted file mode 100644 index 89e7d32eae6d6..0000000000000 --- a/src/vs/workbench/contrib/resources/browser/resourceServiceWorkerMain.ts +++ /dev/null @@ -1,26 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -// This file is to bootstrap AMD so that we can program as usual -// Note the fetch, install, activate event handler must be registered -// when loading the service worker and despite AMD's async nature this -// works. That's because the/our AMD loader uses the sync importScripts -// statement. - -// trigger service worker updates -const _tag = '23549971-9b8d-41bb-92ae-d7f6a68c9702'; - -// loader world -const baseUrl = '../../../../../'; -importScripts(baseUrl + 'vs/loader.js'); -require.config({ - baseUrl, - catchError: true -}); -require(['vs/workbench/contrib/resources/browser/resourceServiceWorker'], - () => { }, - err => console.error(err) -); - diff --git a/src/vs/workbench/workbench.web.main.ts b/src/vs/workbench/workbench.web.main.ts index 681fc606b6a86..e67d61f7e0e48 100644 --- a/src/vs/workbench/workbench.web.main.ts +++ b/src/vs/workbench/workbench.web.main.ts @@ -72,9 +72,6 @@ registerSingleton(IContextMenuService, ContextMenuService); //#region --- workbench contributions -// Resource Service Worker -import 'vs/workbench/contrib/resources/browser/resourceServiceWorkerClient'; - // Preferences import 'vs/workbench/contrib/preferences/browser/keyboardLayoutPicker'; From 503c36d979e1a500dc1a2f2c1551b9d0c0aafd51 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 6 Sep 2019 12:01:14 +0200 Subject: [PATCH 130/204] update distro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9310251ecc126..e6ff2b3d5976c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-oss-dev", "version": "1.39.0", - "distro": "dd0b9cd1073431de0640a4b0e1a5ba2b49e00658", + "distro": "d96ea42b7a10d74b39f24074941435688a1317fc", "author": { "name": "Microsoft Corporation" }, From 61d0aa4d05cd09cb56c2963d37870c11ca52eaf5 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 6 Sep 2019 12:05:51 +0200 Subject: [PATCH 131/204] Fix tests --- src/vs/editor/test/browser/testCodeEditor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/test/browser/testCodeEditor.ts b/src/vs/editor/test/browser/testCodeEditor.ts index bf7ceae25a5f5..39a84d3acb260 100644 --- a/src/vs/editor/test/browser/testCodeEditor.ts +++ b/src/vs/editor/test/browser/testCodeEditor.ts @@ -91,7 +91,12 @@ export function withTestCodeEditor(text: string | string[] | null, options: Test export function createTestCodeEditor(options: TestCodeEditorCreationOptions): TestCodeEditor { + const model = options.model; + delete options.model; + const services: ServiceCollection = options.serviceCollection || new ServiceCollection(); + delete options.serviceCollection; + const instantiationService: IInstantiationService = new InstantiationService(services); if (!services.has(ICodeEditorService)) { @@ -119,6 +124,6 @@ export function createTestCodeEditor(options: TestCodeEditorCreationOptions): Te options, codeEditorWidgetOptions ); - editor.setModel(options.model); + editor.setModel(model); return editor; } From 292f3ab2852269e192e13751c76993404e15b07d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 6 Sep 2019 12:20:25 +0200 Subject: [PATCH 132/204] Reorder options --- src/vs/editor/common/config/editorOptions.ts | 796 +++++++++--------- .../common/standalone/standaloneEnums.ts | 60 +- src/vs/monaco.d.ts | 224 +++-- 3 files changed, 518 insertions(+), 562 deletions(-) diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 5fbca25c2a8f6..f736287cc76c7 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -143,7 +143,7 @@ export interface IEditorMinimapOptions { } /** - * Configuration options for editor minimap + * Configuration options for editor lightbulb */ export interface IEditorLightbulbOptions { /** @@ -190,6 +190,9 @@ export interface IEditorParameterHintOptions { cycle?: boolean; } +/** + * Configuration options for editor suggest widget + */ export interface ISuggestOptions { /** * Enable graceful matching. Defaults to true. @@ -221,6 +224,9 @@ export interface ISuggestOptions { filteredTypes?: Record; } +/** + * Configuration options for go to location + */ export interface IGotoLocationOptions { /** * Control how goto-command work when having multiple results. @@ -228,6 +234,9 @@ export interface IGotoLocationOptions { multiple?: 'peek' | 'gotoAndPeek' | 'goto'; } +/** + * Configuration options for quick suggestions + */ export interface IQuickSuggestionsOptions { other: boolean; comments: boolean; @@ -716,33 +725,6 @@ export interface IEditorOptions { showUnused?: boolean; } -export type IExtendedEditorOptions = IEditorOptions & { - /** - * Do not use, this is a computed option. - */ - editorClassName?: undefined; - /** - * Do not use, this is a computed option. - */ - pixelRatio?: undefined; - /** - * Do not use, this is a computed option. - */ - fontInfo?: undefined; - /** - * Do not use, this is a computed option. - */ - tabFocusMode?: undefined; - /** - * Do not use, this is a computed option. - */ - layoutInfo?: undefined; - /** - * Do not use, this is a computed option. - */ - wrappingInfo?: undefined; -}; - /** * Configuration options for the diff editor. */ @@ -774,36 +756,6 @@ export interface IDiffEditorOptions extends IEditorOptions { originalEditable?: boolean; } -export const enum RenderMinimap { - None = 0, - Small = 1, - Large = 2, - SmallBlocks = 3, - LargeBlocks = 4, -} - -/** - * Describes how to indent wrapped lines. - */ -export const enum WrappingIndent { - /** - * No indentation => wrapped lines begin at column 1. - */ - None = 0, - /** - * Same => wrapped lines get the same indentation as the parent. - */ - Same = 1, - /** - * Indent => wrapped lines get +1 indentation toward the parent. - */ - Indent = 2, - /** - * DeepIndent => wrapped lines get +2 indentation toward the parent. - */ - DeepIndent = 3 -} - /** * The kind of animation in which the editor's cursor should be rendered. */ @@ -983,15 +935,6 @@ function _float(value: any, defaultValue: number): number { return (isNaN(r) ? defaultValue : r); } -function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent { - switch (wrappingIndent) { - case 'none': return WrappingIndent.None; - case 'same': return WrappingIndent.Same; - case 'indent': return WrappingIndent.Indent; - case 'deepIndent': return WrappingIndent.DeepIndent; - } -} - function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle { switch (cursorBlinkingStyle) { case 'blink': return TextEditorCursorBlinkingStyle.Blink; @@ -1078,7 +1021,7 @@ export const EDITOR_MODEL_DEFAULTS = { /** * @internal */ -export interface IRawEditorOptionsBag extends IExtendedEditorOptions { +export interface IRawEditorOptionsBag extends IEditorOptions { [key: string]: any; } @@ -1134,19 +1077,10 @@ export interface IEditorOption { compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V; } -/** - * @internal - */ -type PossibleKeyName0 = { [K in keyof IExtendedEditorOptions]: IExtendedEditorOptions[K] extends V | undefined ? K : never }[keyof IExtendedEditorOptions]; -/** - * @internal - */ +type PossibleKeyName0 = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions]; type PossibleKeyName = NonNullable>; -/** - * @internal - */ -abstract class BaseEditorOption implements IEditorOption { +abstract class BaseEditorOption implements IEditorOption { public readonly id: K1; public readonly name: K2; @@ -1191,9 +1125,6 @@ abstract class ComputedEditorOption implements IEdit public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V; } -/** - * @internal - */ class SimpleEditorOption implements IEditorOption { public readonly id: K1; @@ -1288,131 +1219,6 @@ class EditorEnumOption extends Bas //#endregion -//#region renderLineNumbers - -export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); - -export const enum RenderLineNumbersType { - Off = 0, - On = 1, - Relative = 2, - Interval = 3, - Custom = 4 -} - -export interface InternalEditorRenderLineNumbersOptions { - readonly renderType: RenderLineNumbersType; - readonly renderFn: ((lineNumber: number) => string) | null; -} - -class EditorRenderLineNumbersOption> extends BaseEditorOption { - public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions { - let renderType: RenderLineNumbersType = this.defaultValue.renderType; - let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; - - if (typeof lineNumbers !== 'undefined') { - if (typeof lineNumbers === 'function') { - renderType = RenderLineNumbersType.Custom; - renderFn = lineNumbers; - } else if (lineNumbers === 'interval') { - renderType = RenderLineNumbersType.Interval; - } else if (lineNumbers === 'relative') { - renderType = RenderLineNumbersType.Relative; - } else if (lineNumbers === 'on') { - renderType = RenderLineNumbersType.On; - } else { - renderType = RenderLineNumbersType.Off; - } - } - - return { - renderType, - renderFn - }; - } -} - -//#endregion - -//#region minimap - -export interface InternalEditorMinimapOptions { - readonly enabled: boolean; - readonly side: 'right' | 'left'; - readonly showSlider: 'always' | 'mouseover'; - readonly renderCharacters: boolean; - readonly maxColumn: number; -} - -class EditorMinimap> extends BaseEditorOption { - public validate(_input: any): InternalEditorMinimapOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IEditorMinimapOptions; - return { - enabled: _boolean(input.enabled, this.defaultValue.enabled), - side: _stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']), - showSlider: _stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']), - renderCharacters: _boolean(input.renderCharacters, this.defaultValue.renderCharacters), - maxColumn: _clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000), - }; - } -} - -//#endregion - -//#region hover - -export interface InternalEditorHoverOptions { - readonly enabled: boolean; - readonly delay: number; - readonly sticky: boolean; -} - -class EditorHover> extends BaseEditorOption { - public validate(_input: any): InternalEditorHoverOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IEditorHoverOptions; - return { - enabled: _boolean(input.enabled, this.defaultValue.enabled), - delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000), - sticky: _boolean(input.sticky, this.defaultValue.sticky) - }; - } -} - -//#endregion - -//#region quickSuggestions - -export type ValidQuickSuggestionsOptions = boolean | Readonly>; - -class EditorQuickSuggestions> extends BaseEditorOption { - public readonly defaultValue: Readonly>; - constructor(id: K1, name: K2, defaultValue: Readonly>) { - super(id, name, defaultValue); - } - public validate(_input: any): ValidQuickSuggestionsOptions { - if (typeof _input === 'boolean') { - return _input; - } - if (typeof _input === 'object') { - const input = _input as IQuickSuggestionsOptions; - return { - other: _boolean(input.other, this.defaultValue.other), - comments: _boolean(input.comments, this.defaultValue.comments), - strings: _boolean(input.strings, this.defaultValue.strings), - }; - } - return this.defaultValue; - } -} - -//#endregion - //#region accessibilitySupport class EditorAccessibilitySupportOption> extends BaseEditorOption { @@ -1435,24 +1241,6 @@ class EditorAccessibilitySupportOption extends SimpleEditorOption { - public validate(input: any): number[] { - if (Array.isArray(input)) { - let rulers: number[] = []; - for (let value of input) { - rulers.push(_clampedInt(value, 0, 0, 10000)); - } - rulers.sort(); - return rulers; - } - return this.defaultValue; - } -} - -//#endregion - //#region ariaLabel class EditorAriaLabel extends SimpleEditorOption { @@ -1508,35 +1296,50 @@ class EditorClassName extends ComputedEditorOption extends ComputedEditorOption { - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: boolean): boolean { - const readOnly = options.get(EditorOption.readOnly); - return (readOnly ? true : env.tabFocusMode); +class EditorEmptySelectionClipboard extends EditorBooleanOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { + return value && env.emptySelectionClipboard; } } //#endregion -//#region pixelRatio +//#region find -class EditorPixelRatio extends ComputedEditorOption { - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number { - return env.pixelRatio; +export interface InternalEditorFindOptions { + readonly seedSearchStringFromSelection: boolean; + readonly autoFindInSelection: boolean; + readonly addExtraSpaceOnTop: boolean; + /** + * @internal + */ + readonly globalFindClipboard: boolean; +} + +class EditorFind> extends BaseEditorOption { + public validate(_input: any): InternalEditorFindOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IEditorFindOptions; + return { + seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection), + autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection), + globalFindClipboard: _boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard), + addExtraSpaceOnTop: _boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop) + }; } } //#endregion -//#region lineHeight +//#region fontInfo -class EditorLineHeight> extends EditorIntOption { - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { - // The lineHeight is computed from the fontSize if it is 0. - // Moreover, the final lineHeight respects the editor zoom level. - // So take the result from env.fontInfo - return env.fontInfo.lineHeight; +class EditorFontInfo extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo { + return env.fontInfo; } } @@ -1561,198 +1364,44 @@ class EditorFontSize extends SimpleEditorOption extends ComputedEditorOption { - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo { - return env.fontInfo; - } -} - -//#endregion - -//#region emptySelectionClipboard - -class EditorEmptySelectionClipboard extends EditorBooleanOption { - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean { - return value && env.emptySelectionClipboard; - } -} - -//#endregion - -//#region lightbulb - -export type ValidEditorLightbulbOptions = Required; - -class EditorLightbulb> extends BaseEditorOption { - public validate(_input: any): ValidEditorLightbulbOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IEditorLightbulbOptions; - return { - enabled: _boolean(input.enabled, this.defaultValue.enabled) - }; - } -} - -//#endregion - -//#region scrollbar - -export interface InternalEditorScrollbarOptions { - readonly arrowSize: number; - readonly vertical: ScrollbarVisibility; - readonly horizontal: ScrollbarVisibility; - readonly useShadows: boolean; - readonly verticalHasArrows: boolean; - readonly horizontalHasArrows: boolean; - readonly handleMouseWheel: boolean; - readonly horizontalScrollbarSize: number; - readonly horizontalSliderSize: number; - readonly verticalScrollbarSize: number; - readonly verticalSliderSize: number; -} - -class EditorScrollbar> extends BaseEditorOption { - public validate(_input: any): InternalEditorScrollbarOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IEditorScrollbarOptions; - const horizontalScrollbarSize = _clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000); - const verticalScrollbarSize = _clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000); - return { - arrowSize: _clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000), - vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical), - horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal), - useShadows: _boolean(input.useShadows, this.defaultValue.useShadows), - verticalHasArrows: _boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows), - horizontalHasArrows: _boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows), - handleMouseWheel: _boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel), - horizontalScrollbarSize: horizontalScrollbarSize, - horizontalSliderSize: _clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000), - verticalScrollbarSize: verticalScrollbarSize, - verticalSliderSize: _clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000), - }; - } -} - -//#endregion - -//#region suggest +//#region gotoLocation -export interface InternalSuggestOptions { - readonly filterGraceful: boolean; - readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; - readonly snippetsPreventQuickSuggestions: boolean; - readonly localityBonus: boolean; - readonly shareSuggestSelections: boolean; - readonly showIcons: boolean; - readonly maxVisibleSuggestions: number; - readonly filteredTypes: Record; +export interface InternalGoToLocationOptions { + readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; } -class EditorSuggest> extends BaseEditorOption { - public validate(_input: any): InternalSuggestOptions { +class EditorGoToLocation> extends BaseEditorOption { + public validate(_input: any): InternalGoToLocationOptions { if (typeof _input !== 'object') { return this.defaultValue; } - const input = _input as ISuggestOptions; - return { - filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful), - snippets: EditorOptions.snippetSuggestions.defaultValue, - snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful), - localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus), - shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections), - showIcons: _boolean(input.showIcons, this.defaultValue.showIcons), - maxVisibleSuggestions: _clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15), - filteredTypes: isObject(input.filteredTypes) ? input.filteredTypes : Object.create(null) - }; - } - public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalSuggestOptions): InternalSuggestOptions { - const snippetSuggestions = options.get(EditorOption.snippetSuggestions); + const input = _input as IGotoLocationOptions; return { - filterGraceful: value.filterGraceful, - snippets: snippetSuggestions, - snippetsPreventQuickSuggestions: value.snippetsPreventQuickSuggestions, - localityBonus: value.localityBonus, - shareSuggestSelections: value.shareSuggestSelections, - showIcons: value.showIcons, - maxVisibleSuggestions: value.maxVisibleSuggestions, - filteredTypes: value.filteredTypes, + multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']) }; } } //#endregion -//#region parameterHints +//#region hover -export interface InternalParameterHintOptions { +export interface InternalEditorHoverOptions { readonly enabled: boolean; - readonly cycle: boolean; + readonly delay: number; + readonly sticky: boolean; } -class EditorParameterHints> extends BaseEditorOption { - public validate(_input: any): InternalParameterHintOptions { +class EditorHover> extends BaseEditorOption { + public validate(_input: any): InternalEditorHoverOptions { if (typeof _input !== 'object') { return this.defaultValue; } - const input = _input as IEditorParameterHintOptions; + const input = _input as IEditorHoverOptions; return { enabled: _boolean(input.enabled, this.defaultValue.enabled), - cycle: _boolean(input.cycle, this.defaultValue.cycle) - }; - } -} - -//#endregion - -//#region find - -export interface InternalEditorFindOptions { - readonly seedSearchStringFromSelection: boolean; - readonly autoFindInSelection: boolean; - readonly addExtraSpaceOnTop: boolean; - /** - * @internal - */ - readonly globalFindClipboard: boolean; -} - -class EditorFind> extends BaseEditorOption { - public validate(_input: any): InternalEditorFindOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IEditorFindOptions; - return { - seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection), - autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection), - globalFindClipboard: _boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard), - addExtraSpaceOnTop: _boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop) - }; - } -} - -//#endregion - -//#region gotoLocation - -export interface InternalGoToLocationOptions { - readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; -} - -class EditorGoToLocation> extends BaseEditorOption { - public validate(_input: any): InternalGoToLocationOptions { - if (typeof _input !== 'object') { - return this.defaultValue; - } - const input = _input as IGotoLocationOptions; - return { - multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']) + delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000), + sticky: _boolean(input.sticky, this.defaultValue.sticky) }; } } @@ -1783,6 +1432,14 @@ export interface OverviewRulerPosition { readonly right: number; } +export const enum RenderMinimap { + None = 0, + Small = 1, + Large = 2, + SmallBlocks = 3, + LargeBlocks = 4, +} + /** * The internal layout details of the editor. */ @@ -2065,6 +1722,323 @@ export class EditorLayoutInfoComputer extends ComputedE //#endregion +//#region lightbulb + +export type ValidEditorLightbulbOptions = Required; + +class EditorLightbulb> extends BaseEditorOption { + public validate(_input: any): ValidEditorLightbulbOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IEditorLightbulbOptions; + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled) + }; + } +} + +//#endregion + +//#region lineHeight + +class EditorLineHeight> extends EditorIntOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number { + // The lineHeight is computed from the fontSize if it is 0. + // Moreover, the final lineHeight respects the editor zoom level. + // So take the result from env.fontInfo + return env.fontInfo.lineHeight; + } +} + +//#endregion + +//#region minimap + +export interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly side: 'right' | 'left'; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; +} + +class EditorMinimap> extends BaseEditorOption { + public validate(_input: any): InternalEditorMinimapOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IEditorMinimapOptions; + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled), + side: _stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']), + showSlider: _stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']), + renderCharacters: _boolean(input.renderCharacters, this.defaultValue.renderCharacters), + maxColumn: _clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000), + }; + } +} + +//#endregion + +//#region parameterHints + +export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; +} + +class EditorParameterHints> extends BaseEditorOption { + public validate(_input: any): InternalParameterHintOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IEditorParameterHintOptions; + return { + enabled: _boolean(input.enabled, this.defaultValue.enabled), + cycle: _boolean(input.cycle, this.defaultValue.cycle) + }; + } +} + +//#endregion + +//#region pixelRatio + +class EditorPixelRatio extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number { + return env.pixelRatio; + } +} + +//#endregion + +//#region quickSuggestions + +export type ValidQuickSuggestionsOptions = boolean | Readonly>; + +class EditorQuickSuggestions> extends BaseEditorOption { + public readonly defaultValue: Readonly>; + constructor(id: K1, name: K2, defaultValue: Readonly>) { + super(id, name, defaultValue); + } + public validate(_input: any): ValidQuickSuggestionsOptions { + if (typeof _input === 'boolean') { + return _input; + } + if (typeof _input === 'object') { + const input = _input as IQuickSuggestionsOptions; + return { + other: _boolean(input.other, this.defaultValue.other), + comments: _boolean(input.comments, this.defaultValue.comments), + strings: _boolean(input.strings, this.defaultValue.strings), + }; + } + return this.defaultValue; + } +} + +//#endregion + +//#region renderLineNumbers + +export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + +export const enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 +} + +export interface InternalEditorRenderLineNumbersOptions { + readonly renderType: RenderLineNumbersType; + readonly renderFn: ((lineNumber: number) => string) | null; +} + +class EditorRenderLineNumbersOption> extends BaseEditorOption { + public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions { + let renderType: RenderLineNumbersType = this.defaultValue.renderType; + let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn; + + if (typeof lineNumbers !== 'undefined') { + if (typeof lineNumbers === 'function') { + renderType = RenderLineNumbersType.Custom; + renderFn = lineNumbers; + } else if (lineNumbers === 'interval') { + renderType = RenderLineNumbersType.Interval; + } else if (lineNumbers === 'relative') { + renderType = RenderLineNumbersType.Relative; + } else if (lineNumbers === 'on') { + renderType = RenderLineNumbersType.On; + } else { + renderType = RenderLineNumbersType.Off; + } + } + + return { + renderType, + renderFn + }; + } +} + +//#endregion + +//#region rulers + +class EditorRulers extends SimpleEditorOption { + public validate(input: any): number[] { + if (Array.isArray(input)) { + let rulers: number[] = []; + for (let value of input) { + rulers.push(_clampedInt(value, 0, 0, 10000)); + } + rulers.sort(); + return rulers; + } + return this.defaultValue; + } +} + +//#endregion + +//#region scrollbar + +export interface InternalEditorScrollbarOptions { + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; +} + +class EditorScrollbar> extends BaseEditorOption { + public validate(_input: any): InternalEditorScrollbarOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as IEditorScrollbarOptions; + const horizontalScrollbarSize = _clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000); + const verticalScrollbarSize = _clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000); + return { + arrowSize: _clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000), + vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical), + horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal), + useShadows: _boolean(input.useShadows, this.defaultValue.useShadows), + verticalHasArrows: _boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows), + horizontalHasArrows: _boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows), + handleMouseWheel: _boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel), + horizontalScrollbarSize: horizontalScrollbarSize, + horizontalSliderSize: _clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000), + verticalScrollbarSize: verticalScrollbarSize, + verticalSliderSize: _clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000), + }; + } +} + +//#endregion + +//#region suggest + +export interface InternalSuggestOptions { + readonly filterGraceful: boolean; + readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; + readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + readonly shareSuggestSelections: boolean; + readonly showIcons: boolean; + readonly maxVisibleSuggestions: number; + readonly filteredTypes: Record; +} + +class EditorSuggest> extends BaseEditorOption { + public validate(_input: any): InternalSuggestOptions { + if (typeof _input !== 'object') { + return this.defaultValue; + } + const input = _input as ISuggestOptions; + return { + filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful), + snippets: EditorOptions.snippetSuggestions.defaultValue, + snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful), + localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus), + shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections), + showIcons: _boolean(input.showIcons, this.defaultValue.showIcons), + maxVisibleSuggestions: _clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15), + filteredTypes: isObject(input.filteredTypes) ? input.filteredTypes : Object.create(null) + }; + } + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalSuggestOptions): InternalSuggestOptions { + const snippetSuggestions = options.get(EditorOption.snippetSuggestions); + return { + filterGraceful: value.filterGraceful, + snippets: snippetSuggestions, + snippetsPreventQuickSuggestions: value.snippetsPreventQuickSuggestions, + localityBonus: value.localityBonus, + shareSuggestSelections: value.shareSuggestSelections, + showIcons: value.showIcons, + maxVisibleSuggestions: value.maxVisibleSuggestions, + filteredTypes: value.filteredTypes, + }; + } +} + +//#endregion + +//#region tabFocusMode + +class EditorTabFocusMode extends ComputedEditorOption { + public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: boolean): boolean { + const readOnly = options.get(EditorOption.readOnly); + return (readOnly ? true : env.tabFocusMode); + } +} + +//#endregion + +//#region wrappingIndent + +/** + * Describes how to indent wrapped lines. + */ +export const enum WrappingIndent { + /** + * No indentation => wrapped lines begin at column 1. + */ + None = 0, + /** + * Same => wrapped lines get the same indentation as the parent. + */ + Same = 1, + /** + * Indent => wrapped lines get +1 indentation toward the parent. + */ + Indent = 2, + /** + * DeepIndent => wrapped lines get +2 indentation toward the parent. + */ + DeepIndent = 3 +} + +function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent { + switch (wrappingIndent) { + case 'none': return WrappingIndent.None; + case 'same': return WrappingIndent.Same; + case 'indent': return WrappingIndent.Indent; + case 'deepIndent': return WrappingIndent.DeepIndent; + } +} + +//#endregion + //#region wrappingInfo export interface EditorWrappingInfo { diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 9a5f179dfabcb..89350c4f9a778 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -341,36 +341,6 @@ export enum AccessibilitySupport { Enabled = 2 } -export enum RenderMinimap { - None = 0, - Small = 1, - Large = 2, - SmallBlocks = 3, - LargeBlocks = 4 -} - -/** - * Describes how to indent wrapped lines. - */ -export enum WrappingIndent { - /** - * No indentation => wrapped lines begin at column 1. - */ - None = 0, - /** - * Same => wrapped lines get the same indentation as the parent. - */ - Same = 1, - /** - * Indent => wrapped lines get +1 indentation toward the parent. - */ - Indent = 2, - /** - * DeepIndent => wrapped lines get +2 indentation toward the parent. - */ - DeepIndent = 3 -} - /** * The kind of animation in which the editor's cursor should be rendered. */ @@ -431,6 +401,14 @@ export enum TextEditorCursorStyle { UnderlineThin = 6 } +export enum RenderMinimap { + None = 0, + Small = 1, + Large = 2, + SmallBlocks = 3, + LargeBlocks = 4 +} + export enum RenderLineNumbersType { Off = 0, On = 1, @@ -439,6 +417,28 @@ export enum RenderLineNumbersType { Custom = 4 } +/** + * Describes how to indent wrapped lines. + */ +export enum WrappingIndent { + /** + * No indentation => wrapped lines begin at column 1. + */ + None = 0, + /** + * Same => wrapped lines get the same indentation as the parent. + */ + Same = 1, + /** + * Indent => wrapped lines get +1 indentation toward the parent. + */ + Indent = 2, + /** + * DeepIndent => wrapped lines get +2 indentation toward the parent. + */ + DeepIndent = 3 +} + export enum EditorOption { acceptSuggestionOnCommitCharacter = 0, acceptSuggestionOnEnter = 1, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index c698ce3ad5a69..b56a37e69a2ab 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2540,7 +2540,7 @@ declare namespace monaco.editor { } /** - * Configuration options for editor minimap + * Configuration options for editor lightbulb */ export interface IEditorLightbulbOptions { /** @@ -2587,6 +2587,9 @@ declare namespace monaco.editor { cycle?: boolean; } + /** + * Configuration options for editor suggest widget + */ export interface ISuggestOptions { /** * Enable graceful matching. Defaults to true. @@ -2618,6 +2621,9 @@ declare namespace monaco.editor { filteredTypes?: Record; } + /** + * Configuration options for go to location + */ export interface IGotoLocationOptions { /** * Control how goto-command work when having multiple results. @@ -2625,6 +2631,9 @@ declare namespace monaco.editor { multiple?: 'peek' | 'gotoAndPeek' | 'goto'; } + /** + * Configuration options for quick suggestions + */ export interface IQuickSuggestionsOptions { other: boolean; comments: boolean; @@ -3112,33 +3121,6 @@ declare namespace monaco.editor { showUnused?: boolean; } - export type IExtendedEditorOptions = IEditorOptions & { - /** - * Do not use, this is a computed option. - */ - editorClassName?: undefined; - /** - * Do not use, this is a computed option. - */ - pixelRatio?: undefined; - /** - * Do not use, this is a computed option. - */ - fontInfo?: undefined; - /** - * Do not use, this is a computed option. - */ - tabFocusMode?: undefined; - /** - * Do not use, this is a computed option. - */ - layoutInfo?: undefined; - /** - * Do not use, this is a computed option. - */ - wrappingInfo?: undefined; - }; - /** * Configuration options for the diff editor. */ @@ -3170,36 +3152,6 @@ declare namespace monaco.editor { originalEditable?: boolean; } - export enum RenderMinimap { - None = 0, - Small = 1, - Large = 2, - SmallBlocks = 3, - LargeBlocks = 4 - } - - /** - * Describes how to indent wrapped lines. - */ - export enum WrappingIndent { - /** - * No indentation => wrapped lines begin at column 1. - */ - None = 0, - /** - * Same => wrapped lines get the same indentation as the parent. - */ - Same = 1, - /** - * Indent => wrapped lines get +1 indentation toward the parent. - */ - Indent = 2, - /** - * DeepIndent => wrapped lines get +2 indentation toward the parent. - */ - DeepIndent = 3 - } - /** * The kind of animation in which the editor's cursor should be rendered. */ @@ -3290,69 +3242,6 @@ declare namespace monaco.editor { readonly defaultValue: V; } - export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); - - export enum RenderLineNumbersType { - Off = 0, - On = 1, - Relative = 2, - Interval = 3, - Custom = 4 - } - - export interface InternalEditorRenderLineNumbersOptions { - readonly renderType: RenderLineNumbersType; - readonly renderFn: ((lineNumber: number) => string) | null; - } - - export interface InternalEditorMinimapOptions { - readonly enabled: boolean; - readonly side: 'right' | 'left'; - readonly showSlider: 'always' | 'mouseover'; - readonly renderCharacters: boolean; - readonly maxColumn: number; - } - - export interface InternalEditorHoverOptions { - readonly enabled: boolean; - readonly delay: number; - readonly sticky: boolean; - } - - export type ValidQuickSuggestionsOptions = boolean | Readonly>; - - export type ValidEditorLightbulbOptions = Required; - - export interface InternalEditorScrollbarOptions { - readonly arrowSize: number; - readonly vertical: ScrollbarVisibility; - readonly horizontal: ScrollbarVisibility; - readonly useShadows: boolean; - readonly verticalHasArrows: boolean; - readonly horizontalHasArrows: boolean; - readonly handleMouseWheel: boolean; - readonly horizontalScrollbarSize: number; - readonly horizontalSliderSize: number; - readonly verticalScrollbarSize: number; - readonly verticalSliderSize: number; - } - - export interface InternalSuggestOptions { - readonly filterGraceful: boolean; - readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; - readonly snippetsPreventQuickSuggestions: boolean; - readonly localityBonus: boolean; - readonly shareSuggestSelections: boolean; - readonly showIcons: boolean; - readonly maxVisibleSuggestions: number; - readonly filteredTypes: Record; - } - - export interface InternalParameterHintOptions { - readonly enabled: boolean; - readonly cycle: boolean; - } - export interface InternalEditorFindOptions { readonly seedSearchStringFromSelection: boolean; readonly autoFindInSelection: boolean; @@ -3363,6 +3252,12 @@ declare namespace monaco.editor { readonly multiple: 'peek' | 'gotoAndPeek' | 'goto'; } + export interface InternalEditorHoverOptions { + readonly enabled: boolean; + readonly delay: number; + readonly sticky: boolean; + } + /** * A description for the overview ruler position. */ @@ -3385,6 +3280,14 @@ declare namespace monaco.editor { readonly right: number; } + export enum RenderMinimap { + None = 0, + Small = 1, + Large = 2, + SmallBlocks = 3, + LargeBlocks = 4 + } + /** * The internal layout details of the editor. */ @@ -3475,6 +3378,85 @@ declare namespace monaco.editor { readonly overviewRuler: OverviewRulerPosition; } + export type ValidEditorLightbulbOptions = Required; + + export interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly side: 'right' | 'left'; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; + } + + export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; + } + + export type ValidQuickSuggestionsOptions = boolean | Readonly>; + + export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + + export enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 + } + + export interface InternalEditorRenderLineNumbersOptions { + readonly renderType: RenderLineNumbersType; + readonly renderFn: ((lineNumber: number) => string) | null; + } + + export interface InternalEditorScrollbarOptions { + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; + } + + export interface InternalSuggestOptions { + readonly filterGraceful: boolean; + readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; + readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + readonly shareSuggestSelections: boolean; + readonly showIcons: boolean; + readonly maxVisibleSuggestions: number; + readonly filteredTypes: Record; + } + + /** + * Describes how to indent wrapped lines. + */ + export enum WrappingIndent { + /** + * No indentation => wrapped lines begin at column 1. + */ + None = 0, + /** + * Same => wrapped lines get the same indentation as the parent. + */ + Same = 1, + /** + * Indent => wrapped lines get +1 indentation toward the parent. + */ + Indent = 2, + /** + * DeepIndent => wrapped lines get +2 indentation toward the parent. + */ + DeepIndent = 3 + } + export interface EditorWrappingInfo { readonly isDominatedByLongLines: boolean; readonly isWordWrapMinified: boolean; From 959c017811a137868e62838036a5286c11d0d4f9 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 6 Sep 2019 12:28:13 +0200 Subject: [PATCH 133/204] Rearrange editor options --- .../common/config/commonEditorConfig.ts | 15 +- src/vs/editor/common/config/editorOptions.ts | 307 +++++++++--------- src/vs/monaco.d.ts | 53 ++- 3 files changed, 186 insertions(+), 189 deletions(-) diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index a778496a278a7..5f99d84bf591b 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -9,7 +9,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import * as objects from 'vs/base/common/objects'; import * as arrays from 'vs/base/common/arrays'; import * as platform from 'vs/base/common/platform'; -import { IEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, ComputedEditorOptions, ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions'; +import { IEditorOptions, editorOptionsRegistry, ValidatedEditorOptions, IEnvironmentalOptions, IComputedEditorOptions, ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOptions, EDITOR_MODEL_DEFAULTS, EditorOption, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions'; import { EditorZoom } from 'vs/editor/common/config/editorZoom'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -61,6 +61,19 @@ export interface IEnvConfiguration { const hasOwnProperty = Object.hasOwnProperty; +class ComputedEditorOptions implements IComputedEditorOptions { + private readonly _values: any[] = []; + public _read(id: EditorOption): T { + return this._values[id]; + } + public get(id: T): FindComputedEditorOptionValueById { + return this._values[id]; + } + public _write(id: EditorOption, value: T): void { + this._values[id] = value; + } +} + class RawEditorOptions { private readonly _values: any[] = []; public _read(id: EditorOption): T | undefined { diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index f736287cc76c7..cb44b48319cf9 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -756,91 +756,6 @@ export interface IDiffEditorOptions extends IEditorOptions { originalEditable?: boolean; } -/** - * The kind of animation in which the editor's cursor should be rendered. - */ -export const enum TextEditorCursorBlinkingStyle { - /** - * Hidden - */ - Hidden = 0, - /** - * Blinking - */ - Blink = 1, - /** - * Blinking with smooth fading - */ - Smooth = 2, - /** - * Blinking with prolonged filled state and smooth fading - */ - Phase = 3, - /** - * Expand collapse animation on the y axis - */ - Expand = 4, - /** - * No-Blinking - */ - Solid = 5 -} - -/** - * The style in which the editor's cursor should be rendered. - */ -export enum TextEditorCursorStyle { - /** - * As a vertical line (sitting between two characters). - */ - Line = 1, - /** - * As a block (sitting on top of a character). - */ - Block = 2, - /** - * As a horizontal line (sitting under a character). - */ - Underline = 3, - /** - * As a thin vertical line (sitting between two characters). - */ - LineThin = 4, - /** - * As an outlined block (sitting on top of a character). - */ - BlockOutline = 5, - /** - * As a thin horizontal line (sitting under a character). - */ - UnderlineThin = 6 -} - -/** - * @internal - */ -export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' { - switch (cursorStyle) { - case TextEditorCursorStyle.Line: return 'line'; - case TextEditorCursorStyle.Block: return 'block'; - case TextEditorCursorStyle.Underline: return 'underline'; - case TextEditorCursorStyle.LineThin: return 'line-thin'; - case TextEditorCursorStyle.BlockOutline: return 'block-outline'; - case TextEditorCursorStyle.UnderlineThin: return 'underline-thin'; - } -} - -function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle { - switch (cursorStyle) { - case 'line': return TextEditorCursorStyle.Line; - case 'block': return TextEditorCursorStyle.Block; - case 'underline': return TextEditorCursorStyle.Underline; - case 'line-thin': return TextEditorCursorStyle.LineThin; - case 'block-outline': return TextEditorCursorStyle.BlockOutline; - case 'underline-thin': return TextEditorCursorStyle.UnderlineThin; - } -} - /** * An event describing that the configuration of the editor has changed. */ @@ -858,6 +773,9 @@ export class ConfigurationChangedEvent { } } +/** + * @internal + */ export interface IEnvironmentalOptions { readonly outerWidth: number; readonly outerHeight: number; @@ -935,27 +853,6 @@ function _float(value: any, defaultValue: number): number { return (isNaN(r) ? defaultValue : r); } -function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle { - switch (cursorBlinkingStyle) { - case 'blink': return TextEditorCursorBlinkingStyle.Blink; - case 'smooth': return TextEditorCursorBlinkingStyle.Smooth; - case 'phase': return TextEditorCursorBlinkingStyle.Phase; - case 'expand': return TextEditorCursorBlinkingStyle.Expand; - case 'solid': return TextEditorCursorBlinkingStyle.Solid; - } -} - -function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility { - if (typeof visibility !== 'string') { - return defaultValue; - } - switch (visibility) { - case 'hidden': return ScrollbarVisibility.Hidden; - case 'visible': return ScrollbarVisibility.Visible; - default: return ScrollbarVisibility.Auto; - } -} - /** * @internal */ @@ -987,36 +884,6 @@ export interface IEditorLayoutProviderOpts { readonly pixelRatio: number; } -const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace'; -const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace'; -const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\''; - -/** - * @internal - */ -export const EDITOR_FONT_DEFAULTS = { - fontFamily: ( - platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY) - ), - fontWeight: 'normal', - fontSize: ( - platform.isMacintosh ? 12 : 14 - ), - lineHeight: 0, - letterSpacing: 0, -}; - -/** - * @internal - */ -export const EDITOR_MODEL_DEFAULTS = { - tabSize: 4, - indentSize: 4, - insertSpaces: true, - detectIndentation: true, - trimAutoWhitespace: true, - largeFileOptimizations: true -}; /** * @internal @@ -1045,22 +912,6 @@ export interface IComputedEditorOptions { get(id: T): FindComputedEditorOptionValueById; } -/** - * @internal - */ -export class ComputedEditorOptions implements IComputedEditorOptions { - private readonly _values: any[] = []; - public _read(id: EditorOption): T { - return this._values[id]; - } - public get(id: T): FindComputedEditorOptionValueById { - return this._values[id]; - } - public _write(id: EditorOption, value: T): void { - this._values[id] = value; - } -} - //#region IEditorOption export interface IEditorOption { @@ -1258,6 +1109,109 @@ class EditorAriaLabel extends SimpleEditorOption