From d0a6369f3975f8928d6c41866aa1864e8dc25c3a Mon Sep 17 00:00:00 2001 From: Sriram Desikan Date: Tue, 13 Feb 2018 07:43:33 +0530 Subject: [PATCH 01/60] #42557 fix --- .../execution.contribution.ts | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index 869a9d8c7c1..60435c80426 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -24,7 +24,7 @@ import { ResourceContextKey } from 'vs/workbench/common/resources'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IFileService } from 'vs/platform/files/common/files'; import { IListService } from 'vs/platform/list/browser/listService'; -import { getResourceForCommand } from 'vs/workbench/parts/files/browser/files'; +import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/files'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { Schemas } from 'vs/base/common/network'; @@ -85,20 +85,26 @@ CommandsRegistry.registerCommand({ const fileService = accessor.get(IFileService); const integratedTerminalService = accessor.get(IIntegratedTerminalService); const terminalService = accessor.get(ITerminalService); - resource = getResourceForCommand(resource, accessor.get(IListService), editorService); - - return fileService.resolveFile(resource).then(stat => { - return stat.isDirectory ? stat.resource.fsPath : paths.dirname(stat.resource.fsPath); - }).then(directoryToOpen => { - if (configurationService.getValue().terminal.explorerKind === 'integrated') { - const instance = integratedTerminalService.createInstance({ cwd: directoryToOpen }, true); - if (instance) { - integratedTerminalService.setActiveInstance(instance); - integratedTerminalService.showPanel(true); + let resources:uri[] = []; + let directoryMap:Map = new Map(); + resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService); + return resources.map((resource) => { + return fileService.resolveFile(resource).then(stat => { + return stat.isDirectory ? stat.resource.fsPath : paths.dirname(stat.resource.fsPath); + }).then(directoryToOpen => { + if (!directoryMap.has(directoryToOpen)) { + directoryMap.set(directoryToOpen, true); + if (configurationService.getValue().terminal.explorerKind === 'integrated') { + const instance = integratedTerminalService.createInstance({ cwd: directoryToOpen }, true); + if (instance) { + integratedTerminalService.setActiveInstance(instance); + integratedTerminalService.showPanel(true); + } + } else { + terminalService.openTerminal(directoryToOpen); + } } - } else { - terminalService.openTerminal(directoryToOpen); - } + }); }); } }); From 0ace6ef8eafe95e3627432b1f9ae09cabdd35c2b Mon Sep 17 00:00:00 2001 From: EbXpJ6bp Date: Fri, 16 Feb 2018 02:26:48 +0900 Subject: [PATCH 02/60] Improve Issue Reporter UI * improve scrollbar margin * add cursor property * no wrapping of label text --- .../issue/issueReporterMain.ts | 6 ++--- .../issue/media/issueReporter.css | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/vs/code/electron-browser/issue/issueReporterMain.ts b/src/vs/code/electron-browser/issue/issueReporterMain.ts index d4508cc68b8..56adfad1664 100644 --- a/src/vs/code/electron-browser/issue/issueReporterMain.ts +++ b/src/vs/code/electron-browser/issue/issueReporterMain.ts @@ -187,15 +187,15 @@ export class IssueReporter extends Disposable { } if (styles.sliderBackgroundColor) { - content.push(`.issues-container::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb { background-color: ${styles.sliderBackgroundColor}; }`); + content.push(`::-webkit-scrollbar-thumb { background-color: ${styles.sliderBackgroundColor}; }`); } if (styles.sliderActiveColor) { - content.push(`.issues-container::-webkit-scrollbar-thumb:active, body::-webkit-scrollbar-thumb:active { background-color: ${styles.sliderActiveColor}; }`); + content.push(`::-webkit-scrollbar-thumb:active { background-color: ${styles.sliderActiveColor}; }`); } if (styles.sliderHoverColor) { - content.push(`.issues-container::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover { background-color: ${styles.sliderHoverColor}; }`); + content.push(`::--webkit-scrollbar-thumb:hover { background-color: ${styles.sliderHoverColor}; }`); } styleTag.innerHTML = content.join('\n'); diff --git a/src/vs/code/electron-browser/issue/media/issueReporter.css b/src/vs/code/electron-browser/issue/media/issueReporter.css index 8f1de9a6a4d..8a6158c0f04 100644 --- a/src/vs/code/electron-browser/issue/media/issueReporter.css +++ b/src/vs/code/electron-browser/issue/media/issueReporter.css @@ -116,6 +116,7 @@ html { body { margin: 0; + overflow: scroll; } .hidden { @@ -223,16 +224,11 @@ summary { .include-data { display: inline-block; - position: relative; } .include-data > .caption { display: inline-block; font-size: 12px; - position: absolute; - width: 80px; - top: 2px; - left: 30px; cursor: pointer; } @@ -263,9 +259,12 @@ input:disabled { margin-top: .5em; } +.workbenchCommand { + cursor: pointer; +} .workbenchCommand:disabled { color: #868e96; - cursor: pointer; + cursor: default } .block-extensions .block-info { @@ -303,6 +302,7 @@ button { #issue-type { width: calc(100% - 100px); + cursor: pointer; } #issue-title-label { @@ -348,14 +348,18 @@ button { } } -.issues-container::-webkit-scrollbar, body::-webkit-scrollbar { +::-webkit-scrollbar { width: 14px; } -.issues-container::-webkit-scrollbar, body::-webkit-scrollbar-thumb { +::-webkit-scrollbar-thumb { min-height: 20px; } +::-webkit-scrollbar-corner { + display: none; +} + .issues-container { margin-top: .5em; height: 108px; @@ -397,4 +401,4 @@ div.issues-container { .issues-container > .issue > .issue-state .octicon { padding-right: 5px; -} \ No newline at end of file +} From 493651d6ced5c95d30a225071538c0b8a574ec2f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 22:38:02 -0800 Subject: [PATCH 03/60] Make webview.contents a string instead of an array of strings --- .../workbench/api/electron-browser/mainThreadWebview.ts | 2 +- .../workbench/parts/extensions/browser/extensionEditor.ts | 2 +- src/vs/workbench/parts/html/browser/htmlPreviewPart.ts | 8 ++++---- src/vs/workbench/parts/html/browser/webview-pre.js | 2 +- src/vs/workbench/parts/html/browser/webview.ts | 2 +- src/vs/workbench/parts/html/browser/webviewEditor.ts | 4 ---- .../parts/update/electron-browser/releaseNotesEditor.ts | 2 +- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index ae51d1a4655..f6a2c26d62f 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -209,7 +209,7 @@ class WebviewEditor extends BaseWebviewEditor { allowScripts: input.options.enableScripts, enableWrappedPostMessage: true }; - this.webview.contents = [input.html]; + this.webview.contents = input.html; this.webview.style(this.themeService.getTheme()); } diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index a0566ec09fc..f1d09a11784 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -426,7 +426,7 @@ export class ExtensionEditor extends BaseEditor { this.contentDisposables.push(toDisposable(removeLayoutParticipant)); this.activeWebview.style(this.themeService.getTheme()); - this.activeWebview.contents = [body]; + this.activeWebview.contents = body; this.activeWebview.onDidClickLink(link => { // Whitelist supported schemes for links diff --git a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts index 06925da8b84..24cab9977cf 100644 --- a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts +++ b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts @@ -143,8 +143,8 @@ export class HtmlPreviewPart extends WebviewEditor { this._themeChangeSubscription = this.themeService.onThemeChange(this.onThemeChange.bind(this)); if (this._hasValidModel()) { - this._modelChangeSubscription = this.model.onDidChangeContent(() => this.webview.contents = this.model.getLinesContent()); - this.webview.contents = this.model.getLinesContent(); + this._modelChangeSubscription = this.model.onDidChangeContent(() => this.webview.contents = this.model.getLinesContent().join('\n')); + this.webview.contents = this.model.getLinesContent().join('\n'); } } } @@ -234,14 +234,14 @@ export class HtmlPreviewPart extends WebviewEditor { this._modelChangeSubscription = this.model.onDidChangeContent(() => { if (this.model) { this.scrollYPercentage = 0; - this.webview.contents = this.model.getLinesContent(); + this.webview.contents = this.model.getLinesContent().join('\n'); } }); const state = this.loadViewState(resourceUri); this.scrollYPercentage = state ? state.scrollYPercentage : 0; this.webview.baseUrl = resourceUri.toString(true); this.webview.options = input.options; - this.webview.contents = this.model.getLinesContent(); + this.webview.contents = this.model.getLinesContent().join('\n'); this.webview.initialScrollProgress = this.scrollYPercentage; return undefined; }); diff --git a/src/vs/workbench/parts/html/browser/webview-pre.js b/src/vs/workbench/parts/html/browser/webview-pre.js index ed6c1fc5da8..3f83e84fdb7 100644 --- a/src/vs/workbench/parts/html/browser/webview-pre.js +++ b/src/vs/workbench/parts/html/browser/webview-pre.js @@ -128,7 +128,7 @@ const options = data.options; enableWrappedPostMessage = options && options.enableWrappedPostMessage; - const text = data.contents.join('\n'); + const text = data.contents; const newDocument = new DOMParser().parseFromString(text, 'text/html'); newDocument.querySelectorAll('a').forEach(a => { diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index 8c4771cbfaf..ccdf4298b60 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -284,7 +284,7 @@ export default class Webview { this._options = value; } - set contents(value: string[]) { + set contents(value: string) { this._send('content', { contents: value, options: this._options diff --git a/src/vs/workbench/parts/html/browser/webviewEditor.ts b/src/vs/workbench/parts/html/browser/webviewEditor.ts index f1c7a42e68e..f5c289d3928 100644 --- a/src/vs/workbench/parts/html/browser/webviewEditor.ts +++ b/src/vs/workbench/parts/html/browser/webviewEditor.ts @@ -24,10 +24,6 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { Action } from 'vs/base/common/actions'; import { TPromise } from 'vs/base/common/winjs.base'; -export interface HtmlPreviewEditorViewState { - scrollYPercentage: number; -} - /** A context key that is set when a webview editor has focus. */ export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS = new RawContextKey('webviewEditorFocus', false); /** A context key that is set when the find widget find input in webview editor webview is focused. */ diff --git a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts index ace4d2f79fd..557d912273f 100644 --- a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts +++ b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts @@ -124,7 +124,7 @@ export class ReleaseNotesEditor extends WebviewEditor { } } this.onThemeChange(this.themeService.getTheme()); - this._webview.contents = [body]; + this._webview.contents = body; this._webview.onDidClickLink(link => { addGAParameters(this.telemetryService, this.environmentService, link, 'ReleaseNotes') From 3fbaf308250c0a7e3c10f99385adeb19d50a376b Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 22:40:38 -0800 Subject: [PATCH 04/60] Extract registerFileProtocols --- .../workbench/parts/html/browser/webview.ts | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index ccdf4298b60..cc02b76080a 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -107,18 +107,8 @@ export default class Webview { loaded = true; const contents = this._webview.getWebContents(); - if (contents && !contents.isDestroyed()) { - registerFileProtocol(contents, 'vscode-core-resource', [ - this._environmentService.appRoot - ]); - registerFileProtocol(contents, 'vscode-extension-resource', [ - this._environmentService.extensionsPath, - this._environmentService.appRoot, - this._environmentService.extensionDevelopmentPath - ]); - registerFileProtocol(contents, 'vscode-workspace-resource', - this._contextService.getWorkspace().folders.map(folder => folder.uri.fsPath)); - } + this.registerFileProtocols(contents); + })); } @@ -223,6 +213,24 @@ export default class Webview { } } + private registerFileProtocols(contents: Electron.WebContents) { + if (!contents || contents.isDestroyed()) { + return; + } + + registerFileProtocol(contents, 'vscode-core-resource', [ + this._environmentService.appRoot + ]); + registerFileProtocol(contents, 'vscode-extension-resource', [ + this._environmentService.extensionsPath, + this._environmentService.appRoot, + this._environmentService.extensionDevelopmentPath + ]); + registerFileProtocol(contents, 'vscode-workspace-resource', + this._contextService.getWorkspace().folders.map(folder => folder.uri.fsPath) + ); + } + public notifyFindWidgetFocusChanged(isFocused: boolean) { this._contextKey.set(isFocused || document.activeElement === this._webview); } From 8b096ad66bc3a938a9a2b9610e47797dbb204b6b Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 22:49:50 -0800 Subject: [PATCH 05/60] Move scrollbar-thumb css logic into webview --- .../parts/html/browser/webview-pre.js | 27 ++++++++++++++++--- .../workbench/parts/html/browser/webview.ts | 9 ------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webview-pre.js b/src/vs/workbench/parts/html/browser/webview-pre.js index 3f83e84fdb7..5331fa75e39 100644 --- a/src/vs/workbench/parts/html/browser/webview-pre.js +++ b/src/vs/workbench/parts/html/browser/webview-pre.js @@ -184,14 +184,35 @@ width: 10px; height: 10px; } + ::-webkit-scrollbar-thumb { - background-color: var(--scrollbar-thumb); + background-color: rgba(121, 121, 121, 0.4); } + body.vscode-light::-webkit-scrollbar-thumb { + background-color: rgba(100, 100, 100, 0.4); + } + body.vscode-high-contrast::-webkit-scrollbar-thumb { + background-color: rgba(111, 195, 223, 0.3); + } + ::-webkit-scrollbar-thumb:hover { - background-color: var(--scrollbar-thumb-hover); + background-color: rgba(100, 100, 100, 0.7); } + body.vscode-light::-webkit-scrollbar-thumb:hover { + background-color: rgba(100, 100, 100, 0.7); + } + body.vscode-high-contrast::-webkit-scrollbar-thumb:hover { + background-color: rgba(111, 195, 223, 0.8); + } + ::-webkit-scrollbar-thumb:active { - background-color: var(--scrollbar-thumb-active); + background-color: rgba(85, 85, 85, 0.8); + } + body.vscode-light::-webkit-scrollbar-thumb:active { + background-color: rgba(0, 0, 0, 0.6); + } + body.vscode-high-contrast::-webkit-scrollbar-thumb:active { + background-color: rgba(111, 195, 223, 0.8); } `; if (newDocument.head.hasChildNodes()) { diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index cc02b76080a..e5a82fd92d0 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -332,19 +332,10 @@ export default class Webview { let activeTheme: ApiThemeClassName; if (theme.type === LIGHT) { - styles['scrollbar-thumb'] = 'rgba(100, 100, 100, 0.4)'; - styles['scrollbar-thumb-hover'] = 'rgba(100, 100, 100, 0.7)'; - styles['scrollbar-thumb-active'] = 'rgba(0, 0, 0, 0.6)'; activeTheme = 'vscode-light'; } else if (theme.type === DARK) { - styles['scrollbar-thumb'] = 'rgba(121, 121, 121, 0.4)'; - styles['scrollbar-thumb-hover'] = 'rgba(100, 100, 100, 0.7)'; - styles['scrollbar-thumb-active'] = 'rgba(85, 85, 85, 0.8)'; activeTheme = 'vscode-dark'; } else { - styles['scrollbar-thumb'] = 'rgba(111, 195, 223, 0.3)'; - styles['scrollbar-thumb-hover'] = 'rgba(111, 195, 223, 0.8)'; - styles['scrollbar-thumb-active'] = 'rgba(111, 195, 223, 0.8)'; activeTheme = 'vscode-high-contrast'; } From 4ba0a75cbb63d7cdd05a739dcd02d55e7e7ed8c5 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 22:51:33 -0800 Subject: [PATCH 06/60] Extract getActiveTheme --- .../workbench/parts/html/browser/webview.ts | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index e5a82fd92d0..e1ad5d26910 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -34,8 +34,6 @@ export interface FoundInPageResults { selectionArea: any; } -type ApiThemeClassName = 'vscode-light' | 'vscode-dark' | 'vscode-high-contrast'; - export interface WebviewOptions { allowScripts?: boolean; allowSvgs?: boolean; @@ -330,15 +328,7 @@ export default class Webview { 'link-color': theme.getColor(textLinkForeground).toString() }; - let activeTheme: ApiThemeClassName; - if (theme.type === LIGHT) { - activeTheme = 'vscode-light'; - } else if (theme.type === DARK) { - activeTheme = 'vscode-dark'; - } else { - activeTheme = 'vscode-high-contrast'; - } - + const activeTheme = ApiThemeClassName.fromTheme(theme); this._send('styles', styles, activeTheme); this._webviewFindWidget.updateTheme(theme); @@ -448,6 +438,25 @@ export default class Webview { } } + +enum ApiThemeClassName { + light = 'vscode-light', + dark = 'vscode-dark', + highContrast = 'vscode-high-contrast' +} + +namespace ApiThemeClassName { + export function fromTheme(theme: ITheme): ApiThemeClassName { + if (theme.type === LIGHT) { + return ApiThemeClassName.light; + } else if (theme.type === DARK) { + return ApiThemeClassName.dark; + } else { + return ApiThemeClassName.highContrast; + } + } +} + function registerFileProtocol( contents: Electron.WebContents, protocol: string, From 83ccb8552e1e4105336b7e908f34ba010f7b3cc0 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:01:50 -0800 Subject: [PATCH 07/60] Combine emitter and event definitions --- .../workbench/parts/html/browser/webview.ts | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index e1ad5d26910..47d818f8b53 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -46,13 +46,6 @@ export default class Webview { private _ready: Promise; private _disposables: IDisposable[] = []; - private _onDidClickLink = new Emitter(); - private _onDidScroll = new Emitter<{ scrollYPercentage: number }>(); - private _onFoundInPageResults = new Emitter(); - private _onMessage = new Emitter(); - private _onFocus = new Emitter(); - private _onBlur = new Emitter(); - private _webviewFindWidget: WebviewFindWidget; private _findStarted: boolean = false; @@ -252,29 +245,24 @@ export default class Webview { } } - get onDidClickLink(): Event { - return this._onDidClickLink.event; - } - get onDidScroll(): Event<{ scrollYPercentage: number }> { - return this._onDidScroll.event; - } + private readonly _onDidClickLink = new Emitter(); + public readonly onDidClickLink: Event = this._onDidClickLink.event; - get onFindResults(): Event { - return this._onFoundInPageResults.event; - } + private readonly _onDidScroll = new Emitter<{ scrollYPercentage: number }>(); + public readonly onDidScroll: Event<{ scrollYPercentage: number }> = this._onDidScroll.event; - get onMessage(): Event { - return this._onMessage.event; - } + private readonly _onFoundInPageResults = new Emitter(); + public readonly onFindResults: Event = this._onFoundInPageResults.event; - get onFocus(): Event { - return this._onFocus.event; - } + private readonly _onMessage = new Emitter(); + public readonly onMessage: Event = this._onMessage.event; - get onBlur(): Event { - return this._onBlur.event; - } + private readonly _onFocus = new Emitter(); + public readonly onFocus: Event = this._onFocus.event; + + private readonly _onBlur = new Emitter(); + public readonly onBlur: Event = this._onBlur.event; private _send(channel: string, ...args: any[]): void { this._ready From ab8438a8f074feebff819e576e99b58da6174862 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:08:00 -0800 Subject: [PATCH 08/60] Remove duplicate types --- .../workbench/parts/html/browser/webview.ts | 76 +++++++------------ 1 file changed, 29 insertions(+), 47 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index 47d818f8b53..0f96f64960b 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -19,26 +19,11 @@ import { normalize, nativeSep } from 'vs/base/common/paths'; import { startsWith } from 'vs/base/common/strings'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -export interface WebviewElementFindInPageOptions { - forward?: boolean; - findNext?: boolean; - matchCase?: boolean; - wordStart?: boolean; - medialCapitalAsWordStart?: boolean; -} - -export interface FoundInPageResults { - requestId: number; - activeMatchOrdinal: number; - matches: number; - selectionArea: any; -} - export interface WebviewOptions { - allowScripts?: boolean; - allowSvgs?: boolean; - svgWhiteList?: string[]; - enableWrappedPostMessage?: boolean; + readonly allowScripts?: boolean; + readonly allowSvgs?: boolean; + readonly svgWhiteList?: string[]; + readonly enableWrappedPostMessage?: boolean; } export default class Webview { @@ -204,24 +189,6 @@ export default class Webview { } } - private registerFileProtocols(contents: Electron.WebContents) { - if (!contents || contents.isDestroyed()) { - return; - } - - registerFileProtocol(contents, 'vscode-core-resource', [ - this._environmentService.appRoot - ]); - registerFileProtocol(contents, 'vscode-extension-resource', [ - this._environmentService.extensionsPath, - this._environmentService.appRoot, - this._environmentService.extensionDevelopmentPath - ]); - registerFileProtocol(contents, 'vscode-workspace-resource', - this._contextService.getWorkspace().folders.map(folder => folder.uri.fsPath) - ); - } - public notifyFindWidgetFocusChanged(isFocused: boolean) { this._contextKey.set(isFocused || document.activeElement === this._webview); } @@ -245,15 +212,14 @@ export default class Webview { } } - private readonly _onDidClickLink = new Emitter(); public readonly onDidClickLink: Event = this._onDidClickLink.event; private readonly _onDidScroll = new Emitter<{ scrollYPercentage: number }>(); public readonly onDidScroll: Event<{ scrollYPercentage: number }> = this._onDidScroll.event; - private readonly _onFoundInPageResults = new Emitter(); - public readonly onFindResults: Event = this._onFoundInPageResults.event; + private readonly _onFoundInPageResults = new Emitter(); + public readonly onFindResults: Event = this._onFoundInPageResults.event; private readonly _onMessage = new Emitter(); public readonly onMessage: Event = this._onMessage.event; @@ -359,7 +325,25 @@ export default class Webview { return false; } - public startFind(value: string, options?: WebviewElementFindInPageOptions) { + private registerFileProtocols(contents: Electron.WebContents) { + if (!contents || contents.isDestroyed()) { + return; + } + + registerFileProtocol(contents, 'vscode-core-resource', [ + this._environmentService.appRoot + ]); + registerFileProtocol(contents, 'vscode-extension-resource', [ + this._environmentService.extensionsPath, + this._environmentService.appRoot, + this._environmentService.extensionDevelopmentPath + ]); + registerFileProtocol(contents, 'vscode-workspace-resource', + this._contextService.getWorkspace().folders.map(folder => folder.uri.fsPath) + ); + } + + public startFind(value: string, options?: Electron.FindInPageOptions) { if (!value) { return; } @@ -368,7 +352,7 @@ export default class Webview { options = options || {}; // FindNext must be false for a first request - const findOptions: WebviewElementFindInPageOptions = { + const findOptions: Electron.FindInPageOptions = { forward: options.forward, findNext: false, matchCase: options.matchCase, @@ -385,12 +369,10 @@ export default class Webview { * Successive calls to find will move forward or backward through onFindResults * depending on the supplied options. * - * @param {string} value The string to search for. Empty strings are ignored. - * @param {WebviewElementFindInPageOptions} [options] - * - * @memberOf Webview + * @param value The string to search for. Empty strings are ignored. + * @param options */ - public find(value: string, options?: WebviewElementFindInPageOptions): void { + public find(value: string, options?: Electron.FindInPageOptions): void { // Searching with an empty value will throw an exception if (!value) { return; From 57c65e2e173140a5279f8e75f529877c9aa5c0ba Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:11:26 -0800 Subject: [PATCH 09/60] Don't use default export for webview --- src/vs/workbench/api/electron-browser/mainThreadWebview.ts | 6 +++--- .../workbench/parts/extensions/browser/extensionEditor.ts | 6 +++--- src/vs/workbench/parts/html/browser/htmlPreviewPart.ts | 2 +- src/vs/workbench/parts/html/browser/webview.ts | 2 +- src/vs/workbench/parts/html/browser/webviewEditor.ts | 4 ++-- src/vs/workbench/parts/html/browser/webviewFindWidget.ts | 2 +- .../parts/update/electron-browser/releaseNotesEditor.ts | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index f6a2c26d62f..2562e932d13 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -14,7 +14,7 @@ import { IEditorModel, Position } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { WebviewEditor as BaseWebviewEditor, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from 'vs/workbench/parts/html/browser/webviewEditor'; import { Builder, Dimension } from 'vs/base/browser/builder'; -import WebView from 'vs/workbench/parts/html/browser/webview'; +import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -213,11 +213,11 @@ class WebviewEditor extends BaseWebviewEditor { this.webview.style(this.themeService.getTheme()); } - private get webview(): WebView { + private get webview(): Webview { if (!this._webview) { this._contentDisposables = dispose(this._contentDisposables); - this._webview = new WebView( + this._webview = new Webview( this.webviewContent, this._partService.getContainer(Parts.EDITOR_PART), this._environmentService, diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index f1d09a11784..2b666873d50 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -34,7 +34,7 @@ import { RatingsWidget, InstallCountWidget } from 'vs/workbench/parts/extensions import { EditorOptions } from 'vs/workbench/common/editor'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { CombinedInstallAction, UpdateAction, EnableAction, DisableAction, BuiltinStatusLabelAction, ReloadAction, MaliciousStatusLabelAction } from 'vs/workbench/parts/extensions/browser/extensionsActions'; -import WebView from 'vs/workbench/parts/html/browser/webview'; +import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; @@ -179,7 +179,7 @@ export class ExtensionEditor extends BaseEditor { private contentDisposables: IDisposable[] = []; private transientDisposables: IDisposable[] = []; private disposables: IDisposable[]; - private activeWebview: WebView; + private activeWebview: Webview; constructor( @ITelemetryService telemetryService: ITelemetryService, @@ -421,7 +421,7 @@ export class ExtensionEditor extends BaseEditor { .then(body => { const allowedBadgeProviders = this.extensionsWorkbenchService.allowedBadgeProviders; const webViewOptions = allowedBadgeProviders.length > 0 ? { allowScripts: false, allowSvgs: false, svgWhiteList: allowedBadgeProviders } : {}; - this.activeWebview = new WebView(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions, false); + this.activeWebview = new Webview(this.content, this.partService.getContainer(Parts.EDITOR_PART), this.environmentService, this.contextService, this.contextViewService, this.contextKey, this.findInputFocusContextKey, webViewOptions, false); const removeLayoutParticipant = arrays.insert(this.layoutParticipants, this.activeWebview); this.contentDisposables.push(toDisposable(removeLayoutParticipant)); diff --git a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts index 24cab9977cf..5545451d6d6 100644 --- a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts +++ b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts @@ -22,7 +22,7 @@ import { Parts, IPartService } from 'vs/workbench/services/part/common/partServi import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import Webview, { WebviewOptions } from './webview'; +import { Webview, WebviewOptions } from './webview'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { WebviewEditor } from './webviewEditor'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; diff --git a/src/vs/workbench/parts/html/browser/webview.ts b/src/vs/workbench/parts/html/browser/webview.ts index 0f96f64960b..65c4376fc92 100644 --- a/src/vs/workbench/parts/html/browser/webview.ts +++ b/src/vs/workbench/parts/html/browser/webview.ts @@ -26,7 +26,7 @@ export interface WebviewOptions { readonly enableWrappedPostMessage?: boolean; } -export default class Webview { +export class Webview { private readonly _webview: Electron.WebviewTag; private _ready: Promise; private _disposables: IDisposable[] = []; diff --git a/src/vs/workbench/parts/html/browser/webviewEditor.ts b/src/vs/workbench/parts/html/browser/webviewEditor.ts index f5c289d3928..7c407e05018 100644 --- a/src/vs/workbench/parts/html/browser/webviewEditor.ts +++ b/src/vs/workbench/parts/html/browser/webviewEditor.ts @@ -16,7 +16,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { ContextKeyExpr, IContextKey, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import WebView from './webview'; +import { Webview } from './webview'; import { Builder } from 'vs/base/browser/builder'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -37,7 +37,7 @@ export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE = new RawContextKey< export abstract class WebviewEditor extends BaseWebviewEditor { protected _webviewFocusContextKey: IContextKey; - protected _webview: WebView; + protected _webview: Webview; protected content: HTMLElement; protected contextKey: IContextKey; protected findWidgetVisible: IContextKey; diff --git a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts index 28b438e3acf..cd8f76cfb39 100644 --- a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts +++ b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts @@ -5,7 +5,7 @@ import { SimpleFindWidget } from 'vs/editor/contrib/find/simpleFindWidget'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; -import Webview from './webview'; +import { Webview } from './webview'; export class WebviewFindWidget extends SimpleFindWidget { diff --git a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts index 557d912273f..8690cd45d08 100644 --- a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts +++ b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts @@ -14,7 +14,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ReleaseNotesInput } from './releaseNotesInput'; import { EditorOptions } from 'vs/workbench/common/editor'; -import WebView from 'vs/workbench/parts/html/browser/webview'; +import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IModeService } from 'vs/editor/common/services/modeService'; import { tokenizeToString } from 'vs/editor/common/modes/textToHtmlTokenizer'; @@ -106,7 +106,7 @@ export class ReleaseNotesEditor extends WebviewEditor { const colorMap = TokenizationRegistry.getColorMap(); const css = generateTokensCSSForColorMap(colorMap); const body = renderBody(marked(text, { renderer }), css); - this._webview = new WebView( + this._webview = new Webview( this.content, this.partService.getContainer(Parts.EDITOR_PART), this.environmentService, From 7f2cdefd1dbdb6dcab3fb41cade558bd52e528b3 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:19:15 -0800 Subject: [PATCH 10/60] Cleanup webview findwidget --- .../parts/html/browser/webviewFindWidget.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts index cd8f76cfb39..f304d2f56eb 100644 --- a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts +++ b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts @@ -10,19 +10,15 @@ import { Webview } from './webview'; export class WebviewFindWidget extends SimpleFindWidget { constructor( - @IContextViewService _contextViewService: IContextViewService, - private webview: Webview + @IContextViewService contextViewService: IContextViewService, + private readonly webview: Webview ) { - super(_contextViewService); - - this.find = this.find.bind(this); - this.hide = this.hide.bind(this); - this.onInputChanged = this.onInputChanged.bind(this); + super(contextViewService); } public find(previous: boolean) { - let val = this.inputValue; - if (this.webview !== null && val) { + const val = this.inputValue; + if (val) { this.webview.find(val, { findNext: true, forward: !previous }); } } @@ -34,11 +30,7 @@ export class WebviewFindWidget extends SimpleFindWidget { } public onInputChanged() { - if (!this.webview) { - return; - } - - let val = this.inputValue; + const val = this.inputValue; if (val) { this.webview.startFind(val); } else { From 7a7e566e41fedf97283505ea078b3857aaa9fe46 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:27:02 -0800 Subject: [PATCH 11/60] Mark ids readonly --- src/vs/editor/contrib/codelens/codelensController.ts | 2 +- src/vs/editor/contrib/colorPicker/colorDetector.ts | 2 +- src/vs/editor/contrib/links/links.ts | 2 +- src/vs/editor/contrib/suggest/suggestController.ts | 2 +- src/vs/editor/contrib/suggest/suggestWidget.ts | 2 +- .../workbench/browser/parts/editor/sideBySideEditor.ts | 2 +- src/vs/workbench/common/editor.ts | 2 +- src/vs/workbench/common/editor/dataUriEditorInput.ts | 2 +- src/vs/workbench/common/editor/resourceEditorInput.ts | 2 +- src/vs/workbench/common/editor/untitledEditorInput.ts | 2 +- .../parts/extensions/browser/extensionEditor.ts | 2 +- .../electron-browser/runtimeExtensionsEditor.ts | 2 +- .../parts/files/electron-browser/views/emptyView.ts | 2 +- .../parts/files/electron-browser/views/explorerView.ts | 2 +- src/vs/workbench/parts/html/browser/htmlPreviewPart.ts | 2 +- .../parts/markers/browser/markersPanelActions.ts | 2 +- .../parts/preferences/browser/keybindingsEditor.ts | 4 ++-- .../parts/preferences/browser/preferencesEditor.ts | 10 +++++----- src/vs/workbench/parts/search/browser/searchActions.ts | 8 ++++---- src/vs/workbench/parts/search/browser/searchWidget.ts | 2 +- .../update/electron-browser/releaseNotesEditor.ts | 2 +- .../walkThrough/electron-browser/walkThroughPart.ts | 2 +- 22 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/vs/editor/contrib/codelens/codelensController.ts b/src/vs/editor/contrib/codelens/codelensController.ts index 1b23413d4d7..20909ec04d7 100644 --- a/src/vs/editor/contrib/codelens/codelensController.ts +++ b/src/vs/editor/contrib/codelens/codelensController.ts @@ -22,7 +22,7 @@ import { IModelDecorationsChangeAccessor } from 'vs/editor/common/model'; export class CodeLensContribution implements editorCommon.IEditorContribution { - private static ID: string = 'css.editor.codeLens'; + private static readonly ID: string = 'css.editor.codeLens'; private _isEnabled: boolean; diff --git a/src/vs/editor/contrib/colorPicker/colorDetector.ts b/src/vs/editor/contrib/colorPicker/colorDetector.ts index a1a967f0427..007f0e472ae 100644 --- a/src/vs/editor/contrib/colorPicker/colorDetector.ts +++ b/src/vs/editor/contrib/colorPicker/colorDetector.ts @@ -21,7 +21,7 @@ const MAX_DECORATORS = 500; export class ColorDetector implements IEditorContribution { - private static ID: string = 'editor.contrib.colorDetector'; + private static readonly ID: string = 'editor.contrib.colorDetector'; static RECOMPUTE_TIME = 1000; // ms diff --git a/src/vs/editor/contrib/links/links.ts b/src/vs/editor/contrib/links/links.ts index 87a1c0365ab..5f09afd3250 100644 --- a/src/vs/editor/contrib/links/links.ts +++ b/src/vs/editor/contrib/links/links.ts @@ -130,7 +130,7 @@ class LinkOccurrence { class LinkDetector implements editorCommon.IEditorContribution { - private static ID: string = 'editor.linkDetector'; + private static readonly ID: string = 'editor.linkDetector'; public static get(editor: ICodeEditor): LinkDetector { return editor.getContribution(LinkDetector.ID); diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index b800056c46c..7173f07aea6 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -77,7 +77,7 @@ class AcceptOnCharacterOracle { export class SuggestController implements IEditorContribution { - private static ID: string = 'editor.contrib.suggestController'; + private static readonly ID: string = 'editor.contrib.suggestController'; public static get(editor: ICodeEditor): SuggestController { return editor.getContribution(SuggestController.ID); diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 944076be107..180d53dc16a 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -343,7 +343,7 @@ export interface ISelectedSuggestion { export class SuggestWidget implements IContentWidget, IDelegate, IDisposable { - private static ID: string = 'editor.widget.suggestWidget'; + private static readonly ID: string = 'editor.widget.suggestWidget'; static LOADING_MESSAGE: string = nls.localize('suggestWidget.loading', "Loading..."); static NO_SUGGESTIONS_MESSAGE: string = nls.localize('suggestWidget.noSuggestions', "No suggestions."); diff --git a/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts b/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts index c0099581a82..fd414145054 100644 --- a/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts +++ b/src/vs/workbench/browser/parts/editor/sideBySideEditor.ts @@ -21,7 +21,7 @@ import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/br export class SideBySideEditor extends BaseEditor { - public static ID: string = 'workbench.editor.sidebysideEditor'; + public static readonly ID: string = 'workbench.editor.sidebysideEditor'; private dimension: Dimension; diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index e3fca67780a..dfbef8288f3 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -355,7 +355,7 @@ export interface IFileEditorInput extends IEditorInput, IEncodingSupport { */ export class SideBySideEditorInput extends EditorInput { - public static ID: string = 'workbench.editorinputs.sidebysideEditorInput'; + public static readonly ID: string = 'workbench.editorinputs.sidebysideEditorInput'; private _toUnbind: IDisposable[]; diff --git a/src/vs/workbench/common/editor/dataUriEditorInput.ts b/src/vs/workbench/common/editor/dataUriEditorInput.ts index 8088ecda424..c1d785bd73b 100644 --- a/src/vs/workbench/common/editor/dataUriEditorInput.ts +++ b/src/vs/workbench/common/editor/dataUriEditorInput.ts @@ -18,7 +18,7 @@ import { DataUri } from 'vs/workbench/common/resources'; */ export class DataUriEditorInput extends EditorInput { - static ID: string = 'workbench.editors.dataUriEditorInput'; + static readonly ID: string = 'workbench.editors.dataUriEditorInput'; private resource: URI; private name: string; diff --git a/src/vs/workbench/common/editor/resourceEditorInput.ts b/src/vs/workbench/common/editor/resourceEditorInput.ts index 850154f02bc..0d19259d23a 100644 --- a/src/vs/workbench/common/editor/resourceEditorInput.ts +++ b/src/vs/workbench/common/editor/resourceEditorInput.ts @@ -19,7 +19,7 @@ import { IHashService } from 'vs/workbench/services/hash/common/hashService'; */ export class ResourceEditorInput extends EditorInput { - static ID: string = 'workbench.editors.resourceEditorInput'; + static readonly ID: string = 'workbench.editors.resourceEditorInput'; private modelReference: TPromise>; private resource: URI; diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 78c322eb9fe..7583194d5ed 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -29,7 +29,7 @@ import { IHashService } from 'vs/workbench/services/hash/common/hashService'; */ export class UntitledEditorInput extends EditorInput implements IEncodingSupport { - public static ID: string = 'workbench.editors.untitledEditorInput'; + public static readonly ID: string = 'workbench.editors.untitledEditorInput'; private _hasAssociatedFilePath: boolean; private cachedModel: UntitledEditorModel; diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index 2b666873d50..ee7911ffa80 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -150,7 +150,7 @@ interface ILayoutParticipant { export class ExtensionEditor extends BaseEditor { - static ID: string = 'workbench.editor.extension'; + static readonly ID: string = 'workbench.editor.extension'; private icon: HTMLImageElement; private name: HTMLElement; diff --git a/src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts b/src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts index e6256d7aeae..fdd38bb38c6 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor.ts @@ -88,7 +88,7 @@ interface IRuntimeExtension { export class RuntimeExtensionsEditor extends BaseEditor { - static ID: string = 'workbench.editor.runtimeExtensions'; + static readonly ID: string = 'workbench.editor.runtimeExtensions'; private _list: WorkbenchList; private _profileInfo: IExtensionHostProfile; diff --git a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts index 8a89c8f3511..88a6e367512 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts @@ -25,7 +25,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur export class EmptyView extends ViewsViewletPanel { - public static ID: string = 'workbench.explorer.emptyView'; + public static readonly ID: string = 'workbench.explorer.emptyView'; public static readonly NAME = nls.localize('noWorkspace', "No Folder Opened"); private button: Button; diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts index 4c1612cbf09..822c8060e10 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts @@ -51,7 +51,7 @@ export interface IExplorerViewOptions extends IViewletViewOptions { export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView { - public static ID: string = 'workbench.explorer.fileView'; + public static readonly ID: string = 'workbench.explorer.fileView'; private static readonly EXPLORER_FILE_CHANGES_REACT_DELAY = 500; // delay in ms to react to file changes to give our internal events a chance to react first private static readonly EXPLORER_FILE_CHANGES_REFRESH_DELAY = 100; // delay in ms to refresh the explorer from disk file changes diff --git a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts index 5545451d6d6..60894b14c39 100644 --- a/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts +++ b/src/vs/workbench/parts/html/browser/htmlPreviewPart.ts @@ -34,7 +34,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace */ export class HtmlPreviewPart extends WebviewEditor { - static ID: string = 'workbench.editor.htmlPreviewPart'; + static readonly ID: string = 'workbench.editor.htmlPreviewPart'; static class: string = 'htmlPreviewPart'; private _webviewDisposables: IDisposable[]; diff --git a/src/vs/workbench/parts/markers/browser/markersPanelActions.ts b/src/vs/workbench/parts/markers/browser/markersPanelActions.ts index cf62c96da0f..09247771346 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanelActions.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanelActions.ts @@ -64,7 +64,7 @@ export class CollapseAllAction extends TreeCollapseAction { export class FilterAction extends Action { - public static ID: string = 'workbench.actions.problems.filter'; + public static readonly ID: string = 'workbench.actions.problems.filter'; constructor() { super(FilterAction.ID, Messages.MARKERS_PANEL_ACTION_TOOLTIP_FILTER, 'markers-panel-action-filter', true); diff --git a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts index 68b0c733cce..28467689ba9 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts @@ -46,7 +46,7 @@ let $ = DOM.$; export class KeybindingsEditorInput extends EditorInput { - public static ID: string = 'workbench.input.keybindings'; + public static readonly ID: string = 'workbench.input.keybindings'; public readonly keybindingsModel: KeybindingsEditorModel; constructor( @IInstantiationService instantiationService: IInstantiationService) { @@ -73,7 +73,7 @@ export class KeybindingsEditorInput extends EditorInput { export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor { - public static ID: string = 'workbench.editor.keybindings'; + public static readonly ID: string = 'workbench.editor.keybindings'; private keybindingsEditorModel: KeybindingsEditorModel; diff --git a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts index 49d0798d3bf..a51e9494010 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts @@ -64,7 +64,7 @@ import { IProgressService } from 'vs/platform/progress/common/progress'; import { ILogService } from 'vs/platform/log/common/log'; export class PreferencesEditorInput extends SideBySideEditorInput { - public static ID: string = 'workbench.editorinputs.preferencesEditorInput'; + public static readonly ID: string = 'workbench.editorinputs.preferencesEditorInput'; getTypeId(): string { return PreferencesEditorInput.ID; @@ -105,7 +105,7 @@ export class DefaultPreferencesEditorInput extends ResourceEditorInput { export class PreferencesEditor extends BaseEditor { - public static ID: string = 'workbench.editor.preferencesEditor'; + public static readonly ID: string = 'workbench.editor.preferencesEditor'; private defaultSettingsEditorContextKey: IContextKey; private focusSettingsContextKey: IContextKey; @@ -974,7 +974,7 @@ class SideBySidePreferencesWidget extends Widget { export class DefaultPreferencesEditor extends BaseTextEditor { - public static ID: string = 'workbench.editor.defaultPreferences'; + public static readonly ID: string = 'workbench.editor.defaultPreferences'; constructor( @ITelemetryService telemetryService: ITelemetryService, @@ -1150,7 +1150,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements class DefaultSettingsEditorContribution extends AbstractSettingsEditorContribution implements ISettingsEditorContribution { - static ID: string = 'editor.contrib.defaultsettings'; + static readonly ID: string = 'editor.contrib.defaultsettings'; getId(): string { return DefaultSettingsEditorContribution.ID; @@ -1171,7 +1171,7 @@ class DefaultSettingsEditorContribution extends AbstractSettingsEditorContributi class SettingsEditorContribution extends AbstractSettingsEditorContribution implements ISettingsEditorContribution { - static ID: string = 'editor.contrib.settings'; + static readonly ID: string = 'editor.contrib.settings'; constructor(editor: ICodeEditor, @IInstantiationService instantiationService: IInstantiationService, diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index ffd61a26620..d1695740015 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -297,7 +297,7 @@ export abstract class SearchAction extends Action { export class RefreshAction extends SearchAction { - static ID: string = 'search.action.refreshSearchResults'; + static readonly ID: string = 'search.action.refreshSearchResults'; static LABEL: string = nls.localize('RefreshAction.label', "Refresh"); constructor(id: string, label: string, @IViewletService viewletService: IViewletService) { @@ -322,7 +322,7 @@ export class RefreshAction extends SearchAction { export class CollapseDeepestExpandedLevelAction extends SearchAction { - static ID: string = 'search.action.collapseSearchResults'; + static readonly ID: string = 'search.action.collapseSearchResults'; static LABEL: string = nls.localize('CollapseDeepestExpandedLevelAction.label', "Collapse All"); constructor(id: string, label: string, @IViewletService viewletService: IViewletService) { @@ -356,7 +356,7 @@ export class CollapseDeepestExpandedLevelAction extends SearchAction { export class ClearSearchResultsAction extends SearchAction { - static ID: string = 'search.action.clearSearchResults'; + static readonly ID: string = 'search.action.clearSearchResults'; static LABEL: string = nls.localize('ClearSearchResultsAction.label', "Clear"); constructor(id: string, label: string, @IViewletService viewletService: IViewletService) { @@ -381,7 +381,7 @@ export class ClearSearchResultsAction extends SearchAction { export class CancelSearchAction extends SearchAction { - static ID: string = 'search.action.cancelSearch'; + static readonly ID: string = 'search.action.cancelSearch'; static LABEL: string = nls.localize('CancelSearchAction.label', "Cancel Search"); constructor(id: string, label: string, @IViewletService viewletService: IViewletService) { diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index efecc40aa67..118941a1652 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -44,7 +44,7 @@ export interface ISearchWidgetOptions { class ReplaceAllAction extends Action { private static fgInstance: ReplaceAllAction = null; - public static ID: string = 'search.action.replaceAll'; + public static readonly ID: string = 'search.action.replaceAll'; static get INSTANCE(): ReplaceAllAction { if (ReplaceAllAction.fgInstance === null) { diff --git a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts index 8690cd45d08..e1b0a6163ef 100644 --- a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts +++ b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts @@ -50,7 +50,7 @@ function renderBody( export class ReleaseNotesEditor extends WebviewEditor { - static ID: string = 'workbench.editor.releaseNotes'; + static readonly ID: string = 'workbench.editor.releaseNotes'; private contentDisposables: IDisposable[] = []; private scrollYPercentage: number = 0; diff --git a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts index 422b30d7333..2de650f4c1e 100644 --- a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts +++ b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts @@ -83,7 +83,7 @@ class WalkThroughCodeEditor extends CodeEditor { export class WalkThroughPart extends BaseEditor { - static ID: string = 'workbench.editor.walkThroughPart'; + static readonly ID: string = 'workbench.editor.walkThroughPart'; private disposables: IDisposable[] = []; private contentDisposables: IDisposable[] = []; From 427b3bbe5d54b7ac86ce1e4e789613e89fe57f47 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:35:24 -0800 Subject: [PATCH 12/60] Move webview keybindings to own file --- .../parts/html/browser/html.contribution.ts | 2 + .../html/browser/webview.contribution.ts | 53 +++++++++++++++++++ .../parts/html/browser/webviewEditor.ts | 49 ++--------------- 3 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 src/vs/workbench/parts/html/browser/webview.contribution.ts diff --git a/src/vs/workbench/parts/html/browser/html.contribution.ts b/src/vs/workbench/parts/html/browser/html.contribution.ts index f0aae61248a..6316766624e 100644 --- a/src/vs/workbench/parts/html/browser/html.contribution.ts +++ b/src/vs/workbench/parts/html/browser/html.contribution.ts @@ -20,6 +20,8 @@ import { MenuRegistry } from 'vs/platform/actions/common/actions'; import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions'; import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor'; +import './webview.contribution'; + function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI | string) { const uri = resource instanceof URI ? resource : URI.parse(resource); return accessor.get(IWorkbenchEditorService).getVisibleEditors() diff --git a/src/vs/workbench/parts/html/browser/webview.contribution.ts b/src/vs/workbench/parts/html/browser/webview.contribution.ts new file mode 100644 index 00000000000..9ba0f105685 --- /dev/null +++ b/src/vs/workbench/parts/html/browser/webview.contribution.ts @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; +import { ContextKeyExpr, } from 'vs/platform/contextkey/common/contextkey'; +import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; + +import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; +import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, ShowWebViewEditorFindTermCommand, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, HideWebViewEditorFindCommand, ShowWebViewEditorFindWidgetAction } from './webviewEditor'; +import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; +import { Registry } from 'vs/platform/registry/common/platform'; + + +const category = 'Webview'; +const actionRegistry = Registry.as(ActionExtensions.WorkbenchActions); + +actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetAction.ID, ShowWebViewEditorFindWidgetAction.LABEL, { + primary: KeyMod.CtrlCmd | KeyCode.KEY_F +}, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS), + 'Webview: Focus Find Widget', category); + + +const showNextFindTermCommand = new ShowWebViewEditorFindTermCommand({ + id: 'editor.action.webvieweditor.showNextFindTerm', + precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, + kbOpts: { + primary: KeyMod.Alt | KeyCode.DownArrow + } +}, true); +KeybindingsRegistry.registerCommandAndKeybindingRule(showNextFindTermCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); + +const showPreviousFindTermCommand = new ShowWebViewEditorFindTermCommand({ + id: 'editor.action.webvieweditor.showPreviousFindTerm', + precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, + kbOpts: { + primary: KeyMod.Alt | KeyCode.UpArrow + } +}, false); +KeybindingsRegistry.registerCommandAndKeybindingRule(showPreviousFindTermCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); + + +const hideCommand = new HideWebViewEditorFindCommand({ + id: 'editor.action.webvieweditor.hideFind', + precondition: ContextKeyExpr.and( + KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, + KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE), + kbOpts: { + primary: KeyCode.Escape + } +}); +KeybindingsRegistry.registerCommandAndKeybindingRule(hideCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); diff --git a/src/vs/workbench/parts/html/browser/webviewEditor.ts b/src/vs/workbench/parts/html/browser/webviewEditor.ts index 7c407e05018..c72d1aa76ed 100644 --- a/src/vs/workbench/parts/html/browser/webviewEditor.ts +++ b/src/vs/workbench/parts/html/browser/webviewEditor.ts @@ -12,15 +12,10 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { Command, ICommandOptions } from 'vs/editor/browser/editorExtensions'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; -import { ContextKeyExpr, IContextKey, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { IContextKey, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { Webview } from './webview'; import { Builder } from 'vs/base/browser/builder'; -import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { Action } from 'vs/base/common/actions'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -98,7 +93,7 @@ export abstract class WebviewEditor extends BaseWebviewEditor { protected abstract createEditor(parent: Builder): void; } -class ShowWebViewEditorFindWidgetAction extends Action { +export class ShowWebViewEditorFindWidgetAction extends Action { public static readonly ID = 'editor.action.webvieweditor.showFind'; public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFind', "Focus Find Widget"); @@ -127,15 +122,7 @@ class ShowWebViewEditorFindWidgetAction extends Action { } } -const category = 'Webview'; -let actionRegistry = Registry.as(ActionExtensions.WorkbenchActions); - -actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindWidgetAction.ID, ShowWebViewEditorFindWidgetAction.LABEL, { - primary: KeyMod.CtrlCmd | KeyCode.KEY_F -}, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS), - 'Webview: Focus Find Widget', category); - -class HideWebViewEditorFindCommand extends Command { +export class HideWebViewEditorFindCommand extends Command { public runCommand(accessor: ServicesAccessor, args: any): void { const webViewEditor = this.getWebViewEditor(accessor); if (webViewEditor) { @@ -151,18 +138,8 @@ class HideWebViewEditorFindCommand extends Command { return null; } } -const hideCommand = new HideWebViewEditorFindCommand({ - id: 'editor.action.webvieweditor.hideFind', - precondition: ContextKeyExpr.and( - KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, - KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE), - kbOpts: { - primary: KeyCode.Escape - } -}); -KeybindingsRegistry.registerCommandAndKeybindingRule(hideCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); -class ShowWebViewEditorFindTermCommand extends Command { +export class ShowWebViewEditorFindTermCommand extends Command { constructor(opts: ICommandOptions, private _next: boolean) { super(opts); } @@ -186,21 +163,3 @@ class ShowWebViewEditorFindTermCommand extends Command { return null; } } - -const showNextFindTermCommand = new ShowWebViewEditorFindTermCommand({ - id: 'editor.action.webvieweditor.showNextFindTerm', - precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, - kbOpts: { - primary: KeyMod.Alt | KeyCode.DownArrow - } -}, true); -KeybindingsRegistry.registerCommandAndKeybindingRule(showNextFindTermCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); - -const showPreviousFindTermCommand = new ShowWebViewEditorFindTermCommand({ - id: 'editor.action.webvieweditor.showPreviousFindTerm', - precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, - kbOpts: { - primary: KeyMod.Alt | KeyCode.UpArrow - } -}, false); -KeybindingsRegistry.registerCommandAndKeybindingRule(showPreviousFindTermCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); From 86021249798a8af7bbdbd54f0fb702c10c8f0eba Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Feb 2018 23:39:51 -0800 Subject: [PATCH 13/60] Move webview commands to own file --- .../html/browser/webview.contribution.ts | 3 +- .../parts/html/browser/webviewCommands.ts | 84 +++++++++++++++++++ .../parts/html/browser/webviewEditor.ts | 76 ----------------- 3 files changed, 86 insertions(+), 77 deletions(-) create mode 100644 src/vs/workbench/parts/html/browser/webviewCommands.ts diff --git a/src/vs/workbench/parts/html/browser/webview.contribution.ts b/src/vs/workbench/parts/html/browser/webview.contribution.ts index 9ba0f105685..a1a41b33605 100644 --- a/src/vs/workbench/parts/html/browser/webview.contribution.ts +++ b/src/vs/workbench/parts/html/browser/webview.contribution.ts @@ -8,9 +8,10 @@ import { ContextKeyExpr, } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, ShowWebViewEditorFindTermCommand, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, HideWebViewEditorFindCommand, ShowWebViewEditorFindWidgetAction } from './webviewEditor'; +import { KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from './webviewEditor'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { Registry } from 'vs/platform/registry/common/platform'; +import { ShowWebViewEditorFindWidgetAction, ShowWebViewEditorFindTermCommand, HideWebViewEditorFindCommand } from './webviewCommands'; const category = 'Webview'; diff --git a/src/vs/workbench/parts/html/browser/webviewCommands.ts b/src/vs/workbench/parts/html/browser/webviewCommands.ts new file mode 100644 index 00000000000..01c0ce9a775 --- /dev/null +++ b/src/vs/workbench/parts/html/browser/webviewCommands.ts @@ -0,0 +1,84 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as nls from 'vs/nls'; + +import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { Command, ICommandOptions } from 'vs/editor/browser/editorExtensions'; +import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { Action } from 'vs/base/common/actions'; +import { TPromise } from 'vs/base/common/winjs.base'; +import { WebviewEditor } from './webviewEditor'; + +export class ShowWebViewEditorFindWidgetAction extends Action { + public static readonly ID = 'editor.action.webvieweditor.showFind'; + public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFind', "Focus Find Widget"); + + public constructor( + id: string, + label: string, + @IWorkbenchEditorService private workbenchEditorService: IWorkbenchEditorService + ) { + super(id, label); + } + + public run(): TPromise { + const webViewEditor = this.getWebViewEditor(); + if (webViewEditor) { + webViewEditor.showFind(); + } + return null; + } + + private getWebViewEditor(): WebviewEditor { + const activeEditor = this.workbenchEditorService.getActiveEditor() as WebviewEditor; + if (activeEditor.isWebviewEditor) { + return activeEditor; + } + return null; + } +} + +export class HideWebViewEditorFindCommand extends Command { + public runCommand(accessor: ServicesAccessor, args: any): void { + const webViewEditor = this.getWebViewEditor(accessor); + if (webViewEditor) { + webViewEditor.hideFind(); + } + } + + private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor { + const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor; + if (activeEditor.isWebviewEditor) { + return activeEditor; + } + return null; + } +} + +export class ShowWebViewEditorFindTermCommand extends Command { + constructor(opts: ICommandOptions, private _next: boolean) { + super(opts); + } + + public runCommand(accessor: ServicesAccessor, args: any): void { + const webViewEditor = this.getWebViewEditor(accessor); + if (webViewEditor) { + if (this._next) { + webViewEditor.showNextFindTerm(); + } else { + webViewEditor.showPreviousFindTerm(); + } + } + } + + private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor { + const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor; + if (activeEditor.isWebviewEditor) { + return activeEditor; + } + return null; + } +} diff --git a/src/vs/workbench/parts/html/browser/webviewEditor.ts b/src/vs/workbench/parts/html/browser/webviewEditor.ts index c72d1aa76ed..9021b5f7725 100644 --- a/src/vs/workbench/parts/html/browser/webviewEditor.ts +++ b/src/vs/workbench/parts/html/browser/webviewEditor.ts @@ -3,21 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as nls from 'vs/nls'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { BaseWebviewEditor } from 'vs/workbench/browser/parts/editor/webviewEditor'; import { IStorageService } from 'vs/platform/storage/common/storage'; -import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { Command, ICommandOptions } from 'vs/editor/browser/editorExtensions'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IContextKey, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { Webview } from './webview'; import { Builder } from 'vs/base/browser/builder'; -import { Action } from 'vs/base/common/actions'; -import { TPromise } from 'vs/base/common/winjs.base'; /** A context key that is set when a webview editor has focus. */ export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS = new RawContextKey('webviewEditorFocus', false); @@ -93,73 +87,3 @@ export abstract class WebviewEditor extends BaseWebviewEditor { protected abstract createEditor(parent: Builder): void; } -export class ShowWebViewEditorFindWidgetAction extends Action { - public static readonly ID = 'editor.action.webvieweditor.showFind'; - public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFind', "Focus Find Widget"); - - public constructor( - id: string, - label: string, - @IWorkbenchEditorService private workbenchEditorService: IWorkbenchEditorService - ) { - super(id, label); - } - - public run(): TPromise { - const webViewEditor = this.getWebViewEditor(); - if (webViewEditor) { - webViewEditor.showFind(); - } - return null; - } - - private getWebViewEditor(): WebviewEditor { - const activeEditor = this.workbenchEditorService.getActiveEditor() as WebviewEditor; - if (activeEditor.isWebviewEditor) { - return activeEditor; - } - return null; - } -} - -export class HideWebViewEditorFindCommand extends Command { - public runCommand(accessor: ServicesAccessor, args: any): void { - const webViewEditor = this.getWebViewEditor(accessor); - if (webViewEditor) { - webViewEditor.hideFind(); - } - } - - private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor { - const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor; - if (activeEditor.isWebviewEditor) { - return activeEditor; - } - return null; - } -} - -export class ShowWebViewEditorFindTermCommand extends Command { - constructor(opts: ICommandOptions, private _next: boolean) { - super(opts); - } - - public runCommand(accessor: ServicesAccessor, args: any): void { - const webViewEditor = this.getWebViewEditor(accessor); - if (webViewEditor) { - if (this._next) { - webViewEditor.showNextFindTerm(); - } else { - webViewEditor.showPreviousFindTerm(); - } - } - } - - private getWebViewEditor(accessor: ServicesAccessor): WebviewEditor { - const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as WebviewEditor; - if (activeEditor.isWebviewEditor) { - return activeEditor; - } - return null; - } -} From ae15d09cbccd50204d94beaa24bca0bc0f7db470 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 15 Feb 2018 10:38:37 -0800 Subject: [PATCH 14/60] Mark injected service properties as readonly --- src/vs/editor/browser/services/bulkEdit.ts | 2 +- .../contrib/codelens/codelensController.ts | 4 ++-- .../contrib/colorPicker/colorDetector.ts | 4 ++-- .../editor/contrib/contextmenu/contextmenu.ts | 10 ++++----- src/vs/editor/contrib/find/findController.ts | 8 +++---- .../editor/contrib/find/simpleFindWidget.ts | 2 +- src/vs/editor/contrib/gotoError/gotoError.ts | 6 ++--- src/vs/editor/contrib/hover/hover.ts | 4 ++-- .../referenceSearch/referencesController.ts | 16 +++++++------- .../referenceSearch/referencesWidget.ts | 8 +++---- src/vs/editor/contrib/rename/rename.ts | 6 ++--- .../contrib/snippet/snippetController2.ts | 2 +- .../test/snippetController2.old.test.ts | 2 +- .../contrib/suggest/suggestController.ts | 6 ++--- .../editor/contrib/suggest/suggestMemory.ts | 2 +- .../accessibilityHelp/accessibilityHelp.ts | 6 ++--- .../actions/browser/menuItemActionItem.ts | 4 ++-- src/vs/platform/actions/common/actions.ts | 2 +- src/vs/platform/actions/common/menu.ts | 4 ++-- src/vs/platform/actions/common/menuService.ts | 4 ++-- .../commands/common/commandService.ts | 6 ++--- .../electron-browser/lifecycleService.ts | 8 +++---- .../platform/opener/browser/openerService.ts | 4 ++-- .../mainThreadDocumentsAndEditors.ts | 12 +++++----- .../api/electron-browser/mainThreadEditors.ts | 2 +- .../mainThreadSaveParticipant.ts | 10 ++++----- .../api/electron-browser/mainThreadTask.ts | 4 ++-- .../electron-browser/mainThreadWorkspace.ts | 6 ++--- .../browser/parts/editor/textEditor.ts | 6 ++--- .../browser/parts/views/customView.ts | 2 +- src/vs/workbench/common/resources.ts | 4 ++-- .../electron-browser/accessibility.ts | 8 +++---- .../electron-browser/terminalService.ts | 6 ++--- .../electron-browser/extensionTipsService.ts | 4 ++-- .../markers/browser/markersFileDecorations.ts | 6 ++--- .../markers/browser/markersTreeController.ts | 2 +- .../browser/keybindingsEditorContribution.ts | 6 ++--- .../parts/search/browser/openSymbolHandler.ts | 6 ++--- .../electron-browser/snippetsService.ts | 4 ++-- .../electron-browser/task.contribution.ts | 2 +- .../parts/terminal/common/terminalService.ts | 4 ++-- .../electron-browser/terminalActions.ts | 6 ++--- .../electron-browser/terminalConfigHelper.ts | 8 +++---- .../electron-browser/terminalFindWidget.ts | 4 ++-- .../electron-browser/terminalInstance.ts | 22 +++++++++---------- .../electron-browser/terminalLinkHandler.ts | 6 ++--- .../electron-browser/terminalPanel.ts | 10 ++++----- .../electron-browser/terminalService.ts | 12 +++++----- .../terminal/electron-browser/terminalTab.ts | 2 +- .../electron-browser/releaseNotesEditor.ts | 4 ++-- .../welcome/overlay/browser/welcomeOverlay.ts | 2 +- .../progress/browser/progressService2.ts | 4 ++-- 52 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/vs/editor/browser/services/bulkEdit.ts b/src/vs/editor/browser/services/bulkEdit.ts index cded7ca6be5..6753f7bb6e1 100644 --- a/src/vs/editor/browser/services/bulkEdit.ts +++ b/src/vs/editor/browser/services/bulkEdit.ts @@ -271,7 +271,7 @@ export class BulkEdit { constructor( editor: ICodeEditor, progress: IProgressRunner, - @ITextModelService private _textModelService: ITextModelService, + @ITextModelService private readonly _textModelService: ITextModelService, @optional(IFileService) private _fileService: IFileService ) { this._editor = editor; diff --git a/src/vs/editor/contrib/codelens/codelensController.ts b/src/vs/editor/contrib/codelens/codelensController.ts index 20909ec04d7..693ecec734c 100644 --- a/src/vs/editor/contrib/codelens/codelensController.ts +++ b/src/vs/editor/contrib/codelens/codelensController.ts @@ -36,8 +36,8 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { constructor( private _editor: editorBrowser.ICodeEditor, - @ICommandService private _commandService: ICommandService, - @IMessageService private _messageService: IMessageService + @ICommandService private readonly _commandService: ICommandService, + @IMessageService private readonly _messageService: IMessageService ) { this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens; diff --git a/src/vs/editor/contrib/colorPicker/colorDetector.ts b/src/vs/editor/contrib/colorPicker/colorDetector.ts index 007f0e472ae..b839e90d207 100644 --- a/src/vs/editor/contrib/colorPicker/colorDetector.ts +++ b/src/vs/editor/contrib/colorPicker/colorDetector.ts @@ -39,8 +39,8 @@ export class ColorDetector implements IEditorContribution { private _isEnabled: boolean; constructor(private _editor: ICodeEditor, - @ICodeEditorService private _codeEditorService: ICodeEditorService, - @IConfigurationService private _configurationService: IConfigurationService + @ICodeEditorService private readonly _codeEditorService: ICodeEditorService, + @IConfigurationService private readonly _configurationService: IConfigurationService ) { this._globalToDispose.push(_editor.onDidChangeModel((e) => { this._isEnabled = this.isEnabled(); diff --git a/src/vs/editor/contrib/contextmenu/contextmenu.ts b/src/vs/editor/contrib/contextmenu/contextmenu.ts index c3028475d32..f3c1ab86c25 100644 --- a/src/vs/editor/contrib/contextmenu/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/contextmenu.ts @@ -40,11 +40,11 @@ export class ContextMenuController implements IEditorContribution { constructor( editor: ICodeEditor, - @IContextMenuService private _contextMenuService: IContextMenuService, - @IContextViewService private _contextViewService: IContextViewService, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IKeybindingService private _keybindingService: IKeybindingService, - @IMenuService private _menuService: IMenuService + @IContextMenuService private readonly _contextMenuService: IContextMenuService, + @IContextViewService private readonly _contextViewService: IContextViewService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IMenuService private readonly _menuService: IMenuService ) { this._editor = editor; diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index aea6fb8abbc..334de9e40e2 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -362,10 +362,10 @@ export class FindController extends CommonFindController implements IFindControl constructor( editor: ICodeEditor, - @IContextViewService private _contextViewService: IContextViewService, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IKeybindingService private _keybindingService: IKeybindingService, - @IThemeService private _themeService: IThemeService, + @IContextViewService private readonly _contextViewService: IContextViewService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IThemeService private readonly _themeService: IThemeService, @IStorageService storageService: IStorageService, @optional(IClipboardService) clipboardService: IClipboardService ) { diff --git a/src/vs/editor/contrib/find/simpleFindWidget.ts b/src/vs/editor/contrib/find/simpleFindWidget.ts index a4216e51f39..b4c396e4e40 100644 --- a/src/vs/editor/contrib/find/simpleFindWidget.ts +++ b/src/vs/editor/contrib/find/simpleFindWidget.ts @@ -33,7 +33,7 @@ export abstract class SimpleFindWidget extends Widget { protected _updateHistoryDelayer: Delayer; constructor( - @IContextViewService private _contextViewService: IContextViewService, + @IContextViewService private readonly _contextViewService: IContextViewService, private animate: boolean = true ) { super(); diff --git a/src/vs/editor/contrib/gotoError/gotoError.ts b/src/vs/editor/contrib/gotoError/gotoError.ts index 9efd2151ada..626e4c802e8 100644 --- a/src/vs/editor/contrib/gotoError/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/gotoError.ts @@ -430,9 +430,9 @@ class MarkerController implements editorCommon.IEditorContribution { constructor( editor: ICodeEditor, - @IMarkerService private _markerService: IMarkerService, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IThemeService private _themeService: IThemeService + @IMarkerService private readonly _markerService: IMarkerService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IThemeService private readonly _themeService: IThemeService ) { this._editor = editor; this._markersNavigationVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._contextKeyService); diff --git a/src/vs/editor/contrib/hover/hover.ts b/src/vs/editor/contrib/hover/hover.ts index 047e21db91b..af7f1a66d41 100644 --- a/src/vs/editor/contrib/hover/hover.ts +++ b/src/vs/editor/contrib/hover/hover.ts @@ -56,8 +56,8 @@ export class ModesHoverController implements editorCommon.IEditorContribution { } constructor(editor: ICodeEditor, - @IOpenerService private _openerService: IOpenerService, - @IModeService private _modeService: IModeService + @IOpenerService private readonly _openerService: IOpenerService, + @IModeService private readonly _modeService: IModeService ) { this._editor = editor; diff --git a/src/vs/editor/contrib/referenceSearch/referencesController.ts b/src/vs/editor/contrib/referenceSearch/referencesController.ts index d82c3378137..0dc0f36b083 100644 --- a/src/vs/editor/contrib/referenceSearch/referencesController.ts +++ b/src/vs/editor/contrib/referenceSearch/referencesController.ts @@ -55,14 +55,14 @@ export class ReferencesController implements editorCommon.IEditorContribution { public constructor( editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService, - @IEditorService private _editorService: IEditorService, - @ITextModelService private _textModelResolverService: ITextModelService, - @IMessageService private _messageService: IMessageService, - @IInstantiationService private _instantiationService: IInstantiationService, - @IWorkspaceContextService private _contextService: IWorkspaceContextService, - @IStorageService private _storageService: IStorageService, - @IThemeService private _themeService: IThemeService, - @IConfigurationService private _configurationService: IConfigurationService, + @IEditorService private readonly _editorService: IEditorService, + @ITextModelService private readonly _textModelResolverService: ITextModelService, + @IMessageService private readonly _messageService: IMessageService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, + @IStorageService private readonly _storageService: IStorageService, + @IThemeService private readonly _themeService: IThemeService, + @IConfigurationService private readonly _configurationService: IConfigurationService, @optional(IEnvironmentService) private _environmentService: IEnvironmentService ) { this._editor = editor; diff --git a/src/vs/editor/contrib/referenceSearch/referencesWidget.ts b/src/vs/editor/contrib/referenceSearch/referencesWidget.ts index 7b0e5ee38ed..ee73377d033 100644 --- a/src/vs/editor/contrib/referenceSearch/referencesWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/referencesWidget.ts @@ -164,7 +164,7 @@ class DecorationsManager implements IDisposable { class DataSource implements tree.IDataSource { constructor( - @ITextModelService private _textModelResolverService: ITextModelService + @ITextModelService private readonly _textModelResolverService: ITextModelService ) { // } @@ -305,7 +305,7 @@ class FileReferencesTemplate { constructor( container: HTMLElement, - @IWorkspaceContextService private _contextService: IWorkspaceContextService, + @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, @optional(IEnvironmentService) private _environmentService: IEnvironmentService, @IThemeService themeService: IThemeService, ) { @@ -372,8 +372,8 @@ class Renderer implements tree.IRenderer { }; constructor( - @IWorkspaceContextService private _contextService: IWorkspaceContextService, - @IThemeService private _themeService: IThemeService, + @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, + @IThemeService private readonly _themeService: IThemeService, @optional(IEnvironmentService) private _environmentService: IEnvironmentService, ) { // diff --git a/src/vs/editor/contrib/rename/rename.ts b/src/vs/editor/contrib/rename/rename.ts index f6cbd734f42..1d7cda764c7 100644 --- a/src/vs/editor/contrib/rename/rename.ts +++ b/src/vs/editor/contrib/rename/rename.ts @@ -113,9 +113,9 @@ class RenameController implements IEditorContribution { constructor( private editor: ICodeEditor, - @IMessageService private _messageService: IMessageService, - @ITextModelService private _textModelResolverService: ITextModelService, - @IProgressService private _progressService: IProgressService, + @IMessageService private readonly _messageService: IMessageService, + @ITextModelService private readonly _textModelResolverService: ITextModelService, + @IProgressService private readonly _progressService: IProgressService, @IContextKeyService contextKeyService: IContextKeyService, @IThemeService themeService: IThemeService, @optional(IFileService) private _fileService: IFileService diff --git a/src/vs/editor/contrib/snippet/snippetController2.ts b/src/vs/editor/contrib/snippet/snippetController2.ts index eda1c4e1509..f929ab3239f 100644 --- a/src/vs/editor/contrib/snippet/snippetController2.ts +++ b/src/vs/editor/contrib/snippet/snippetController2.ts @@ -42,7 +42,7 @@ export class SnippetController2 implements IEditorContribution { constructor( private readonly _editor: ICodeEditor, - @ILogService private _logService: ILogService, + @ILogService private readonly _logService: ILogService, @IContextKeyService contextKeyService: IContextKeyService ) { this._inSnippet = SnippetController2.InSnippetMode.bindTo(contextKeyService); diff --git a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts index 6979ff09551..a7e46d98f0d 100644 --- a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts +++ b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts @@ -18,7 +18,7 @@ class TestSnippetController extends SnippetController2 { constructor( editor: ICodeEditor, - @IContextKeyService private _contextKeyService: IContextKeyService + @IContextKeyService private readonly _contextKeyService: IContextKeyService ) { super(editor, new NullLogService(), _contextKeyService); } diff --git a/src/vs/editor/contrib/suggest/suggestController.ts b/src/vs/editor/contrib/suggest/suggestController.ts index 7173f07aea6..d5b911c551c 100644 --- a/src/vs/editor/contrib/suggest/suggestController.ts +++ b/src/vs/editor/contrib/suggest/suggestController.ts @@ -90,9 +90,9 @@ export class SuggestController implements IEditorContribution { constructor( private _editor: ICodeEditor, - @ICommandService private _commandService: ICommandService, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IInstantiationService private _instantiationService: IInstantiationService, + @ICommandService private readonly _commandService: ICommandService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, ) { this._model = new SuggestModel(this._editor); this._memory = _instantiationService.createInstance(SuggestMemories, this._editor.getConfiguration().contribInfo.suggestSelection); diff --git a/src/vs/editor/contrib/suggest/suggestMemory.ts b/src/vs/editor/contrib/suggest/suggestMemory.ts index 58df1fd7179..7ead0af993a 100644 --- a/src/vs/editor/contrib/suggest/suggestMemory.ts +++ b/src/vs/editor/contrib/suggest/suggestMemory.ts @@ -177,7 +177,7 @@ export class SuggestMemories { constructor( mode: MemMode, - @IStorageService private _storageService: IStorageService + @IStorageService private readonly _storageService: IStorageService ) { this._persistSoon = new RunOnceScheduler(() => this._flush(), 3000); this.setMode(mode); diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index 44f2fca8421..7f6504e4607 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -115,9 +115,9 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { constructor( editor: ICodeEditor, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IKeybindingService private _keybindingService: IKeybindingService, - @IOpenerService private _openerService: IOpenerService + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IOpenerService private readonly _openerService: IOpenerService ) { super(); diff --git a/src/vs/platform/actions/browser/menuItemActionItem.ts b/src/vs/platform/actions/browser/menuItemActionItem.ts index 9f8e5bda400..653fbc84b9e 100644 --- a/src/vs/platform/actions/browser/menuItemActionItem.ts +++ b/src/vs/platform/actions/browser/menuItemActionItem.ts @@ -128,9 +128,9 @@ export class MenuItemActionItem extends ActionItem { constructor( public _action: MenuItemAction, - @IKeybindingService private _keybindingService: IKeybindingService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, @IMessageService protected _messageService: IMessageService, - @IContextMenuService private _contextMenuService: IContextMenuService + @IContextMenuService private readonly _contextMenuService: IContextMenuService ) { super(undefined, _action, { icon: !!(_action.class || _action.item.iconPath), label: !_action.class && !_action.item.iconPath }); } diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index f8786606a24..b1150d970f3 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -154,7 +154,7 @@ export class ExecuteCommandAction extends Action { constructor( id: string, label: string, - @ICommandService private _commandService: ICommandService) { + @ICommandService private readonly _commandService: ICommandService) { super(id, label); } diff --git a/src/vs/platform/actions/common/menu.ts b/src/vs/platform/actions/common/menu.ts index eed9d50ea4c..e9d904f3345 100644 --- a/src/vs/platform/actions/common/menu.ts +++ b/src/vs/platform/actions/common/menu.ts @@ -23,8 +23,8 @@ export class Menu implements IMenu { constructor( id: MenuId, startupSignal: TPromise, - @ICommandService private _commandService: ICommandService, - @IContextKeyService private _contextKeyService: IContextKeyService + @ICommandService private readonly _commandService: ICommandService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService ) { startupSignal.then(_ => { const menuItems = MenuRegistry.getMenuItems(id); diff --git a/src/vs/platform/actions/common/menuService.ts b/src/vs/platform/actions/common/menuService.ts index c48ef95154b..db0ec647dac 100644 --- a/src/vs/platform/actions/common/menuService.ts +++ b/src/vs/platform/actions/common/menuService.ts @@ -16,8 +16,8 @@ export class MenuService implements IMenuService { _serviceBrand: any; constructor( - @IExtensionService private _extensionService: IExtensionService, - @ICommandService private _commandService: ICommandService + @IExtensionService private readonly _extensionService: IExtensionService, + @ICommandService private readonly _commandService: ICommandService ) { // } diff --git a/src/vs/platform/commands/common/commandService.ts b/src/vs/platform/commands/common/commandService.ts index db0aff02f20..b104d7c776c 100644 --- a/src/vs/platform/commands/common/commandService.ts +++ b/src/vs/platform/commands/common/commandService.ts @@ -22,9 +22,9 @@ export class CommandService extends Disposable implements ICommandService { public readonly onWillExecuteCommand: Event = this._onWillExecuteCommand.event; constructor( - @IInstantiationService private _instantiationService: IInstantiationService, - @IExtensionService private _extensionService: IExtensionService, - @ILogService private _logService: ILogService + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IExtensionService private readonly _extensionService: IExtensionService, + @ILogService private readonly _logService: ILogService ) { super(); this._extensionService.whenInstalledExtensionsRegistered().then(value => this._extensionHostIsReady = value); diff --git a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts index 26d27676441..48d4c8dfe48 100644 --- a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts +++ b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts @@ -31,10 +31,10 @@ export class LifecycleService implements ILifecycleService { private _phaseWhen = new Map(); constructor( - @IMessageService private _messageService: IMessageService, - @IWindowService private _windowService: IWindowService, - @IStorageService private _storageService: IStorageService, - @ILogService private _logService: ILogService + @IMessageService private readonly _messageService: IMessageService, + @IWindowService private readonly _windowService: IWindowService, + @IStorageService private readonly _storageService: IStorageService, + @ILogService private readonly _logService: ILogService ) { const lastShutdownReason = this._storageService.getInteger(LifecycleService._lastShutdownReasonKey, StorageScope.WORKSPACE); this._storageService.remove(LifecycleService._lastShutdownReasonKey, StorageScope.WORKSPACE); diff --git a/src/vs/platform/opener/browser/openerService.ts b/src/vs/platform/opener/browser/openerService.ts index fa76e7730b4..83cadb145e2 100644 --- a/src/vs/platform/opener/browser/openerService.ts +++ b/src/vs/platform/opener/browser/openerService.ts @@ -22,8 +22,8 @@ export class OpenerService implements IOpenerService { _serviceBrand: any; constructor( - @IEditorService private _editorService: IEditorService, - @ICommandService private _commandService: ICommandService, + @IEditorService private readonly _editorService: IEditorService, + @ICommandService private readonly _commandService: ICommandService, @optional(ITelemetryService) private _telemetryService: ITelemetryService = NullTelemetryService ) { // diff --git a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts index ab5c345cb80..d7d1c5ea866 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts @@ -157,9 +157,9 @@ class MainThreadDocumentAndEditorStateComputer { constructor( private readonly _onDidChangeState: (delta: DocumentAndEditorStateDelta) => void, - @IModelService private _modelService: IModelService, - @ICodeEditorService private _codeEditorService: ICodeEditorService, - @IWorkbenchEditorService private _workbenchEditorService: IWorkbenchEditorService + @IModelService private readonly _modelService: IModelService, + @ICodeEditorService private readonly _codeEditorService: ICodeEditorService, + @IWorkbenchEditorService private readonly _workbenchEditorService: IWorkbenchEditorService ) { this._modelService.onModelAdded(this._updateStateOnModelAdd, this, this._toDispose); this._modelService.onModelRemoved(this._updateState, this, this._toDispose); @@ -299,9 +299,9 @@ export class MainThreadDocumentsAndEditors { constructor( extHostContext: IExtHostContext, - @IModelService private _modelService: IModelService, - @ITextFileService private _textFileService: ITextFileService, - @IWorkbenchEditorService private _workbenchEditorService: IWorkbenchEditorService, + @IModelService private readonly _modelService: IModelService, + @ITextFileService private readonly _textFileService: ITextFileService, + @IWorkbenchEditorService private readonly _workbenchEditorService: IWorkbenchEditorService, @ICodeEditorService codeEditorService: ICodeEditorService, @IModeService modeService: IModeService, @IFileService fileService: IFileService, diff --git a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts index 409e9df963d..bb0d1d1c941 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts @@ -41,7 +41,7 @@ export class MainThreadEditors implements MainThreadEditorsShape { constructor( documentsAndEditors: MainThreadDocumentsAndEditors, extHostContext: IExtHostContext, - @ICodeEditorService private _codeEditorService: ICodeEditorService, + @ICodeEditorService private readonly _codeEditorService: ICodeEditorService, @IWorkbenchEditorService workbenchEditorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @ITextModelService private readonly _textModelResolverService: ITextModelService, diff --git a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts index 83ec60aedcf..1aee0cdd391 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts @@ -179,9 +179,9 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipantParticipant class FormatOnSaveParticipant implements ISaveParticipantParticipant { constructor( - @ICodeEditorService private _editorService: ICodeEditorService, - @IEditorWorkerService private _editorWorkerService: IEditorWorkerService, - @IConfigurationService private _configurationService: IConfigurationService + @ICodeEditorService private readonly _editorService: ICodeEditorService, + @IEditorWorkerService private readonly _editorWorkerService: IEditorWorkerService, + @IConfigurationService private readonly _configurationService: IConfigurationService ) { // Nothing } @@ -288,8 +288,8 @@ export class SaveParticipant implements ISaveParticipant { constructor( extHostContext: IExtHostContext, @IInstantiationService instantiationService: IInstantiationService, - @IProgressService2 private _progressService: IProgressService2, - @ILogService private _logService: ILogService + @IProgressService2 private readonly _progressService: IProgressService2, + @ILogService private readonly _logService: ILogService ) { this._saveParticipants = [ instantiationService.createInstance(TrimWhitespaceParticipant), diff --git a/src/vs/workbench/api/electron-browser/mainThreadTask.ts b/src/vs/workbench/api/electron-browser/mainThreadTask.ts index 9980e755deb..b6bf7cc83c5 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadTask.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadTask.ts @@ -23,8 +23,8 @@ export class MainThreadTask implements MainThreadTaskShape { constructor( extHostContext: IExtHostContext, - @ITaskService private _taskService: ITaskService, - @IWorkspaceContextService private _workspaceContextServer: IWorkspaceContextService + @ITaskService private readonly _taskService: ITaskService, + @IWorkspaceContextService private readonly _workspaceContextServer: IWorkspaceContextService ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTask); this._activeHandles = Object.create(null); diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index 275298bcad4..c85997bc5d4 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -30,9 +30,9 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { @ISearchService private readonly _searchService: ISearchService, @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, @ITextFileService private readonly _textFileService: ITextFileService, - @IConfigurationService private _configurationService: IConfigurationService, - @IWorkspaceEditingService private _workspaceEditingService: IWorkspaceEditingService, - @IStatusbarService private _statusbarService: IStatusbarService + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IWorkspaceEditingService private readonly _workspaceEditingService: IWorkspaceEditingService, + @IStatusbarService private readonly _statusbarService: IStatusbarService ) { this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostWorkspace); this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose); diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 179956d9c07..13827bc1503 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -50,11 +50,11 @@ export abstract class BaseTextEditor extends BaseEditor { constructor( id: string, @ITelemetryService telemetryService: ITelemetryService, - @IInstantiationService private _instantiationService: IInstantiationService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, @IStorageService private storageService: IStorageService, - @ITextResourceConfigurationService private _configurationService: ITextResourceConfigurationService, + @ITextResourceConfigurationService private readonly _configurationService: ITextResourceConfigurationService, @IThemeService protected themeService: IThemeService, - @ITextFileService private _textFileService: ITextFileService, + @ITextFileService private readonly _textFileService: ITextFileService, @IEditorGroupService protected editorGroupService: IEditorGroupService ) { super(id, telemetryService, themeService); diff --git a/src/vs/workbench/browser/parts/views/customView.ts b/src/vs/workbench/browser/parts/views/customView.ts index 17065601c26..5381405294e 100644 --- a/src/vs/workbench/browser/parts/views/customView.ts +++ b/src/vs/workbench/browser/parts/views/customView.ts @@ -488,7 +488,7 @@ class TreeController extends WorkbenchTreeController { private treeViewId: string, private menus: Menus, @IContextMenuService private contextMenuService: IContextMenuService, - @IKeybindingService private _keybindingService: IKeybindingService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, @IConfigurationService configurationService: IConfigurationService ) { super({}, configurationService); diff --git a/src/vs/workbench/common/resources.ts b/src/vs/workbench/common/resources.ts index b4f626742fe..ce37e8b8eff 100644 --- a/src/vs/workbench/common/resources.ts +++ b/src/vs/workbench/common/resources.ts @@ -32,8 +32,8 @@ export class ResourceContextKey implements IContextKey { constructor( @IContextKeyService contextKeyService: IContextKeyService, - @IModeService private _modeService: IModeService, - @IFileService private _fileService: IFileService + @IModeService private readonly _modeService: IModeService, + @IFileService private readonly _fileService: IFileService ) { this._schemeKey = ResourceContextKey.Scheme.bindTo(contextKeyService); this._filenameKey = ResourceContextKey.Filename.bindTo(contextKeyService); diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts index bfc2994524a..a9e4ec6741e 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts @@ -82,10 +82,10 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { constructor( editor: ICodeEditor, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IKeybindingService private _keybindingService: IKeybindingService, - @IConfigurationService private _configurationService: IConfigurationService, - @IOpenerService private _openerService: IOpenerService + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IOpenerService private readonly _openerService: IOpenerService ) { super(); diff --git a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts index 1d25e068cbe..6329d0d1f7e 100644 --- a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts @@ -31,7 +31,7 @@ export class WinTerminalService implements ITerminalService { private static readonly CMD = 'cmd.exe'; constructor( - @IConfigurationService private _configurationService: IConfigurationService + @IConfigurationService private readonly _configurationService: IConfigurationService ) { } @@ -120,7 +120,7 @@ export class MacTerminalService implements ITerminalService { private static readonly OSASCRIPT = '/usr/bin/osascript'; // osascript is the AppleScript interpreter on OS X constructor( - @IConfigurationService private _configurationService: IConfigurationService + @IConfigurationService private readonly _configurationService: IConfigurationService ) { } public openTerminal(cwd?: string): void { @@ -211,7 +211,7 @@ export class LinuxTerminalService implements ITerminalService { private static readonly WAIT_MESSAGE = nls.localize('press.any.key', "Press any key to continue..."); constructor( - @IConfigurationService private _configurationService: IConfigurationService + @IConfigurationService private readonly _configurationService: IConfigurationService ) { } diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts index 0d46433a6a2..c8fe96f5fcb 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionTipsService.ts @@ -66,8 +66,8 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe private proactiveRecommendationsFetched: boolean = false; constructor( - @IExtensionGalleryService private _galleryService: IExtensionGalleryService, - @IModelService private _modelService: IModelService, + @IExtensionGalleryService private readonly _galleryService: IExtensionGalleryService, + @IModelService private readonly _modelService: IModelService, @IStorageService private storageService: IStorageService, @IChoiceService private choiceService: IChoiceService, @IExtensionManagementService private extensionsService: IExtensionManagementService, diff --git a/src/vs/workbench/parts/markers/browser/markersFileDecorations.ts b/src/vs/workbench/parts/markers/browser/markersFileDecorations.ts index 447a5f43abf..e2b8e12034c 100644 --- a/src/vs/workbench/parts/markers/browser/markersFileDecorations.ts +++ b/src/vs/workbench/parts/markers/browser/markersFileDecorations.ts @@ -60,9 +60,9 @@ class MarkersFileDecorations implements IWorkbenchContribution { private _enabled: boolean; constructor( - @IMarkerService private _markerService: IMarkerService, - @IDecorationsService private _decorationsService: IDecorationsService, - @IConfigurationService private _configurationService: IConfigurationService + @IMarkerService private readonly _markerService: IMarkerService, + @IDecorationsService private readonly _decorationsService: IDecorationsService, + @IConfigurationService private readonly _configurationService: IConfigurationService ) { // this._disposables = [ diff --git a/src/vs/workbench/parts/markers/browser/markersTreeController.ts b/src/vs/workbench/parts/markers/browser/markersTreeController.ts index 548b3fb7b6b..8c6d21f3e6a 100644 --- a/src/vs/workbench/parts/markers/browser/markersTreeController.ts +++ b/src/vs/workbench/parts/markers/browser/markersTreeController.ts @@ -21,7 +21,7 @@ export class Controller extends WorkbenchTreeController { constructor( @IContextMenuService private contextMenuService: IContextMenuService, @IMenuService private menuService: IMenuService, - @IKeybindingService private _keybindingService: IKeybindingService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, @IConfigurationService configurationService: IConfigurationService ) { super({}, configurationService); diff --git a/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts b/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts index b1bf80c1496..806ac0f38fa 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts @@ -48,7 +48,7 @@ export class DefineKeybindingController extends Disposable implements editorComm constructor( private _editor: ICodeEditor, - @IInstantiationService private _instantiationService: IInstantiationService + @IInstantiationService private readonly _instantiationService: IInstantiationService ) { super(); @@ -125,7 +125,7 @@ export class KeybindingWidgetRenderer extends Disposable { constructor( private _editor: ICodeEditor, - @IInstantiationService private _instantiationService: IInstantiationService + @IInstantiationService private readonly _instantiationService: IInstantiationService ) { super(); this._launchWidget = this._register(this._instantiationService.createInstance(FloatingClickWidget, this._editor, NLS_LAUNCH_MESSAGE, DefineKeybindingCommand.ID)); @@ -171,7 +171,7 @@ export class KeybindingEditorDecorationsRenderer extends Disposable { constructor( private _editor: ICodeEditor, - @IKeybindingService private _keybindingService: IKeybindingService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, ) { super(); diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index 88401644d73..4f1a912594e 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -34,10 +34,10 @@ class SymbolEntry extends EditorQuickOpenEntry { constructor( private _bearing: SymbolInformation, private _provider: IWorkspaceSymbolProvider, - @IConfigurationService private _configurationService: IConfigurationService, - @IWorkspaceContextService private _contextService: IWorkspaceContextService, + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, - @IEnvironmentService private _environmentService: IEnvironmentService + @IEnvironmentService private readonly _environmentService: IEnvironmentService ) { super(editorService); } diff --git a/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts b/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts index f1695bc6c63..722ba217562 100644 --- a/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts +++ b/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts @@ -298,8 +298,8 @@ export class SnippetSuggestion implements ISuggestion { export class SnippetSuggestProvider implements ISuggestSupport { constructor( - @IModeService private _modeService: IModeService, - @ISnippetsService private _snippets: ISnippetsService + @IModeService private readonly _modeService: IModeService, + @ISnippetsService private readonly _snippets: ISnippetsService ) { // } diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index 7354af78892..0fb82f1b37d 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -500,7 +500,7 @@ class TaskService implements ITaskService { @IStorageService private storageService: IStorageService, @IProgressService2 private progressService: IProgressService2, @IOpenerService private openerService: IOpenerService, - @IWindowService private _windowServive: IWindowService + @IWindowService private readonly _windowServive: IWindowService ) { this.configurationService = configurationService; this.markerService = markerService; diff --git a/src/vs/workbench/parts/terminal/common/terminalService.ts b/src/vs/workbench/parts/terminal/common/terminalService.ts index ee7e20df287..82ef1eaf3d9 100644 --- a/src/vs/workbench/parts/terminal/common/terminalService.ts +++ b/src/vs/workbench/parts/terminal/common/terminalService.ts @@ -43,9 +43,9 @@ export abstract class TerminalService implements ITerminalService { public abstract get configHelper(): ITerminalConfigHelper; constructor( - @IContextKeyService private _contextKeyService: IContextKeyService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IPanelService protected _panelService: IPanelService, - @IPartService private _partService: IPartService, + @IPartService private readonly _partService: IPartService, @ILifecycleService lifecycleService: ILifecycleService ) { this._activeTabIndex = 0; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index f3187aa043d..25ffd59fe6e 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -157,7 +157,7 @@ export abstract class BaseSendTextTerminalAction extends Action { id: string, label: string, private _text: string, - @ITerminalService private _terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } @@ -302,7 +302,7 @@ export class SplitVerticalTerminalAction extends Action { constructor( id: string, label: string, - @ITerminalService private _terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } @@ -321,7 +321,7 @@ export abstract class BaseFocusDirectionTerminalAction extends Action { constructor( id: string, label: string, private _direction: Direction, - @ITerminalService private _terminalService: ITerminalService + @ITerminalService private readonly _terminalService: ITerminalService ) { super(id, label); } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index 24a10026878..f3e549e7746 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -33,10 +33,10 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { public config: ITerminalConfiguration; public constructor( - @IConfigurationService private _configurationService: IConfigurationService, - @IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService, - @IChoiceService private _choiceService: IChoiceService, - @IStorageService private _storageService: IStorageService + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IWorkspaceConfigurationService private readonly _workspaceConfigurationService: IWorkspaceConfigurationService, + @IChoiceService private readonly _choiceService: IChoiceService, + @IStorageService private readonly _storageService: IStorageService ) { this._updateConfig(); this._configurationService.onDidChangeConfiguration(e => { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts index 431ea507364..54f6566bf1f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts @@ -13,8 +13,8 @@ export class TerminalFindWidget extends SimpleFindWidget { constructor( @IContextViewService _contextViewService: IContextViewService, - @IContextKeyService private _contextKeyService: IContextKeyService, - @ITerminalService private _terminalService: ITerminalService + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @ITerminalService private readonly _terminalService: ITerminalService ) { super(_contextViewService); this._findInputFocused = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED.bindTo(this._contextKeyService); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index e8a97b3f809..50fcaca4306 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -118,17 +118,17 @@ export class TerminalInstance implements ITerminalInstance { private _configHelper: TerminalConfigHelper, private _container: HTMLElement, private _shellLaunchConfig: IShellLaunchConfig, - @IContextKeyService private _contextKeyService: IContextKeyService, - @IKeybindingService private _keybindingService: IKeybindingService, - @IMessageService private _messageService: IMessageService, - @IPanelService private _panelService: IPanelService, - @IInstantiationService private _instantiationService: IInstantiationService, - @IClipboardService private _clipboardService: IClipboardService, - @IHistoryService private _historyService: IHistoryService, - @IThemeService private _themeService: IThemeService, - @IConfigurationResolverService private _configurationResolverService: IConfigurationResolverService, - @IWorkspaceContextService private _workspaceContextService: IWorkspaceContextService, - @IConfigurationService private _configurationService: IConfigurationService + @IContextKeyService private readonly _contextKeyService: IContextKeyService, + @IKeybindingService private readonly _keybindingService: IKeybindingService, + @IMessageService private readonly _messageService: IMessageService, + @IPanelService private readonly _panelService: IPanelService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IClipboardService private readonly _clipboardService: IClipboardService, + @IHistoryService private readonly _historyService: IHistoryService, + @IThemeService private readonly _themeService: IThemeService, + @IConfigurationResolverService private readonly _configurationResolverService: IConfigurationResolverService, + @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, + @IConfigurationService private readonly _configurationService: IConfigurationService ) { this._instanceDisposables = []; this._processDisposables = []; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts index bb1bbe0019f..21d7615761b 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts @@ -66,9 +66,9 @@ export class TerminalLinkHandler { private _xterm: any, private _platform: platform.Platform, private _initialCwd: string, - @IOpenerService private _openerService: IOpenerService, - @IConfigurationService private _configurationService: IConfigurationService, - @ITerminalService private _terminalService: ITerminalService + @IOpenerService private readonly _openerService: IOpenerService, + @IConfigurationService private readonly _configurationService: IConfigurationService, + @ITerminalService private readonly _terminalService: ITerminalService ) { const baseLocalLinkClause = _platform === platform.Platform.Windows ? winLocalLinkClause : unixLocalLinkClause; // Append line and column number regex diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index a47e312f952..a66423a6618 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -42,11 +42,11 @@ export class TerminalPanel extends Panel { private _findWidget: TerminalFindWidget; constructor( - @IConfigurationService private _configurationService: IConfigurationService, - @IContextMenuService private _contextMenuService: IContextMenuService, - @IInstantiationService private _instantiationService: IInstantiationService, - @ITerminalService private _terminalService: ITerminalService, - @ILifecycleService private _lifecycleService: ILifecycleService, + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IContextMenuService private readonly _contextMenuService: IContextMenuService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @ITerminalService private readonly _terminalService: ITerminalService, + @ILifecycleService private readonly _lifecycleService: ILifecycleService, @IThemeService protected themeService: IThemeService, @ITelemetryService telemetryService: ITelemetryService ) { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index a06d25e3e4e..df182935d06 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -38,12 +38,12 @@ export class TerminalService extends AbstractTerminalService implements ITermina @IPanelService _panelService: IPanelService, @IPartService _partService: IPartService, @ILifecycleService _lifecycleService: ILifecycleService, - @IConfigurationService private _configurationService: IConfigurationService, - @IInstantiationService private _instantiationService: IInstantiationService, - @IQuickOpenService private _quickOpenService: IQuickOpenService, - @IChoiceService private _choiceService: IChoiceService, - @IStorageService private _storageService: IStorageService, - @IMessageService private _messageService: IMessageService + @IConfigurationService private readonly _configurationService: IConfigurationService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IQuickOpenService private readonly _quickOpenService: IQuickOpenService, + @IChoiceService private readonly _choiceService: IChoiceService, + @IStorageService private readonly _storageService: IStorageService, + @IMessageService private readonly _messageService: IMessageService ) { super(_contextKeyService, _panelService, _partService, _lifecycleService); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts index 801aca5ad10..04acf742dbc 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts @@ -211,7 +211,7 @@ export class TerminalTab extends Disposable implements ITerminalTab { configHelper: TerminalConfigHelper, private _container: HTMLElement, shellLaunchConfig: IShellLaunchConfig, - @IInstantiationService private _instantiationService: IInstantiationService + @IInstantiationService private readonly _instantiationService: IInstantiationService ) { super(); this._onDisposed = new Emitter(); diff --git a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts index e1b0a6163ef..52abc7a5262 100644 --- a/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts +++ b/src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts @@ -64,8 +64,8 @@ export class ReleaseNotesEditor extends WebviewEditor { @IOpenerService private openerService: IOpenerService, @IModeService private modeService: IModeService, @IPartService private partService: IPartService, - @IContextViewService private _contextViewService: IContextViewService, - @IWorkspaceContextService private _contextService: IWorkspaceContextService + @IContextViewService private readonly _contextViewService: IContextViewService, + @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService ) { super(ReleaseNotesEditor.ID, telemetryService, themeService, storageService, contextKeyService); } diff --git a/src/vs/workbench/parts/welcome/overlay/browser/welcomeOverlay.ts b/src/vs/workbench/parts/welcome/overlay/browser/welcomeOverlay.ts index 26b5cf2c7e9..75313c3e266 100644 --- a/src/vs/workbench/parts/welcome/overlay/browser/welcomeOverlay.ts +++ b/src/vs/workbench/parts/welcome/overlay/browser/welcomeOverlay.ts @@ -149,7 +149,7 @@ class WelcomeOverlay { @IPartService private partService: IPartService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @ICommandService private commandService: ICommandService, - @IContextKeyService private _contextKeyService: IContextKeyService, + @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IKeybindingService private keybindingService: IKeybindingService ) { this._overlayVisible = OVERLAY_VISIBLE.bindTo(this._contextKeyService); diff --git a/src/vs/workbench/services/progress/browser/progressService2.ts b/src/vs/workbench/services/progress/browser/progressService2.ts index cf356213af6..b728fbc0e01 100644 --- a/src/vs/workbench/services/progress/browser/progressService2.ts +++ b/src/vs/workbench/services/progress/browser/progressService2.ts @@ -61,8 +61,8 @@ export class ProgressService2 implements IProgressService2 { private _stack: [IProgressOptions, Progress][] = []; constructor( - @IActivityService private _activityBar: IActivityService, - @IViewletService private _viewletService: IViewletService + @IActivityService private readonly _activityBar: IActivityService, + @IViewletService private readonly _viewletService: IViewletService ) { // } From 70b41f0b2dffe69f848abc0434bea9d2d11350a7 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 15 Feb 2018 11:06:53 -0800 Subject: [PATCH 15/60] Use onEditorsChanged to fire webview onBecameActive and onBecameInactive Fixes #43775 Fixes #43776 --- .../api/electron-browser/mainThreadWebview.ts | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts index 2562e932d13..1d7da64f539 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWebview.ts @@ -246,18 +246,6 @@ class WebviewEditor extends BaseWebviewEditor { } }, null, this._contentDisposables); - this._webview.onFocus(() => { - if (this.input) { - (this.input as WebviewInput).events.onFocus(); - } - }, this, this._contentDisposables); - - this._webview.onBlur(() => { - if (this.input) { - (this.input as WebviewInput).events.onBlur(); - } - }, this, this._contentDisposables); - this._contentDisposables.push(this._webview); this._contentDisposables.push(toDisposable(() => this._webview = null)); } @@ -283,7 +271,7 @@ export class MainThreadWebview implements MainThreadWebviewShape { private readonly _proxy: ExtHostWebviewsShape; private readonly _webviews = new Map(); - // private _activeWebview: WebviewInput | undefined; + private _activeWebview: WebviewInput | undefined = undefined; constructor( context: IExtHostContext, @@ -293,7 +281,7 @@ export class MainThreadWebview implements MainThreadWebviewShape { ) { this._proxy = context.getProxy(ExtHostContext.ExtHostWebviews); - _editorGroupService.onEditorsChanged(() => this.onEditorsChanged, null, this._toDispose); + _editorGroupService.onEditorsChanged(this.onEditorsChanged, this, this._toDispose); } dispose(): void { @@ -357,15 +345,31 @@ export class MainThreadWebview implements MainThreadWebviewShape { private onEditorsChanged() { const activeEditor = this._editorService.getActiveEditor(); + let newActiveWebview: WebviewInput | undefined = undefined; if (activeEditor.input instanceof WebviewInput) { - // this._activeWebview = activeEditor.input; for (const handle of map.keys(this._webviews)) { const input = this._webviews.get(handle); if (input.matches(activeEditor.input)) { - + newActiveWebview = input; + break; } } } + + if (newActiveWebview) { + if (!this._activeWebview || !newActiveWebview.matches(this._activeWebview)) { + if (this._activeWebview) { + this._activeWebview.events.onBlur(); + } + newActiveWebview.events.onFocus(); + this._activeWebview = newActiveWebview; + } + } else { + if (this._activeWebview) { + this._activeWebview.events.onBlur(); + this._activeWebview = undefined; + } + } } } From d019a5bed26cd0fc8255898bc17205d6fcdc5a8c Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 15 Feb 2018 21:49:26 +0100 Subject: [PATCH 16/60] [theming] Make contrastActiveBorder around text optional/themeable. Fixes #43761 --- src/vs/editor/common/view/editorColorRegistry.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/vs/editor/common/view/editorColorRegistry.ts b/src/vs/editor/common/view/editorColorRegistry.ts index 4960109a2ea..bec51990776 100644 --- a/src/vs/editor/common/view/editorColorRegistry.ts +++ b/src/vs/editor/common/view/editorColorRegistry.ts @@ -14,6 +14,8 @@ import { Color, RGBA } from 'vs/base/common/color'; export const editorLineHighlight = registerColor('editor.lineHighlightBackground', { dark: null, light: null, hc: null }, nls.localize('lineHighlight', 'Background color for the highlight of line at the cursor position.')); export const editorLineHighlightBorder = registerColor('editor.lineHighlightBorder', { dark: '#282828', light: '#eeeeee', hc: '#f38518' }, nls.localize('lineHighlightBorderBox', 'Background color for the border around the line at the cursor position.')); export const editorRangeHighlight = registerColor('editor.rangeHighlightBackground', { dark: '#ffffff0b', light: '#fdff0033', hc: null }, nls.localize('rangeHighlight', 'Background color of highlighted ranges, like by quick open and find features. The color must not be opaque to not hide underlying decorations.'), true); +export const editorRangeHighlightBorder = registerColor('editor.rangeHighlightBorder', { dark: null, light: null, hc: activeContrastBorder }, nls.localize('rangeHighlightBorder', 'Background color of the border around highlighted ranges.'), true); + export const editorCursorForeground = registerColor('editorCursor.foreground', { dark: '#AEAFAD', light: Color.black, hc: Color.white }, nls.localize('caret', 'Color of the editor cursor.')); export const editorCursorBackground = registerColor('editorCursor.background', null, nls.localize('editorCursorBackground', 'The background color of the editor cursor. Allows customizing the color of a character overlapped by a block cursor.')); export const editorWhitespaces = registerColor('editorWhitespace.foreground', { dark: '#e3e4e229', light: '#33333333', hc: '#e3e4e229' }, nls.localize('editorWhitespaces', 'Color of whitespace characters in the editor.')); @@ -45,7 +47,6 @@ export const overviewRulerError = registerColor('editorOverviewRuler.errorForegr export const overviewRulerWarning = registerColor('editorOverviewRuler.warningForeground', { dark: new Color(new RGBA(18, 136, 18, 0.7)), light: new Color(new RGBA(18, 136, 18, 0.7)), hc: new Color(new RGBA(50, 255, 50, 1)) }, nls.localize('overviewRuleWarning', 'Overview ruler marker color for warnings.')); export const overviewRulerInfo = registerColor('editorOverviewRuler.infoForeground', { dark: new Color(new RGBA(18, 18, 136, 0.7)), light: new Color(new RGBA(18, 18, 136, 0.7)), hc: new Color(new RGBA(50, 50, 255, 1)) }, nls.localize('overviewRuleInfo', 'Overview ruler marker color for infos.')); - // contains all color rules that used to defined in editor/browser/widget/editor.css registerThemingParticipant((theme, collector) => { let background = theme.getColor(editorBackground); @@ -56,21 +57,18 @@ registerThemingParticipant((theme, collector) => { if (foreground) { collector.addRule(`.monaco-editor, .monaco-editor .inputarea.ime-input { color: ${foreground}; }`); } - let gutter = theme.getColor(editorGutter); if (gutter) { collector.addRule(`.monaco-editor .margin { background-color: ${gutter}; }`); } - let rangeHighlight = theme.getColor(editorRangeHighlight); if (rangeHighlight) { collector.addRule(`.monaco-editor .rangeHighlight { background-color: ${rangeHighlight}; }`); } - let outline = theme.getColor(activeContrastBorder); - if (outline) { - collector.addRule(`.monaco-editor .rangeHighlight { border: 1px dotted ${outline}; }`); + let rangeHighlightBorder = theme.getColor(editorRangeHighlightBorder); + if (rangeHighlightBorder) { + collector.addRule(`.monaco-editor .rangeHighlight { border: 1px dotted ${rangeHighlightBorder}; }`); } - let invisibles = theme.getColor(editorWhitespaces); if (invisibles) { collector.addRule(`.vs-whitespace { color: ${invisibles} !important; }`); From 2a445d90d2954870e02b65c672d22c590dc40c81 Mon Sep 17 00:00:00 2001 From: Rachel Macfarlane Date: Thu, 15 Feb 2018 12:00:32 -0800 Subject: [PATCH 17/60] Tag issues generated by issue reporter, telemetry improvements --- .../issue/issueReporterMain.ts | 21 ++++++++++--------- .../issue/issueReporterModel.ts | 3 ++- .../issue/test/testReporterModel.test.ts | 3 ++- .../issue/electron-main/issueService.ts | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/vs/code/electron-browser/issue/issueReporterMain.ts b/src/vs/code/electron-browser/issue/issueReporterMain.ts index 56adfad1664..d4845ccf973 100644 --- a/src/vs/code/electron-browser/issue/issueReporterMain.ts +++ b/src/vs/code/electron-browser/issue/issueReporterMain.ts @@ -67,6 +67,7 @@ export class IssueReporter extends Disposable { private logService: ILogService; private issueReporterModel: IssueReporterModel; private shouldQueueSearch = true; + private numberOfSearchResultsDisplayed = 0; private features: IssueReporterFeatures; private receivedSystemInfo = false; private receivedPerformanceInfo = false; @@ -444,6 +445,7 @@ export class IssueReporter extends Disposable { private clearSearchResults(): void { const similarIssues = document.getElementById('similar-issues'); similarIssues.innerHTML = ''; + this.numberOfSearchResultsDisplayed = 0; } @debounce(300) @@ -520,8 +522,8 @@ export class IssueReporter extends Disposable { const issuesText = $('div.list-title'); issuesText.textContent = localize('similarIssues', "Similar issues"); - const numResultsToDisplay = results.length < 5 ? results.length : 5; - for (let i = 0; i < numResultsToDisplay; i++) { + this.numberOfSearchResultsDisplayed = results.length < 5 ? results.length : 5; + for (let i = 0; i < this.numberOfSearchResultsDisplayed; i++) { const issue = results[i]; const link = issue.state ? $('a.issue-link', { href: issue.html_url }) : $('a', { href: issue.html_url }); link.textContent = issue.title; @@ -676,14 +678,13 @@ export class IssueReporter extends Disposable { return false; } - if (this.telemetryService) { - /* __GDPR__ - "issueReporterSubmit" : { - "issueType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } - } - */ - this.telemetryService.publicLog('issueReporterSubmit', { issueType: this.issueReporterModel.getData().issueType }); - } + /* __GDPR__ + "issueReporterSubmit" : { + "issueType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }, + "numSimilarIssuesDisplayed" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } + } + */ + this.telemetryService.publicLog('issueReporterSubmit', { issueType: this.issueReporterModel.getData().issueType, numSimilarIssuesDisplayed: this.numberOfSearchResultsDisplayed }); const issueTitle = encodeURIComponent((document.getElementById('issue-title')).value); const queryStringPrefix = product.reportIssueUrl.indexOf('?') === -1 ? '?' : '&'; diff --git a/src/vs/code/electron-browser/issue/issueReporterModel.ts b/src/vs/code/electron-browser/issue/issueReporterModel.ts index 1669eaeebe2..fec01f2d9e7 100644 --- a/src/vs/code/electron-browser/issue/issueReporterModel.ts +++ b/src/vs/code/electron-browser/issue/issueReporterModel.ts @@ -73,7 +73,8 @@ ${this._data.issueDescription} VS Code version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion} OS version: ${this._data.versionInfo && this._data.versionInfo.os} -${this.getInfos()}`; +${this.getInfos()} +`; } private getIssueTypeTitle(): string { diff --git a/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts b/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts index f9a885220cb..eaeb2ae6de4 100644 --- a/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts +++ b/src/vs/code/electron-browser/issue/test/testReporterModel.test.ts @@ -39,6 +39,7 @@ undefined VS Code version: undefined OS version: undefined -`); + +`); }); }); diff --git a/src/vs/platform/issue/electron-main/issueService.ts b/src/vs/platform/issue/electron-main/issueService.ts index d706dcd5ff9..2d24cd52a83 100644 --- a/src/vs/platform/issue/electron-main/issueService.ts +++ b/src/vs/platform/issue/electron-main/issueService.ts @@ -47,7 +47,7 @@ export class IssueService implements IIssueService { }); ipcMain.on('workbenchCommand', (event, arg) => { - this._parentWindow.webContents.send('vscode:runAction', { id: arg }); + this._parentWindow.webContents.send('vscode:runAction', { id: arg, from: 'issueReporter' }); }); this._parentWindow = BrowserWindow.getFocusedWindow(); From bcda4bd73796683ac2d66cc54c2f99fb4295eafb Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 15 Feb 2018 22:23:03 +0100 Subject: [PATCH 18/60] Double color boxes appear inside style blocks in html files in 1.21. Fixes #43628 --- extensions/css/client/src/cssMain.ts | 40 ++------------------------ extensions/html/client/src/htmlMain.ts | 35 +--------------------- 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/extensions/css/client/src/cssMain.ts b/extensions/css/client/src/cssMain.ts index 5cc90fff537..a8aaa53a18a 100644 --- a/extensions/css/client/src/cssMain.ts +++ b/extensions/css/client/src/cssMain.ts @@ -8,12 +8,9 @@ import * as path from 'path'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); -import { languages, window, commands, ExtensionContext, TextDocument, ColorInformation, ColorPresentation, Color, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode'; +import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode'; import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient'; -import { ConfigurationFeature } from 'vscode-languageclient/lib/configuration.proposed'; -import { DocumentColorRequest, DocumentColorParams, ColorPresentationRequest, ColorPresentationParams } from 'vscode-languageserver-protocol/lib/protocol.colorProvider.proposed'; - // this method is called when vs code is activated export function activate(context: ExtensionContext) { @@ -43,46 +40,13 @@ export function activate(context: ExtensionContext) { // Create the language client and start the client. let client = new LanguageClient('css', localize('cssserver.name', 'CSS Language Server'), serverOptions, clientOptions); - client.registerFeature(new ConfigurationFeature(client)); + client.registerProposedFeatures(); let disposable = client.start(); // Push the disposable to the context's subscriptions so that the // client can be deactivated on extension deactivation context.subscriptions.push(disposable); - client.onReady().then(_ => { - // register color provider - context.subscriptions.push(languages.registerColorProvider(documentSelector, { - provideDocumentColors(document: TextDocument): Thenable { - let params: DocumentColorParams = { - textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document) - }; - return client.sendRequest(DocumentColorRequest.type, params).then(symbols => { - return symbols.map(symbol => { - let range = client.protocol2CodeConverter.asRange(symbol.range); - let color = new Color(symbol.color.red, symbol.color.green, symbol.color.blue, symbol.color.alpha); - return new ColorInformation(range, color); - }); - }); - }, - provideColorPresentations(color: Color, context): ColorPresentation[] | Thenable { - let params: ColorPresentationParams = { - textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(context.document), - color, - range: client.code2ProtocolConverter.asRange(context.range) - }; - return client.sendRequest(ColorPresentationRequest.type, params).then(presentations => { - return presentations.map(p => { - let presentation = new ColorPresentation(p.label); - presentation.textEdit = p.textEdit && client.protocol2CodeConverter.asTextEdit(p.textEdit); - presentation.additionalTextEdits = p.additionalTextEdits && client.protocol2CodeConverter.asTextEdits(p.additionalTextEdits); - return presentation; - }); - }); - } - })); - }); - let indentationRules = { increaseIndentPattern: /(^.*\{[^}]*$)/, decreaseIndentPattern: /^\s*\}/ diff --git a/extensions/html/client/src/htmlMain.ts b/extensions/html/client/src/htmlMain.ts index 107ac7ce11d..1ddf5f1b665 100644 --- a/extensions/html/client/src/htmlMain.ts +++ b/extensions/html/client/src/htmlMain.ts @@ -8,14 +8,12 @@ import * as path from 'path'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); -import { languages, ExtensionContext, IndentAction, Position, TextDocument, Color, ColorInformation, ColorPresentation, Range, CompletionItem, CompletionItemKind, SnippetString } from 'vscode'; +import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString } from 'vscode'; import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, TextDocumentPositionParams } from 'vscode-languageclient'; import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared'; import { activateTagClosing } from './tagClosing'; import TelemetryReporter from 'vscode-extension-telemetry'; -import { DocumentColorRequest, DocumentColorParams, ColorPresentationRequest, ColorPresentationParams } from 'vscode-languageserver-protocol/lib/protocol.colorProvider.proposed'; - namespace TagCloseRequest { export const type: RequestType = new RequestType('html/tag'); } @@ -67,37 +65,6 @@ export function activate(context: ExtensionContext) { let disposable = client.start(); toDispose.push(disposable); client.onReady().then(() => { - disposable = languages.registerColorProvider(documentSelector, { - provideDocumentColors(document: TextDocument): Thenable { - let params: DocumentColorParams = { - textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document) - }; - return client.sendRequest(DocumentColorRequest.type, params).then(symbols => { - return symbols.map(symbol => { - let range = client.protocol2CodeConverter.asRange(symbol.range); - let color = new Color(symbol.color.red, symbol.color.green, symbol.color.blue, symbol.color.alpha); - return new ColorInformation(range, color); - }); - }); - }, - provideColorPresentations(color, context): Thenable { - let params: ColorPresentationParams = { - textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(context.document), - color, - range: client.code2ProtocolConverter.asRange(context.range) - }; - return client.sendRequest(ColorPresentationRequest.type, params).then(presentations => { - return presentations.map(p => { - let presentation = new ColorPresentation(p.label); - presentation.textEdit = p.textEdit && client.protocol2CodeConverter.asTextEdit(p.textEdit); - presentation.additionalTextEdits = p.additionalTextEdits && client.protocol2CodeConverter.asTextEdits(p.additionalTextEdits); - return presentation; - }); - }); - } - }); - toDispose.push(disposable); - let tagRequestor = (document: TextDocument, position: Position) => { let param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position); return client.sendRequest(TagCloseRequest.type, param); From bffbf8b1e7bf619b7f4e3db8074d7e7d3b1799ac Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 15 Feb 2018 22:38:49 +0100 Subject: [PATCH 19/60] Clarify diffEditor.inserted/removedTextBackground (#41201) --- src/vs/platform/theme/common/colorRegistry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/platform/theme/common/colorRegistry.ts b/src/vs/platform/theme/common/colorRegistry.ts index 9adba34254f..101f117a398 100644 --- a/src/vs/platform/theme/common/colorRegistry.ts +++ b/src/vs/platform/theme/common/colorRegistry.ts @@ -269,8 +269,8 @@ export const editorActiveLinkForeground = registerColor('editorLink.activeForegr export const defaultInsertColor = new Color(new RGBA(155, 185, 85, 0.2)); export const defaultRemoveColor = new Color(new RGBA(255, 0, 0, 0.2)); -export const diffInserted = registerColor('diffEditor.insertedTextBackground', { dark: defaultInsertColor, light: defaultInsertColor, hc: null }, nls.localize('diffEditorInserted', 'Background color for text that got inserted.')); -export const diffRemoved = registerColor('diffEditor.removedTextBackground', { dark: defaultRemoveColor, light: defaultRemoveColor, hc: null }, nls.localize('diffEditorRemoved', 'Background color for text that got removed.')); +export const diffInserted = registerColor('diffEditor.insertedTextBackground', { dark: defaultInsertColor, light: defaultInsertColor, hc: null }, nls.localize('diffEditorInserted', 'Background color for text that got inserted. The color must not be opaque to not hide underlying decorations.'), true); +export const diffRemoved = registerColor('diffEditor.removedTextBackground', { dark: defaultRemoveColor, light: defaultRemoveColor, hc: null }, nls.localize('diffEditorRemoved', 'Background color for text that got removed. The color must not be opaque to not hide underlying decorations.'), true); export const diffInsertedOutline = registerColor('diffEditor.insertedTextBorder', { dark: null, light: null, hc: '#33ff2eff' }, nls.localize('diffEditorInsertedOutline', 'Outline color for the text that got inserted.')); export const diffRemovedOutline = registerColor('diffEditor.removedTextBorder', { dark: null, light: null, hc: '#FF008F' }, nls.localize('diffEditorRemovedOutline', 'Outline color for text that got removed.')); From c37e74202361008b1c6fab43898faa4f2f27b74e Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 15 Feb 2018 12:55:40 -0800 Subject: [PATCH 20/60] Hookup basic webview.viewColumn --- src/vs/vscode.proposed.d.ts | 9 +++++++-- src/vs/workbench/api/node/extHostWebview.ts | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index a13e9b98405..88767411c16 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -493,14 +493,14 @@ declare module 'vscode' { */ export interface WebviewOptions { /** - * Should scripts be enabled in the webview? + * Should scripts be enabled in the webview contetn? * * Defaults to false (scripts-disabled). */ readonly enableScripts?: boolean; /** - * Should command uris be enabled? + * Should command uris be enabled in webview content? * * Defaults to false. */ @@ -541,6 +541,11 @@ declare module 'vscode' { */ options: WebviewOptions; + /** + * The column in which the webview is showing. + */ + readonly viewColumn?: ViewColumn; + /** * Fired when the webview content posts a message. */ diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index dac84a1bfcf..97117f0b4d2 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -13,6 +13,8 @@ class ExtHostWebview implements vscode.Webview { private _html: string; private _options: vscode.WebviewOptions; private _isDisposed: boolean = false; + private _viewColumn: vscode.ViewColumn; + public readonly onMessageEmitter = new Emitter(); public readonly onMessage = this.onMessageEmitter.event; @@ -26,7 +28,10 @@ class ExtHostWebview implements vscode.Webview { constructor( private readonly _proxy: MainThreadWebviewShape, private readonly _handle: number, - ) { } + viewColumn: vscode.ViewColumn + ) { + this._viewColumn = viewColumn; + } public dispose() { if (this._isDisposed) { @@ -66,6 +71,10 @@ class ExtHostWebview implements vscode.Webview { this._proxy.$setOptions(this._handle, value); } + get viewColumn(): vscode.ViewColumn { + return this._viewColumn; + } + public postMessage(message: any): Thenable { return this._proxy.$sendMessage(this._handle, message); } @@ -86,17 +95,17 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { createWebview( title: string, - column: vscode.ViewColumn, + viewColumn: vscode.ViewColumn, options: vscode.WebviewOptions ): vscode.Webview { const handle = ExtHostWebviews._handlePool++; this._proxy.$createWebview(handle); - const webview = new ExtHostWebview(this._proxy, handle); + const webview = new ExtHostWebview(this._proxy, handle, viewColumn); this._webviews.set(handle, webview); webview.title = title; webview.options = options; - this._proxy.$show(handle, typeConverters.fromViewColumn(column)); + this._proxy.$show(handle, typeConverters.fromViewColumn(viewColumn)); return webview; } From e1f33fbb0716378651729641663de19e2c548221 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 15 Feb 2018 15:27:24 -0800 Subject: [PATCH 21/60] Rename ext host / main thread `editor` to `textEditor` Rename to make it more clear that these APIs are for `vscode.TextEditor` --- .../mainThreadDocumentsAndEditors.ts | 40 +++++++++---------- .../api/electron-browser/mainThreadEditors.ts | 4 +- src/vs/workbench/api/node/extHost.api.impl.ts | 2 +- src/vs/workbench/api/node/extHost.protocol.ts | 4 +- .../node/extHostDocumentSaveParticipant.ts | 4 +- .../api/node/extHostDocumentsAndEditors.ts | 2 +- .../workbench/api/node/extHostTextEditor.ts | 16 ++++---- .../workbench/api/node/extHostTextEditors.ts | 6 +-- .../extHostDocumentSaveParticipant.test.ts | 10 ++--- .../api/extHostTextEditor.test.ts | 4 +- .../api/extHostTextEditors.test.ts | 4 +- .../api/mainThreadEditors.test.ts | 6 +-- 12 files changed, 52 insertions(+), 50 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts index d7d1c5ea866..8322e21dfc6 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts @@ -16,7 +16,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { Position as EditorPosition, IEditor } from 'vs/platform/editor/common/editor'; import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { MainThreadDocuments } from 'vs/workbench/api/electron-browser/mainThreadDocuments'; -import { MainThreadEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors'; +import { MainThreadTextEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IFileService } from 'vs/platform/files/common/files'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; @@ -77,7 +77,7 @@ namespace delta { } } -class EditorSnapshot { +class TextEditorSnapshot { readonly id: string; @@ -95,8 +95,8 @@ class DocumentAndEditorStateDelta { constructor( readonly removedDocuments: ITextModel[], readonly addedDocuments: ITextModel[], - readonly removedEditors: EditorSnapshot[], - readonly addedEditors: EditorSnapshot[], + readonly removedEditors: TextEditorSnapshot[], + readonly addedEditors: TextEditorSnapshot[], readonly oldActiveEditor: string, readonly newActiveEditor: string, ) { @@ -124,12 +124,12 @@ class DocumentAndEditorState { if (!before) { return new DocumentAndEditorStateDelta( [], mapset.setValues(after.documents), - [], mapset.mapValues(after.editors), + [], mapset.mapValues(after.textEditors), undefined, after.activeEditor ); } const documentDelta = delta.ofSets(before.documents, after.documents); - const editorDelta = delta.ofMaps(before.editors, after.editors); + const editorDelta = delta.ofMaps(before.textEditors, after.textEditors); const oldActiveEditor = before.activeEditor !== after.activeEditor ? before.activeEditor : undefined; const newActiveEditor = before.activeEditor !== after.activeEditor ? after.activeEditor : undefined; @@ -142,7 +142,7 @@ class DocumentAndEditorState { constructor( readonly documents: Set, - readonly editors: Map, + readonly textEditors: Map, readonly activeEditor: string, ) { // @@ -206,7 +206,7 @@ class MainThreadDocumentAndEditorStateComputer { // small (fast) delta this._currentState = new DocumentAndEditorState( this._currentState.documents.add(model), - this._currentState.editors, + this._currentState.textEditors, this._currentState.activeEditor ); @@ -229,7 +229,7 @@ class MainThreadDocumentAndEditorStateComputer { // editor: only take those that have a not too large model - const editors = new Map(); + const editors = new Map(); let activeEditor: string = null; for (const editor of this._codeEditorService.listCodeEditors()) { @@ -238,7 +238,7 @@ class MainThreadDocumentAndEditorStateComputer { && !model.isDisposed() // model disposed && Boolean(this._modelService.getModel(model.uri)) // model disposing, the flag didn't flip yet but the model service already removed it ) { - const apiEditor = new EditorSnapshot(editor); + const apiEditor = new TextEditorSnapshot(editor); editors.set(apiEditor.id, apiEditor); if (editor.isFocused()) { activeEditor = apiEditor.id; @@ -285,7 +285,7 @@ export class MainThreadDocumentsAndEditors { private _toDispose: IDisposable[]; private _proxy: ExtHostDocumentsAndEditorsShape; private _stateComputer: MainThreadDocumentAndEditorStateComputer; - private _editors = <{ [id: string]: MainThreadTextEditor }>Object.create(null); + private _textEditors = <{ [id: string]: MainThreadTextEditor }>Object.create(null); private _onTextEditorAdd = new Emitter(); private _onTextEditorRemove = new Emitter(); @@ -314,15 +314,15 @@ export class MainThreadDocumentsAndEditors { const mainThreadDocuments = new MainThreadDocuments(this, extHostContext, this._modelService, modeService, this._textFileService, fileService, textModelResolverService, untitledEditorService); extHostContext.set(MainContext.MainThreadDocuments, mainThreadDocuments); - const mainThreadEditors = new MainThreadEditors(this, extHostContext, codeEditorService, this._workbenchEditorService, editorGroupService, textModelResolverService, fileService, this._modelService); - extHostContext.set(MainContext.MainThreadEditors, mainThreadEditors); + const mainThreadTextEditors = new MainThreadTextEditors(this, extHostContext, codeEditorService, this._workbenchEditorService, editorGroupService, textModelResolverService, fileService, this._modelService); + extHostContext.set(MainContext.MainThreadTextEditors, mainThreadTextEditors); // It is expected that the ctor of the state computer calls our `_onDelta`. this._stateComputer = new MainThreadDocumentAndEditorStateComputer(delta => this._onDelta(delta), _modelService, codeEditorService, _workbenchEditorService); this._toDispose = [ mainThreadDocuments, - mainThreadEditors, + mainThreadTextEditors, this._stateComputer, this._onTextEditorAdd, this._onTextEditorRemove, @@ -349,16 +349,16 @@ export class MainThreadDocumentsAndEditors { const mainThreadEditor = new MainThreadTextEditor(apiEditor.id, apiEditor.editor.getModel(), apiEditor.editor, { onGainedFocus() { }, onLostFocus() { } }, this._modelService); - this._editors[apiEditor.id] = mainThreadEditor; + this._textEditors[apiEditor.id] = mainThreadEditor; addedEditors.push(mainThreadEditor); } // removed editors for (const { id } of delta.removedEditors) { - const mainThreadEditor = this._editors[id]; + const mainThreadEditor = this._textEditors[id]; if (mainThreadEditor) { mainThreadEditor.dispose(); - delete this._editors[id]; + delete this._textEditors[id]; removedEditors.push(id); } } @@ -428,8 +428,8 @@ export class MainThreadDocumentsAndEditors { } findTextEditorIdFor(editor: IEditor): string { - for (let id in this._editors) { - if (this._editors[id].matches(editor)) { + for (let id in this._textEditors) { + if (this._textEditors[id].matches(editor)) { return id; } } @@ -437,6 +437,6 @@ export class MainThreadDocumentsAndEditors { } getEditor(id: string): MainThreadTextEditor { - return this._editors[id]; + return this._textEditors[id]; } } diff --git a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts index bb0d1d1c941..b45d2269dac 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadEditors.ts @@ -18,7 +18,7 @@ import { MainThreadTextEditor } from './mainThreadEditor'; import { ITextEditorConfigurationUpdate, TextEditorRevealType, IApplyEditsOptions, IUndoStopOptions, WorkspaceEditDto, reviveWorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; import { MainThreadDocumentsAndEditors } from './mainThreadDocumentsAndEditors'; import { equals as objectEquals } from 'vs/base/common/objects'; -import { ExtHostContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IExtHostContext } from '../node/extHost.protocol'; +import { ExtHostContext, MainThreadTextEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IExtHostContext } from '../node/extHost.protocol'; import { IRange } from 'vs/editor/common/core/range'; import { ISelection } from 'vs/editor/common/core/selection'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; @@ -28,7 +28,7 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { isCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { isResourceFileEdit } from 'vs/editor/common/modes'; -export class MainThreadEditors implements MainThreadEditorsShape { +export class MainThreadTextEditors implements MainThreadTextEditorsShape { private _proxy: ExtHostEditorsShape; private _documentsAndEditors: MainThreadDocumentsAndEditors; diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index b1db8ce0a59..50c74c0efb3 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -100,7 +100,7 @@ export function createApiFactory( const extHostDocumentsAndEditors = rpcProtocol.set(ExtHostContext.ExtHostDocumentsAndEditors, new ExtHostDocumentsAndEditors(rpcProtocol)); const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors)); const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors)); - const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadEditors))); + const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadTextEditors))); const extHostEditors = rpcProtocol.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(rpcProtocol, extHostDocumentsAndEditors)); const extHostCommands = rpcProtocol.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(rpcProtocol, extHostHeapService, extHostLogService)); const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands)); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index d3fae306747..b4715e17ff2 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -196,7 +196,7 @@ export interface ITextDocumentShowOptions { selection?: IRange; } -export interface MainThreadEditorsShape extends IDisposable { +export interface MainThreadTextEditorsShape extends IDisposable { $tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): TPromise; $registerTextEditorDecorationType(key: string, options: editorCommon.IDecorationRenderOptions): void; $removeTextEditorDecorationType(key: string): void; @@ -798,7 +798,7 @@ export const MainContext = { MainThreadDialogs: createMainId('MainThreadDiaglogs'), MainThreadDocuments: createMainId('MainThreadDocuments'), MainThreadDocumentContentProviders: createMainId('MainThreadDocumentContentProviders'), - MainThreadEditors: createMainId('MainThreadEditors'), + MainThreadTextEditors: createMainId('MainThreadTextEditors'), MainThreadErrors: createMainId('MainThreadErrors'), MainThreadTreeViews: createMainId('MainThreadTreeViews'), MainThreadLanguageFeatures: createMainId('MainThreadLanguageFeatures'), diff --git a/src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts b/src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts index d6edc95eb20..77458388e0b 100644 --- a/src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts @@ -8,7 +8,7 @@ import Event from 'vs/base/common/event'; import URI, { UriComponents } from 'vs/base/common/uri'; import { sequence, always } from 'vs/base/common/async'; import { illegalState } from 'vs/base/common/errors'; -import { ExtHostDocumentSaveParticipantShape, MainThreadEditorsShape, ResourceTextEditDto } from 'vs/workbench/api/node/extHost.protocol'; +import { ExtHostDocumentSaveParticipantShape, MainThreadTextEditorsShape, ResourceTextEditDto } from 'vs/workbench/api/node/extHost.protocol'; import { TextEdit } from 'vs/workbench/api/node/extHostTypes'; import { fromRange, TextDocumentSaveReason, EndOfLine } from 'vs/workbench/api/node/extHostTypeConverters'; import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments'; @@ -28,7 +28,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic constructor( private readonly _logService: ILogService, private readonly _documents: ExtHostDocuments, - private readonly _mainThreadEditors: MainThreadEditorsShape, + private readonly _mainThreadEditors: MainThreadTextEditorsShape, private readonly _thresholds: { timeout: number; errors: number; } = { timeout: 1500, errors: 3 } ) { // diff --git a/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts b/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts index 16f3bda684c..65be19d03aa 100644 --- a/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts +++ b/src/vs/workbench/api/node/extHostDocumentsAndEditors.ts @@ -85,7 +85,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha const documentData = this._documents.get(resource.toString()); const editor = new ExtHostTextEditor( - this._mainContext.getProxy(MainContext.MainThreadEditors), + this._mainContext.getProxy(MainContext.MainThreadTextEditors), data.id, documentData, data.selections.map(typeConverters.toSelection), diff --git a/src/vs/workbench/api/node/extHostTextEditor.ts b/src/vs/workbench/api/node/extHostTextEditor.ts index 435f64983de..6ebf86fad18 100644 --- a/src/vs/workbench/api/node/extHostTextEditor.ts +++ b/src/vs/workbench/api/node/extHostTextEditor.ts @@ -13,7 +13,7 @@ import { ExtHostDocumentData } from 'vs/workbench/api/node/extHostDocumentData'; import { Selection, Range, Position, EndOfLine, TextEditorRevealType, TextEditorLineNumbersStyle, SnippetString } from './extHostTypes'; import { ISingleEditOperation } from 'vs/editor/common/model'; import * as TypeConverters from './extHostTypeConverters'; -import { MainThreadEditorsShape, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate } from './extHost.protocol'; +import { MainThreadTextEditorsShape, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate } from './extHost.protocol'; import * as vscode from 'vscode'; import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions'; import { IRange } from 'vs/editor/common/core/range'; @@ -22,10 +22,10 @@ export class TextEditorDecorationType implements vscode.TextEditorDecorationType private static readonly _Keys = new IdGenerator('TextEditorDecorationType'); - private _proxy: MainThreadEditorsShape; + private _proxy: MainThreadTextEditorsShape; public key: string; - constructor(proxy: MainThreadEditorsShape, options: vscode.DecorationRenderOptions) { + constructor(proxy: MainThreadTextEditorsShape, options: vscode.DecorationRenderOptions) { this.key = TextEditorDecorationType._Keys.nextId(); this._proxy = proxy; this._proxy.$registerTextEditorDecorationType(this.key, /* URI vs Uri */ options); @@ -141,7 +141,7 @@ function deprecated(name: string, message: string = 'Refer to the documentation export class ExtHostTextEditorOptions implements vscode.TextEditorOptions { - private _proxy: MainThreadEditorsShape; + private _proxy: MainThreadTextEditorsShape; private _id: string; private _tabSize: number; @@ -149,7 +149,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions { private _cursorStyle: TextEditorCursorStyle; private _lineNumbers: TextEditorLineNumbersStyle; - constructor(proxy: MainThreadEditorsShape, id: string, source: IResolvedTextEditorConfiguration) { + constructor(proxy: MainThreadTextEditorsShape, id: string, source: IResolvedTextEditorConfiguration) { this._proxy = proxy; this._id = id; this._accept(source); @@ -313,7 +313,9 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions { export class ExtHostTextEditor implements vscode.TextEditor { - private readonly _proxy: MainThreadEditorsShape; + public readonly type = 'texteditor'; + + private readonly _proxy: MainThreadTextEditorsShape; private readonly _id: string; private readonly _documentData: ExtHostDocumentData; @@ -324,7 +326,7 @@ export class ExtHostTextEditor implements vscode.TextEditor { get id(): string { return this._id; } - constructor(proxy: MainThreadEditorsShape, id: string, document: ExtHostDocumentData, selections: Selection[], options: IResolvedTextEditorConfiguration, viewColumn: vscode.ViewColumn) { + constructor(proxy: MainThreadTextEditorsShape, id: string, document: ExtHostDocumentData, selections: Selection[], options: IResolvedTextEditorConfiguration, viewColumn: vscode.ViewColumn) { this._proxy = proxy; this._id = id; this._documentData = document; diff --git a/src/vs/workbench/api/node/extHostTextEditors.ts b/src/vs/workbench/api/node/extHostTextEditors.ts index c64f6c085f1..2415ce3d0b1 100644 --- a/src/vs/workbench/api/node/extHostTextEditors.ts +++ b/src/vs/workbench/api/node/extHostTextEditors.ts @@ -12,7 +12,7 @@ import * as TypeConverters from './extHostTypeConverters'; import { TextEditorDecorationType, ExtHostTextEditor } from './extHostTextEditor'; import { ExtHostDocumentsAndEditors } from './extHostDocumentsAndEditors'; import { Position as EditorPosition } from 'vs/platform/editor/common/editor'; -import { MainContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IResolvedTextEditorConfiguration, ISelectionChangeEvent, IMainContext, WorkspaceEditDto } from './extHost.protocol'; +import { MainContext, MainThreadTextEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IResolvedTextEditorConfiguration, ISelectionChangeEvent, IMainContext, WorkspaceEditDto } from './extHost.protocol'; import * as vscode from 'vscode'; export class ExtHostEditors implements ExtHostEditorsShape { @@ -30,14 +30,14 @@ export class ExtHostEditors implements ExtHostEditorsShape { readonly onDidChangeVisibleTextEditors: Event = this._onDidChangeVisibleTextEditors.event; - private _proxy: MainThreadEditorsShape; + private _proxy: MainThreadTextEditorsShape; private _extHostDocumentsAndEditors: ExtHostDocumentsAndEditors; constructor( mainContext: IMainContext, extHostDocumentsAndEditors: ExtHostDocumentsAndEditors, ) { - this._proxy = mainContext.getProxy(MainContext.MainThreadEditors); + this._proxy = mainContext.getProxy(MainContext.MainThreadTextEditors); this._extHostDocumentsAndEditors = extHostDocumentsAndEditors; this._extHostDocumentsAndEditors.onDidChangeVisibleTextEditors(e => this._onDidChangeVisibleTextEditors.fire(e)); diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts index d50d46f226a..a6b65c6508e 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts @@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors'; import { TextDocumentSaveReason, TextEdit, Position, EndOfLine } from 'vs/workbench/api/node/extHostTypes'; -import { MainThreadEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; +import { MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/node/extHostDocumentSaveParticipant'; import { SingleProxyRPCProtocol } from './testRPCProtocol'; import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles'; @@ -23,7 +23,7 @@ import { isResourceTextEdit, ResourceTextEdit } from 'vs/editor/common/modes'; suite('ExtHostDocumentSaveParticipant', () => { let resource = URI.parse('foo:bar'); - let mainThreadEditors = new class extends mock() { }; + let mainThreadEditors = new class extends mock() { }; let documents: ExtHostDocuments; let nullLogService = new NullLogService(); let nullExtensionDescription: IExtensionDescription = { @@ -264,7 +264,7 @@ suite('ExtHostDocumentSaveParticipant', () => { test('event delivery, pushEdits sync', () => { let dto: WorkspaceEditDto; - const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { + const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { $tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) { dto = _edits; return TPromise.as(true); @@ -288,7 +288,7 @@ suite('ExtHostDocumentSaveParticipant', () => { test('event delivery, concurrent change', () => { let edits: WorkspaceEditDto; - const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { + const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { $tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) { edits = _edits; return TPromise.as(true); @@ -322,7 +322,7 @@ suite('ExtHostDocumentSaveParticipant', () => { test('event delivery, two listeners -> two document states', () => { - const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { + const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock() { $tryApplyWorkspaceEdit(dto: WorkspaceEditDto) { for (const edit of dto.edits) { diff --git a/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts index 48d6e46c0c7..4ab480bbaff 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { TPromise } from 'vs/base/common/winjs.base'; import { TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes'; import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions'; -import { MainThreadEditorsShape, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate } from 'vs/workbench/api/node/extHost.protocol'; +import { MainThreadTextEditorsShape, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate } from 'vs/workbench/api/node/extHost.protocol'; import { ExtHostTextEditorOptions, ExtHostTextEditor } from 'vs/workbench/api/node/extHostTextEditor'; import { ExtHostDocumentData } from 'vs/workbench/api/node/extHostDocumentData'; import URI from 'vs/base/common/uri'; @@ -48,7 +48,7 @@ suite('ExtHostTextEditorOptions', () => { setup(() => { calls = []; - let mockProxy: MainThreadEditorsShape = { + let mockProxy: MainThreadTextEditorsShape = { dispose: undefined, $trySetOptions: (id: string, options: ITextEditorConfigurationUpdate) => { assert.equal(id, '1'); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts index 41663d277ef..8f6d051243b 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTextEditors.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { TPromise } from 'vs/base/common/winjs.base'; import * as extHostTypes from 'vs/workbench/api/node/extHostTypes'; -import { MainContext, MainThreadEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; +import { MainContext, MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol'; import URI from 'vs/base/common/uri'; import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors'; @@ -25,7 +25,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => { workspaceResourceEdits = null; let rpcProtocol = new TestRPCProtocol(); - rpcProtocol.set(MainContext.MainThreadEditors, new class extends mock() { + rpcProtocol.set(MainContext.MainThreadTextEditors, new class extends mock() { $tryApplyWorkspaceEdit(_workspaceResourceEdits: WorkspaceEditDto): TPromise { workspaceResourceEdits = _workspaceResourceEdits; return TPromise.as(true); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index 03ad3ac7926..cc6327963d0 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -17,7 +17,7 @@ import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import Event from 'vs/base/common/event'; -import { MainThreadEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors'; +import { MainThreadTextEditors } from 'vs/workbench/api/electron-browser/mainThreadEditors'; import URI from 'vs/base/common/uri'; import { Range } from 'vs/editor/common/core/range'; import { Position } from 'vs/editor/common/core/position'; @@ -33,7 +33,7 @@ suite('MainThreadEditors', () => { const resource = URI.parse('foo:bar'); let modelService: IModelService; - let editors: MainThreadEditors; + let editors: MainThreadTextEditors; const movedResources = new Map(); const createdResources = new Set(); @@ -103,7 +103,7 @@ suite('MainThreadEditors', () => { editorGroupService, ); - editors = new MainThreadEditors( + editors = new MainThreadTextEditors( documentAndEditor, SingleProxyRPCProtocol(null), codeEditorService, From 936b796aa8667de5edb536b00ce8a8e61fcebfb6 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Thu, 15 Feb 2018 17:20:09 -0800 Subject: [PATCH 22/60] Fix #43758 and failing test --- src/vs/workbench/services/search/node/searchService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 5184cf4d32c..8348a36db72 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -288,7 +288,7 @@ export class DiskSearch implements ISearchResultProvider { if (query.folderQueries) { for (const q of query.folderQueries) { - if (q.folder.scheme === Schemas.file && await pfs.exists(q.folder.path)) { + if (q.folder.scheme === Schemas.file && await pfs.exists(q.folder.fsPath)) { rawSearch.folderQueries.push({ excludePattern: q.excludePattern, includePattern: q.includePattern, From 74dec50ae43bf4996424a6ca5b0eae4f3db20bdd Mon Sep 17 00:00:00 2001 From: Sriram Desikan Date: Fri, 16 Feb 2018 08:34:49 +0530 Subject: [PATCH 23/60] Use set instead of map and set active only on primary instance --- .../electron-browser/execution.contribution.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index 60435c80426..2d6b8d5e714 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -79,24 +79,24 @@ DEFAULT_TERMINAL_LINUX_READY.then(defaultTerminalLinux => { const OPEN_IN_TERMINAL_COMMAND_ID = 'openInTerminal'; CommandsRegistry.registerCommand({ id: OPEN_IN_TERMINAL_COMMAND_ID, - handler: (accessor, resource: uri) => { + handler: (accessor, selectedResource: uri) => { const configurationService = accessor.get(IConfigurationService); const editorService = accessor.get(IWorkbenchEditorService); const fileService = accessor.get(IFileService); const integratedTerminalService = accessor.get(IIntegratedTerminalService); const terminalService = accessor.get(ITerminalService); let resources:uri[] = []; - let directoryMap:Map = new Map(); - resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService); + let directorySet:Set = new Set(); + resources = getMultiSelectedResources(selectedResource, accessor.get(IListService), editorService); return resources.map((resource) => { return fileService.resolveFile(resource).then(stat => { return stat.isDirectory ? stat.resource.fsPath : paths.dirname(stat.resource.fsPath); }).then(directoryToOpen => { - if (!directoryMap.has(directoryToOpen)) { - directoryMap.set(directoryToOpen, true); + if (!directorySet.has(directoryToOpen)) { + directorySet.add(directoryToOpen); if (configurationService.getValue().terminal.explorerKind === 'integrated') { const instance = integratedTerminalService.createInstance({ cwd: directoryToOpen }, true); - if (instance) { + if (instance && (selectedResource === resource)) { integratedTerminalService.setActiveInstance(instance); integratedTerminalService.showPanel(true); } From b27a905d2dc537c5e853b08dbb9fd7e69ca766c1 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 16 Feb 2018 10:46:34 +0100 Subject: [PATCH 24/60] Make code snapshot-friendly --- src/vs/base/browser/dom.ts | 71 ++++++++----------- src/vs/base/common/async.ts | 21 +++--- src/vs/base/common/diagnostics.ts | 2 +- src/vs/base/common/errors.ts | 3 +- src/vs/base/common/performance.js | 7 +- src/vs/base/common/platform.ts | 40 +++-------- src/vs/base/common/winjs.base.raw.js | 29 +++++--- src/vs/base/common/worker/simpleWorker.ts | 7 -- src/vs/base/node/pfs.ts | 12 +++- src/vs/base/node/processes.ts | 29 ++++---- src/vs/editor/common/core/stringBuilder.ts | 2 +- .../common/services/editorSimpleWorker.ts | 8 +-- .../electron-browser/requestService.ts | 47 ++++++------ src/vs/workbench/electron-browser/window.ts | 2 +- .../cli/electron-browser/cli.contribution.ts | 19 +++-- .../parts/debug/browser/debugActionsWidget.ts | 2 +- .../execution.contribution.ts | 6 +- .../execution/electron-browser/terminal.ts | 54 ++++++++------ .../electron-browser/terminalService.ts | 10 +-- .../electron-browser/terminalService.test.ts | 8 +-- .../parts/tasks/common/taskTemplates.ts | 14 ++-- .../electron-browser/task.contribution.ts | 4 +- .../electron-browser/terminal.contribution.ts | 8 +-- .../terminal/electron-browser/terminal.ts | 37 ++++++---- .../electron-browser/terminalService.ts | 4 +- .../electron-browser/update.contribution.ts | 3 +- .../electron-browser/gettingStarted.ts | 4 +- .../electron-browser/extensionService.ts | 22 ++++-- 28 files changed, 249 insertions(+), 226 deletions(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 8bb4ed5e331..13951c0ec24 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -251,41 +251,26 @@ export function addDisposableNonBubblingMouseOutListener(node: Element, handler: }); } -const _animationFrame = (function () { - let emulatedRequestAnimationFrame = (callback: (time: number) => void): number => { - return setTimeout(() => callback(new Date().getTime()), 0); - }; - let nativeRequestAnimationFrame: (callback: (time: number) => void) => number = - self.requestAnimationFrame - || (self).msRequestAnimationFrame - || (self).webkitRequestAnimationFrame - || (self).mozRequestAnimationFrame - || (self).oRequestAnimationFrame; - - - - let emulatedCancelAnimationFrame = (id: number) => { }; - let nativeCancelAnimationFrame: (id: number) => void = - self.cancelAnimationFrame || (self).cancelRequestAnimationFrame - || (self).msCancelAnimationFrame || (self).msCancelRequestAnimationFrame - || (self).webkitCancelAnimationFrame || (self).webkitCancelRequestAnimationFrame - || (self).mozCancelAnimationFrame || (self).mozCancelRequestAnimationFrame - || (self).oCancelAnimationFrame || (self).oCancelRequestAnimationFrame; - - let isNative = !!nativeRequestAnimationFrame; - let request = nativeRequestAnimationFrame || emulatedRequestAnimationFrame; - let cancel = nativeCancelAnimationFrame || emulatedCancelAnimationFrame; - - return { - isNative: isNative, - request: (callback: (time: number) => void): number => { - return request(callback); - }, - cancel: (id: number) => { - return cancel(id); - } - }; -})(); +interface IRequestAnimationFrame { + (callback: (time: number) => void): number; +} +let _animationFrame: IRequestAnimationFrame = null; +function doRequestAnimationFrame(callback: (time: number) => void): number { + if (!_animationFrame) { + const emulatedRequestAnimationFrame = (callback: (time: number) => void): number => { + return setTimeout(() => callback(new Date().getTime()), 0); + }; + _animationFrame = ( + self.requestAnimationFrame + || (self).msRequestAnimationFrame + || (self).webkitRequestAnimationFrame + || (self).mozRequestAnimationFrame + || (self).oRequestAnimationFrame + || emulatedRequestAnimationFrame + ); + } + return _animationFrame(callback); +} /** * Schedule a callback to be run at the next animation frame. @@ -375,7 +360,7 @@ class AnimationFrameQueueItem implements IDisposable { if (!animFrameRequested) { animFrameRequested = true; - _animationFrame.request(animationFrameRunner); + doRequestAnimationFrame(animationFrameRunner); } return item; @@ -662,7 +647,13 @@ export function createStyleSheet(container: HTMLElement = document.getElementsBy return style; } -const sharedStyle = createStyleSheet(); +let _sharedStyleSheet: HTMLStyleElement = null; +function getSharedStyleSheet(): HTMLStyleElement { + if (!_sharedStyleSheet) { + _sharedStyleSheet = createStyleSheet(); + } + return _sharedStyleSheet; +} function getDynamicStyleSheetRules(style: any) { if (style && style.sheet && style.sheet.rules) { @@ -676,7 +667,7 @@ function getDynamicStyleSheetRules(style: any) { return []; } -export function createCSSRule(selector: string, cssText: string, style: HTMLStyleElement = sharedStyle): void { +export function createCSSRule(selector: string, cssText: string, style: HTMLStyleElement = getSharedStyleSheet()): void { if (!style || !cssText) { return; } @@ -684,7 +675,7 @@ export function createCSSRule(selector: string, cssText: string, style: HTMLStyl (style.sheet).insertRule(selector + '{' + cssText + '}', 0); } -export function removeCSSRulesContainingSelector(ruleName: string, style = sharedStyle): void { +export function removeCSSRulesContainingSelector(ruleName: string, style: HTMLStyleElement = getSharedStyleSheet()): void { if (!style) { return; } @@ -699,7 +690,7 @@ export function removeCSSRulesContainingSelector(ruleName: string, style = share } for (let i = toDelete.length - 1; i >= 0; i--) { - style.sheet.deleteRule(toDelete[i]); + (style.sheet).deleteRule(toDelete[i]); } } diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index 93c6dda80c2..34247aa7796 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -6,7 +6,6 @@ 'use strict'; import * as errors from 'vs/base/common/errors'; -import * as platform from 'vs/base/common/platform'; import { Promise, TPromise, ValueCallback, ErrorCallback, ProgressCallback } from 'vs/base/common/winjs.base'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; @@ -525,7 +524,7 @@ export function setDisposableTimeout(handler: Function, timeout: number, ...args } export class TimeoutTimer extends Disposable { - private _token: platform.TimeoutToken; + private _token: number; constructor() { super(); @@ -539,14 +538,14 @@ export class TimeoutTimer extends Disposable { cancel(): void { if (this._token !== -1) { - platform.clearTimeout(this._token); + clearTimeout(this._token); this._token = -1; } } cancelAndSet(runner: () => void, timeout: number): void { this.cancel(); - this._token = platform.setTimeout(() => { + this._token = setTimeout(() => { this._token = -1; runner(); }, timeout); @@ -557,7 +556,7 @@ export class TimeoutTimer extends Disposable { // timer is already set return; } - this._token = platform.setTimeout(() => { + this._token = setTimeout(() => { this._token = -1; runner(); }, timeout); @@ -566,7 +565,7 @@ export class TimeoutTimer extends Disposable { export class IntervalTimer extends Disposable { - private _token: platform.IntervalToken; + private _token: number; constructor() { super(); @@ -580,14 +579,14 @@ export class IntervalTimer extends Disposable { cancel(): void { if (this._token !== -1) { - platform.clearInterval(this._token); + clearInterval(this._token); this._token = -1; } } cancelAndSet(runner: () => void, interval: number): void { this.cancel(); - this._token = platform.setInterval(() => { + this._token = setInterval(() => { runner(); }, interval); } @@ -595,7 +594,7 @@ export class IntervalTimer extends Disposable { export class RunOnceScheduler { - private timeoutToken: platform.TimeoutToken; + private timeoutToken: number; private runner: () => void; private timeout: number; private timeoutHandler: () => void; @@ -620,7 +619,7 @@ export class RunOnceScheduler { */ cancel(): void { if (this.isScheduled()) { - platform.clearTimeout(this.timeoutToken); + clearTimeout(this.timeoutToken); this.timeoutToken = -1; } } @@ -630,7 +629,7 @@ export class RunOnceScheduler { */ schedule(delay = this.timeout): void { this.cancel(); - this.timeoutToken = platform.setTimeout(this.timeoutHandler, delay); + this.timeoutToken = setTimeout(this.timeoutHandler, delay); } /** diff --git a/src/vs/base/common/diagnostics.ts b/src/vs/base/common/diagnostics.ts index 66c522cb3a7..7ad7daa18d4 100644 --- a/src/vs/base/common/diagnostics.ts +++ b/src/vs/base/common/diagnostics.ts @@ -62,7 +62,7 @@ export function register(what: string, fn: Function): (...args: any[]) => void { const thisArguments = allArgs.shift(); fn.apply(fn, thisArguments); if (allArgs.length > 0) { - Platform.setTimeout(doIt, 500); + setTimeout(doIt, 500); } }; doIt(); diff --git a/src/vs/base/common/errors.ts b/src/vs/base/common/errors.ts index 1d3502e4801..a3dfa070fb9 100644 --- a/src/vs/base/common/errors.ts +++ b/src/vs/base/common/errors.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import platform = require('vs/base/common/platform'); import types = require('vs/base/common/types'); import { IAction } from 'vs/base/common/actions'; import Severity from 'vs/base/common/severity'; @@ -79,7 +78,7 @@ export class ErrorHandler { this.listeners = []; this.unexpectedErrorHandler = function (e: any) { - platform.setTimeout(() => { + setTimeout(() => { if (e.stack) { throw new Error(e.message + '\n\n' + e.stack); } diff --git a/src/vs/base/common/performance.js b/src/vs/base/common/performance.js index a7ebc4c627c..a2646638ed0 100644 --- a/src/vs/base/common/performance.js +++ b/src/vs/base/common/performance.js @@ -11,7 +11,6 @@ // Because we want both instances to use the same perf-data // we store them globally // stores data as 'type','name','startTime','duration' -global._performanceEntries = global._performanceEntries || []; if (typeof define !== "function" && typeof module === "object" && typeof module.exports === "object") { // this is commonjs, fake amd @@ -23,6 +22,12 @@ if (typeof define !== "function" && typeof module === "object" && typeof module. define([], function () { + var _global = this; + if (typeof global !== 'undefined') { + _global = global; + } + _global._performanceEntries = _global._performanceEntries || []; + // const _now = global.performance && performance.now ? performance.now : Date.now const _now = Date.now; diff --git a/src/vs/base/common/platform.ts b/src/vs/base/common/platform.ts index 0306de78a92..5bee1d98f35 100644 --- a/src/vs/base/common/platform.ts +++ b/src/vs/base/common/platform.ts @@ -4,12 +4,9 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -// --- THIS FILE IS TEMPORARY UNTIL ENV.TS IS CLEANED UP. IT CAN SAFELY BE USED IN ALL TARGET EXECUTION ENVIRONMENTS (node & dom) --- - let _isWindows = false; let _isMacintosh = false; let _isLinux = false; -let _isRootUser = false; let _isNative = false; let _isWeb = false; let _locale: string = undefined; @@ -48,12 +45,11 @@ if (typeof process === 'object') { _isWindows = (process.platform === 'win32'); _isMacintosh = (process.platform === 'darwin'); _isLinux = (process.platform === 'linux'); - _isRootUser = !_isWindows && (process.getuid() === 0); - let rawNlsConfig = process.env['VSCODE_NLS_CONFIG']; + const rawNlsConfig = process.env['VSCODE_NLS_CONFIG']; if (rawNlsConfig) { try { - let nlsConfig: NLSConfig = JSON.parse(rawNlsConfig); - let resolved = nlsConfig.availableLanguages['*']; + const nlsConfig: NLSConfig = JSON.parse(rawNlsConfig); + const resolved = nlsConfig.availableLanguages['*']; _locale = nlsConfig.locale; // VSCode's default language is 'en' _language = resolved ? resolved : LANGUAGE_DEFAULT; @@ -63,7 +59,7 @@ if (typeof process === 'object') { } _isNative = true; } else if (typeof navigator === 'object') { - let userAgent = navigator.userAgent; + const userAgent = navigator.userAgent; _isWindows = userAgent.indexOf('Windows') >= 0; _isMacintosh = userAgent.indexOf('Macintosh') >= 0; _isLinux = userAgent.indexOf('Linux') >= 0; @@ -93,11 +89,14 @@ if (_isNative) { export const isWindows = _isWindows; export const isMacintosh = _isMacintosh; export const isLinux = _isLinux; -export const isRootUser = _isRootUser; export const isNative = _isNative; export const isWeb = _isWeb; export const platform = _platform; +export function isRootUser(): boolean { + return _isNative && !_isWindows && (process.getuid() === 0); +} + /** * The language used for the user interface. The format of * the string is all lower case (e.g. zh-tw for Traditional @@ -117,30 +116,9 @@ export const locale = _locale; */ export const translationsConfigFile = _translationsConfigFile; -export interface TimeoutToken { -} - -export interface IntervalToken { -} - -interface IGlobals { - Worker?: any; - setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutToken; - clearTimeout(token: TimeoutToken): void; - - setInterval(callback: (...args: any[]) => void, delay: number, ...args: any[]): IntervalToken; - clearInterval(token: IntervalToken): void; -} - -const _globals = (typeof self === 'object' ? self : global); +const _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {} as any); export const globals: any = _globals; -export const setTimeout = _globals.setTimeout.bind(_globals); -export const clearTimeout = _globals.clearTimeout.bind(_globals); - -export const setInterval = _globals.setInterval.bind(_globals); -export const clearInterval = _globals.clearInterval.bind(_globals); - export const enum OperatingSystem { Windows = 1, Macintosh = 2, diff --git a/src/vs/base/common/winjs.base.raw.js b/src/vs/base/common/winjs.base.raw.js index 0ffe0bc96cc..d827548303e 100644 --- a/src/vs/base/common/winjs.base.raw.js +++ b/src/vs/base/common/winjs.base.raw.js @@ -7,7 +7,7 @@ */ (function() { -var _modules = {}; +var _modules = Object.create(null);//{}; _modules["WinJS/Core/_WinJS"] = {}; var _winjs = function(moduleId, deps, factory) { @@ -64,11 +64,24 @@ _winjs("WinJS/Core/_BaseCoreUtils", ["WinJS/Core/_Global"], function baseCoreUti return func; } + var actualSetImmediate = null; + return { hasWinRT: hasWinRT, markSupportedForProcessing: markSupportedForProcessing, - _setImmediate: _Global.setImmediate ? _Global.setImmediate.bind(_Global) : function (handler) { - _Global.setTimeout(handler, 0); + _setImmediate: function (callback) { + // BEGIN monaco change + if (actualSetImmediate === null) { + if (_Global.setImmediate) { + actualSetImmediate = _Global.setImmediate.bind(_Global); + } else if (typeof process !== 'undefined' && typeof process.nextTick === 'function') { + actualSetImmediate = process.nextTick.bind(process); + } else { + actualSetImmediate = _Global.setTimeout.bind(_Global); + } + } + actualSetImmediate(callback); + // END monaco change } }; }); @@ -2057,15 +2070,9 @@ _winjs("WinJS/Promise", ["WinJS/Core/_Base","WinJS/Promise/_StateMachine"], func var exported = _modules["WinJS/Core/_WinJS"]; if (typeof exports === 'undefined' && typeof define === 'function' && define.amd) { - define(exported); + define([], exported); } else { module.exports = exported; } -if (typeof process !== 'undefined' && typeof process.nextTick === 'function') { - _modules["WinJS/Core/_BaseCoreUtils"]._setImmediate = function(handler) { - return process.nextTick(handler); - }; -} - -})(); \ No newline at end of file +})(); diff --git a/src/vs/base/common/worker/simpleWorker.ts b/src/vs/base/common/worker/simpleWorker.ts index 415660a12fe..ed06f5e3d63 100644 --- a/src/vs/base/common/worker/simpleWorker.ts +++ b/src/vs/base/common/worker/simpleWorker.ts @@ -339,13 +339,6 @@ export class SimpleWorkerServer { delete loaderConfig.paths['vs']; } } - let nlsConfig = loaderConfig['vs/nls']; - // We need to have pseudo translation - if (nlsConfig && nlsConfig.pseudo) { - require(['vs/nls'], function (nlsPlugin) { - nlsPlugin.setPseudoTranslation(nlsConfig.pseudo); - }); - } // Since this is in a web worker, enable catching errors loaderConfig.catchError = true; diff --git a/src/vs/base/node/pfs.ts b/src/vs/base/node/pfs.ts index 5fdb5cb0264..c16be6ca58d 100644 --- a/src/vs/base/node/pfs.ts +++ b/src/vs/base/node/pfs.ts @@ -161,8 +161,14 @@ export function fileExists(path: string): TPromise { /** * Deletes a path from disk. */ -const tmpDir = os.tmpdir(); -export function del(path: string, tmp = tmpDir): TPromise { +let _tmpDir: string = null; +function getTmpDir(): string { + if (!_tmpDir) { + _tmpDir = os.tmpdir(); + } + return _tmpDir; +} +export function del(path: string, tmp = getTmpDir()): TPromise { return nfcall(extfs.del, path, tmp); } @@ -185,4 +191,4 @@ export function whenDeleted(path: string): TPromise { } }, 1000); }); -} \ No newline at end of file +} diff --git a/src/vs/base/node/processes.ts b/src/vs/base/node/processes.ts index 7aa6034bba6..32ee843b5ae 100644 --- a/src/vs/base/node/processes.ts +++ b/src/vs/base/node/processes.ts @@ -6,9 +6,6 @@ import path = require('path'); import * as cp from 'child_process'; -import ChildProcess = cp.ChildProcess; -import exec = cp.exec; -import spawn = cp.spawn; import { fork } from 'vs/base/node/stdFork'; import nls = require('vs/nls'); import { PPromise, TPromise, TValueCallback, TProgressCallback, ErrorCallback } from 'vs/base/common/winjs.base'; @@ -40,7 +37,7 @@ function getWindowsCode(status: number): TerminateResponseCode { } } -export function terminateProcess(process: ChildProcess, cwd?: string): TerminateResponse { +export function terminateProcess(process: cp.ChildProcess, cwd?: string): TerminateResponse { if (Platform.isWindows) { try { let options: any = { @@ -80,8 +77,8 @@ export abstract class AbstractProcess { private options: CommandOptions | ForkOptions; protected shell: boolean; - private childProcess: ChildProcess; - protected childProcessPromise: TPromise; + private childProcess: cp.ChildProcess; + protected childProcessPromise: TPromise; protected terminateRequested: boolean; private static WellKnowCommands: IStringDictionary = { @@ -173,7 +170,7 @@ export abstract class AbstractProcess { if (this.args) { cmd = cmd + ' ' + this.args.join(' '); } - this.childProcess = exec(cmd, this.options, (error, stdout, stderr) => { + this.childProcess = cp.exec(cmd, this.options, (error, stdout, stderr) => { this.childProcess = null; let err: any = error; // This is tricky since executing a command shell reports error back in case the executed command return an @@ -186,7 +183,7 @@ export abstract class AbstractProcess { } }); } else { - let childProcess: ChildProcess = null; + let childProcess: cp.ChildProcess = null; let closeHandler = (data: any) => { this.childProcess = null; this.childProcessPromise = null; @@ -231,13 +228,13 @@ export abstract class AbstractProcess { } else { args.push(commandLine.join(' ')); } - childProcess = spawn(getWindowsShell(), args, options); + childProcess = cp.spawn(getWindowsShell(), args, options); } else { if (this.cmd) { - childProcess = spawn(this.cmd, this.args, this.options); + childProcess = cp.spawn(this.cmd, this.args, this.options); } else if (this.module) { - this.childProcessPromise = new TPromise((c, e, p) => { - fork(this.module, this.args, this.options, (error: any, childProcess: ChildProcess) => { + this.childProcessPromise = new TPromise((c, e, p) => { + fork(this.module, this.args, this.options, (error: any, childProcess: cp.ChildProcess) => { if (error) { e(error); ee({ terminated: this.terminateRequested, error: error }); @@ -269,7 +266,7 @@ export abstract class AbstractProcess { } protected abstract handleExec(cc: TValueCallback, pp: TProgressCallback, error: Error, stdout: Buffer, stderr: Buffer): void; - protected abstract handleSpawn(childProcess: ChildProcess, cc: TValueCallback, pp: TProgressCallback, ee: ErrorCallback, sync: boolean): void; + protected abstract handleSpawn(childProcess: cp.ChildProcess, cc: TValueCallback, pp: TProgressCallback, ee: ErrorCallback, sync: boolean): void; protected handleClose(data: any, cc: TValueCallback, pp: TProgressCallback, ee: ErrorCallback): void { // Default is to do nothing. @@ -315,7 +312,7 @@ export abstract class AbstractProcess { if (!this.shell || !Platform.isWindows) { c(false); } - let cmdShell = spawn(getWindowsShell(), ['/s', '/c']); + let cmdShell = cp.spawn(getWindowsShell(), ['/s', '/c']); cmdShell.on('error', (error: Error) => { c(true); }); @@ -353,7 +350,7 @@ export class LineProcess extends AbstractProcess { cc({ terminated: this.terminateRequested, error: error }); } - protected handleSpawn(childProcess: ChildProcess, cc: TValueCallback, pp: TProgressCallback, ee: ErrorCallback, sync: boolean): void { + protected handleSpawn(childProcess: cp.ChildProcess, cc: TValueCallback, pp: TProgressCallback, ee: ErrorCallback, sync: boolean): void { this.stdoutLineDecoder = new LineDecoder(); this.stderrLineDecoder = new LineDecoder(); childProcess.stdout.on('data', (data: Buffer) => { @@ -384,7 +381,7 @@ export interface IQueuedSender { // queue is free again to consume messages. // On Windows we always wait for the send() method to return before sending the next message // to workaround https://github.com/nodejs/node/issues/7657 (IPC can freeze process) -export function createQueuedSender(childProcess: ChildProcess | NodeJS.Process): IQueuedSender { +export function createQueuedSender(childProcess: cp.ChildProcess | NodeJS.Process): IQueuedSender { let msgQueue: string[] = []; let useQueue = false; diff --git a/src/vs/editor/common/core/stringBuilder.ts b/src/vs/editor/common/core/stringBuilder.ts index ff9ec2bedfc..e49d40e4d63 100644 --- a/src/vs/editor/common/core/stringBuilder.ts +++ b/src/vs/editor/common/core/stringBuilder.ts @@ -21,7 +21,7 @@ export interface IStringBuilder { export let createStringBuilder: (capacity: number) => IStringBuilder; -if ((self).TextDecoder) { +if (typeof TextDecoder !== 'undefined') { createStringBuilder = (capacity) => new StringBuilder(capacity); } else { createStringBuilder = (capacity) => new CompatStringBuilder(); diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 39a9e6a9280..cd669a4a94b 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -21,6 +21,7 @@ import { BasicInplaceReplace } from 'vs/editor/common/modes/supports/inplaceRepl import { getWordAtText, ensureValidWordDefinition } from 'vs/editor/common/model/wordHelper'; import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase'; import { IWordAtPosition, EndOfLineSequence } from 'vs/editor/common/model'; +import { globals } from 'vs/base/common/platform'; export interface IMirrorModel { readonly uri: URI; @@ -567,8 +568,7 @@ export function create(): IRequestHandler { return new EditorSimpleWorkerImpl(); } -var global: any = self; -let isWebWorker = (typeof global.importScripts === 'function'); -if (isWebWorker) { - global.monaco = createMonacoBaseAPI(); +if (typeof importScripts === 'function') { + // Running in a web worker + globals.monaco = createMonacoBaseAPI(); } diff --git a/src/vs/platform/request/electron-browser/requestService.ts b/src/vs/platform/request/electron-browser/requestService.ts index 27bb2bba0c2..3a65e8ea555 100644 --- a/src/vs/platform/request/electron-browser/requestService.ts +++ b/src/vs/platform/request/electron-browser/requestService.ts @@ -19,29 +19,6 @@ export class RequestService extends NodeRequestService { } } -class ArrayBufferStream extends Readable { - - private _buffer: Buffer; - private _offset: number; - private _length: number; - - constructor(arraybuffer: ArrayBuffer) { - super(); - this._buffer = new Buffer(new Uint8Array(arraybuffer)); - this._offset = 0; - this._length = this._buffer.length; - } - - _read(size: number) { - if (this._offset < this._length) { - this.push(this._buffer.slice(this._offset, (this._offset + size))); - this._offset += size; - } else { - this.push(null); - } - } -} - export const xhrRequest: IRequestFunction = (options: IRequestOptions): TPromise => { const xhr = new XMLHttpRequest(); @@ -58,7 +35,29 @@ export const xhrRequest: IRequestFunction = (options: IRequestOptions): TPromise statusCode: xhr.status, headers: getResponseHeaders(xhr) }, - stream: new ArrayBufferStream(xhr.response) + stream: new class ArrayBufferStream extends Readable { + + private _buffer: Buffer; + private _offset: number; + private _length: number; + + constructor(arraybuffer: ArrayBuffer) { + super(); + this._buffer = new Buffer(new Uint8Array(arraybuffer)); + this._offset = 0; + this._length = this._buffer.length; + } + + _read(size: number) { + if (this._offset < this._length) { + this.push(this._buffer.slice(this._offset, (this._offset + size))); + this._offset += size; + } else { + this.push(null); + } + } + + }(xhr.response) }); }; xhr.ontimeout = e => reject(new Error(`XHR timeout: ${options.timeout}ms`)); diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 034f90ae386..c84411bdb67 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -329,7 +329,7 @@ export class ElectronWindow extends Themable { if (isWindows) { isAdminPromise = import('native-is-elevated').then(isElevated => isElevated()); } else { - isAdminPromise = Promise.resolve(isRootUser); + isAdminPromise = Promise.resolve(isRootUser()); } return isAdminPromise.then(isAdmin => { diff --git a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts index af31a3e601a..9e051d49efe 100644 --- a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts +++ b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts @@ -7,6 +7,7 @@ import * as nls from 'vs/nls'; import * as path from 'path'; import * as cp from 'child_process'; import * as pfs from 'vs/base/node/pfs'; +import * as platform from 'vs/base/common/platform'; import { nfcall } from 'vs/base/common/async'; import { TPromise } from 'vs/base/common/winjs.base'; import URI from 'vs/base/common/uri'; @@ -21,11 +22,17 @@ function ignore(code: string, value: T = null): (err: any) => TPromise { return err => err.code === code ? TPromise.as(value) : TPromise.wrapError(err); } -const root = URI.parse(require.toUrl('')).fsPath; -const source = path.resolve(root, '..', 'bin', 'code'); +let _source: string = null; +function getSource(): string { + if (!_source) { + const root = URI.parse(require.toUrl('')).fsPath; + _source = path.resolve(root, '..', 'bin', 'code'); + } + return _source; +} function isAvailable(): TPromise { - return pfs.exists(source); + return pfs.exists(getSource()); } class InstallAction extends Action { @@ -61,7 +68,7 @@ class InstallAction extends Action { const createSymlink = () => { return pfs.unlink(this.target) .then(null, ignore('ENOENT')) - .then(() => pfs.symlink(source, this.target)); + .then(() => pfs.symlink(getSource(), this.target)); }; return createSymlink().then(null, err => { @@ -84,7 +91,7 @@ class InstallAction extends Action { return pfs.lstat(this.target) .then(stat => stat.isSymbolicLink()) .then(() => pfs.readlink(this.target)) - .then(link => link === source) + .then(link => link === getSource()) .then(null, ignore('ENOENT', false)); } @@ -143,7 +150,7 @@ class UninstallAction extends Action { } } -if (process.platform === 'darwin') { +if (platform.isMacintosh) { const category = nls.localize('shellCommand', "Shell Command"); const workbenchActionsRegistry = Registry.as(ActionExtensions.WorkbenchActions); diff --git a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts index 313156f9059..17762702ea3 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import 'vs/css!vs/workbench/parts/debug/browser/media/debugActionsWidget'; +import 'vs/css!./media/debugActionsWidget'; import * as errors from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; import * as browser from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index 869a9d8c7c1..42583969ac4 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -17,7 +17,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { ITerminalService as IIntegratedTerminalService, KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED } from 'vs/workbench/parts/terminal/common/terminal'; -import { DEFAULT_TERMINAL_WINDOWS, DEFAULT_TERMINAL_LINUX_READY, DEFAULT_TERMINAL_OSX, ITerminalConfiguration } from 'vs/workbench/parts/execution/electron-browser/terminal'; +import { getDefaultTerminalWindows, getDefaultTerminalLinuxReady, DEFAULT_TERMINAL_OSX, ITerminalConfiguration } from 'vs/workbench/parts/execution/electron-browser/terminal'; import { WinTerminalService, MacTerminalService, LinuxTerminalService } from 'vs/workbench/parts/execution/electron-browser/terminalService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { ResourceContextKey } from 'vs/workbench/common/resources'; @@ -36,7 +36,7 @@ if (env.isWindows) { registerSingleton(ITerminalService, LinuxTerminalService); } -DEFAULT_TERMINAL_LINUX_READY.then(defaultTerminalLinux => { +getDefaultTerminalLinuxReady().then(defaultTerminalLinux => { let configurationRegistry = Registry.as(Extensions.Configuration); configurationRegistry.registerConfiguration({ 'id': 'externalTerminal', @@ -57,7 +57,7 @@ DEFAULT_TERMINAL_LINUX_READY.then(defaultTerminalLinux => { 'terminal.external.windowsExec': { 'type': 'string', 'description': nls.localize('terminal.external.windowsExec', "Customizes which terminal to run on Windows."), - 'default': DEFAULT_TERMINAL_WINDOWS, + 'default': getDefaultTerminalWindows(), 'isExecutable': true }, 'terminal.external.osxExec': { diff --git a/src/vs/workbench/parts/execution/electron-browser/terminal.ts b/src/vs/workbench/parts/execution/electron-browser/terminal.ts index 9ddb4c6369e..7dd4a07cb4b 100644 --- a/src/vs/workbench/parts/execution/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/execution/electron-browser/terminal.ts @@ -8,32 +8,44 @@ import env = require('vs/base/common/platform'); import * as pfs from 'vs/base/node/pfs'; import { TPromise } from 'vs/base/common/winjs.base'; -export const DEFAULT_TERMINAL_LINUX_READY = new TPromise(c => { - if (env.isLinux) { - TPromise.join([pfs.exists('/etc/debian_version'), process.lazyEnv]).then(([isDebian]) => { - if (isDebian) { - c('x-terminal-emulator'); - } else if (process.env.DESKTOP_SESSION === 'gnome' || process.env.DESKTOP_SESSION === 'gnome-classic') { - c('gnome-terminal'); - } else if (process.env.DESKTOP_SESSION === 'kde-plasma') { - c('konsole'); - } else if (process.env.COLORTERM) { - c(process.env.COLORTERM); - } else if (process.env.TERM) { - c(process.env.TERM); - } else { - c('xterm'); +let _DEFAULT_TERMINAL_LINUX_READY: TPromise = null; +export function getDefaultTerminalLinuxReady(): TPromise { + if (!_DEFAULT_TERMINAL_LINUX_READY) { + _DEFAULT_TERMINAL_LINUX_READY = new TPromise(c => { + if (env.isLinux) { + TPromise.join([pfs.exists('/etc/debian_version'), process.lazyEnv]).then(([isDebian]) => { + if (isDebian) { + c('x-terminal-emulator'); + } else if (process.env.DESKTOP_SESSION === 'gnome' || process.env.DESKTOP_SESSION === 'gnome-classic') { + c('gnome-terminal'); + } else if (process.env.DESKTOP_SESSION === 'kde-plasma') { + c('konsole'); + } else if (process.env.COLORTERM) { + c(process.env.COLORTERM); + } else if (process.env.TERM) { + c(process.env.TERM); + } else { + c('xterm'); + } + }); + return; } - }); - return; - } - c('xterm'); -}); + c('xterm'); + }); + } + return _DEFAULT_TERMINAL_LINUX_READY; +} export const DEFAULT_TERMINAL_OSX = 'Terminal.app'; -export const DEFAULT_TERMINAL_WINDOWS = `${process.env.windir}\\${process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') ? 'Sysnative' : 'System32'}\\cmd.exe`; +let _DEFAULT_TERMINAL_WINDOWS: string = null; +export function getDefaultTerminalWindows(): string { + if (!_DEFAULT_TERMINAL_WINDOWS) { + _DEFAULT_TERMINAL_WINDOWS = `${process.env.windir}\\${process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') ? 'Sysnative' : 'System32'}\\cmd.exe`; + } + return _DEFAULT_TERMINAL_WINDOWS; +} export interface ITerminalConfiguration { terminal: { diff --git a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts index 6329d0d1f7e..6c383779843 100644 --- a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts @@ -14,7 +14,7 @@ import { assign } from 'vs/base/common/objects'; import { TPromise } from 'vs/base/common/winjs.base'; import { ITerminalService } from 'vs/workbench/parts/execution/common/execution'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { ITerminalConfiguration, DEFAULT_TERMINAL_WINDOWS, DEFAULT_TERMINAL_LINUX_READY, DEFAULT_TERMINAL_OSX } from 'vs/workbench/parts/execution/electron-browser/terminal'; +import { ITerminalConfiguration, getDefaultTerminalWindows, getDefaultTerminalLinuxReady, DEFAULT_TERMINAL_OSX } from 'vs/workbench/parts/execution/electron-browser/terminal'; import uri from 'vs/base/common/uri'; import { IProcessEnvironment } from 'vs/base/common/platform'; @@ -46,7 +46,7 @@ export class WinTerminalService implements ITerminalService { const configuration = this._configurationService.getValue(); const terminalConfig = configuration.terminal.external; - const exec = terminalConfig.windowsExec || DEFAULT_TERMINAL_WINDOWS; + const exec = terminalConfig.windowsExec || getDefaultTerminalWindows(); return new TPromise((c, e) => { @@ -78,7 +78,7 @@ export class WinTerminalService implements ITerminalService { private spawnTerminal(spawner, configuration: ITerminalConfiguration, command: string, cwd?: string): TPromise { const terminalConfig = configuration.terminal.external; - const exec = terminalConfig.windowsExec || DEFAULT_TERMINAL_WINDOWS; + const exec = terminalConfig.windowsExec || getDefaultTerminalWindows(); const spawnType = this.getSpawnType(exec); // Make the drive letter uppercase on Windows (see #9448) @@ -226,7 +226,7 @@ export class LinuxTerminalService implements ITerminalService { const configuration = this._configurationService.getValue(); const terminalConfig = configuration.terminal.external; - const execPromise = terminalConfig.linuxExec ? TPromise.as(terminalConfig.linuxExec) : DEFAULT_TERMINAL_LINUX_READY; + const execPromise = terminalConfig.linuxExec ? TPromise.as(terminalConfig.linuxExec) : getDefaultTerminalLinuxReady(); return new TPromise((c, e) => { @@ -280,7 +280,7 @@ export class LinuxTerminalService implements ITerminalService { private spawnTerminal(spawner, configuration: ITerminalConfiguration, cwd?: string): TPromise { const terminalConfig = configuration.terminal.external; - const execPromise = terminalConfig.linuxExec ? TPromise.as(terminalConfig.linuxExec) : DEFAULT_TERMINAL_LINUX_READY; + const execPromise = terminalConfig.linuxExec ? TPromise.as(terminalConfig.linuxExec) : getDefaultTerminalLinuxReady(); const env = cwd ? { cwd: cwd } : void 0; return new TPromise((c, e) => { diff --git a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts index 9eb9e7b123e..787aded95ef 100644 --- a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts +++ b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts @@ -7,7 +7,7 @@ import { deepEqual, equal } from 'assert'; import { WinTerminalService, LinuxTerminalService, MacTerminalService } from 'vs/workbench/parts/execution/electron-browser/terminalService'; -import { DEFAULT_TERMINAL_WINDOWS, DEFAULT_TERMINAL_LINUX_READY, DEFAULT_TERMINAL_OSX } from 'vs/workbench/parts/execution/electron-browser/terminal'; +import { getDefaultTerminalWindows, getDefaultTerminalLinuxReady, DEFAULT_TERMINAL_OSX } from 'vs/workbench/parts/execution/electron-browser/terminal'; suite('Execution - TerminalService', () => { let mockOnExit: Function; @@ -61,7 +61,7 @@ suite('Execution - TerminalService', () => { let mockSpawner = { spawn: (command: any, args: any, opts: any) => { // assert - equal(args[args.length - 1], DEFAULT_TERMINAL_WINDOWS, 'terminal should equal expected'); + equal(args[args.length - 1], getDefaultTerminalWindows(), 'terminal should equal expected'); done(); return { on: (evt: any) => evt @@ -197,7 +197,7 @@ suite('Execution - TerminalService', () => { }); test(`LinuxTerminalService - uses default terminal when configuration.terminal.external.linuxExec is undefined`, done => { - DEFAULT_TERMINAL_LINUX_READY.then(defaultTerminalLinux => { + getDefaultTerminalLinuxReady().then(defaultTerminalLinux => { let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command: any, args: any, opts: any) => { @@ -220,4 +220,4 @@ suite('Execution - TerminalService', () => { ); }); }); -}); \ No newline at end of file +}); diff --git a/src/vs/workbench/parts/tasks/common/taskTemplates.ts b/src/vs/workbench/parts/tasks/common/taskTemplates.ts index 4bb5ee8a833..e19cfd42648 100644 --- a/src/vs/workbench/parts/tasks/common/taskTemplates.ts +++ b/src/vs/workbench/parts/tasks/common/taskTemplates.ts @@ -124,10 +124,16 @@ const maven: TaskEntry = { ].join('\n') }; -export let templates: TaskEntry[] = [dotnetBuild, msbuild, maven].sort((a, b) => { - return (a.sort || a.label).localeCompare(b.sort || b.label); -}); -templates.push(command); +let _templates: TaskEntry[] = null; +export function getTemplates(): TaskEntry[] { + if (!_templates) { + _templates = [dotnetBuild, msbuild, maven].sort((a, b) => { + return (a.sort || a.label).localeCompare(b.sort || b.label); + }); + _templates.push(command); + } + return _templates; +} /** Version 1.0 templates diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index 0fb82f1b37d..6c5fd95bcc6 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -72,7 +72,7 @@ import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; import { ITaskSystem, ITaskResolver, ITaskSummary, TaskExecuteKind, TaskError, TaskErrors, TaskTerminateResponse } from 'vs/workbench/parts/tasks/common/taskSystem'; import { Task, CustomTask, ConfiguringTask, ContributedTask, InMemoryTask, TaskEvent, TaskEventKind, TaskSet, TaskGroup, GroupType, ExecutionEngine, JsonSchemaVersion, TaskSourceKind, TaskIdentifier, TaskSorter } from 'vs/workbench/parts/tasks/common/tasks'; import { ITaskService, ITaskProvider, RunOptions, CustomizationProperties } from 'vs/workbench/parts/tasks/common/taskService'; -import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates'; +import { getTemplates as getTaskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates'; import * as TaskConfig from '../node/taskConfiguration'; import { ProcessTaskSystem } from 'vs/workbench/parts/tasks/node/processTaskSystem'; @@ -2129,7 +2129,7 @@ class TaskService implements ITaskService { if (stat) { return stat.resource; } - return this.quickOpenService.pick(taskTemplates, { placeHolder: nls.localize('TaskService.template', 'Select a Task Template') }).then((selection) => { + return this.quickOpenService.pick(getTaskTemplates(), { placeHolder: nls.localize('TaskService.template', 'Select a Task Template') }).then((selection) => { if (!selection) { return undefined; } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 8ebaaebb94e..b94b3f695b2 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -14,7 +14,7 @@ import * as platform from 'vs/base/common/platform'; import * as terminalCommands from 'vs/workbench/parts/terminal/electron-browser/terminalCommands'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_PANEL_ID, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, TerminalCursorStyle } from 'vs/workbench/parts/terminal/common/terminal'; -import { TERMINAL_DEFAULT_SHELL_UNIX_LIKE, TERMINAL_DEFAULT_SHELL_WINDOWS } from 'vs/workbench/parts/terminal/electron-browser/terminal'; +import { getTerminalDefaultShellUnixLike, getTerminalDefaultShellWindows } from 'vs/workbench/parts/terminal/electron-browser/terminal'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; @@ -76,7 +76,7 @@ configurationRegistry.registerConfiguration({ 'terminal.integrated.shell.linux': { 'description': nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux."), 'type': 'string', - 'default': TERMINAL_DEFAULT_SHELL_UNIX_LIKE + 'default': getTerminalDefaultShellUnixLike() }, 'terminal.integrated.shellArgs.linux': { 'description': nls.localize('terminal.integrated.shellArgs.linux', "The command line arguments to use when on the Linux terminal."), @@ -89,7 +89,7 @@ configurationRegistry.registerConfiguration({ 'terminal.integrated.shell.osx': { 'description': nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on OS X."), 'type': 'string', - 'default': TERMINAL_DEFAULT_SHELL_UNIX_LIKE + 'default': getTerminalDefaultShellUnixLike() }, 'terminal.integrated.shellArgs.osx': { 'description': nls.localize('terminal.integrated.shellArgs.osx', "The command line arguments to use when on the OS X terminal."), @@ -105,7 +105,7 @@ configurationRegistry.registerConfiguration({ 'terminal.integrated.shell.windows': { 'description': nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu)."), 'type': 'string', - 'default': TERMINAL_DEFAULT_SHELL_WINDOWS + 'default': getTerminalDefaultShellWindows() }, 'terminal.integrated.shellArgs.windows': { 'description': nls.localize('terminal.integrated.shellArgs.windows', "The command line arguments to use when on the Windows terminal."), diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index b73b020260e..620dcf23b9f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -9,21 +9,32 @@ import * as platform from 'vs/base/common/platform'; import * as processes from 'vs/base/node/processes'; import { readFile, fileExists } from 'vs/base/node/pfs'; -let unixLikeTerminal = 'sh'; -if (!platform.isWindows && process.env.SHELL) { - unixLikeTerminal = process.env.SHELL; - // Some systems have $SHELL set to /bin/false which breaks the terminal - if (unixLikeTerminal === '/bin/false') { - unixLikeTerminal = '/bin/bash'; +let _TERMINAL_DEFAULT_SHELL_UNIX_LIKE: string = null; +export function getTerminalDefaultShellUnixLike(): string { + if (!_TERMINAL_DEFAULT_SHELL_UNIX_LIKE) { + let unixLikeTerminal = 'sh'; + if (!platform.isWindows && process.env.SHELL) { + unixLikeTerminal = process.env.SHELL; + // Some systems have $SHELL set to /bin/false which breaks the terminal + if (unixLikeTerminal === '/bin/false') { + unixLikeTerminal = '/bin/bash'; + } + } + _TERMINAL_DEFAULT_SHELL_UNIX_LIKE = unixLikeTerminal; } + return _TERMINAL_DEFAULT_SHELL_UNIX_LIKE; } -export const TERMINAL_DEFAULT_SHELL_UNIX_LIKE = unixLikeTerminal; -const isAtLeastWindows10 = platform.isWindows && parseFloat(os.release()) >= 10; -const is32ProcessOn64Windows = process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'); -const powerShellPath = `${process.env.windir}\\${is32ProcessOn64Windows ? 'Sysnative' : 'System32'}\\WindowsPowerShell\\v1.0\\powershell.exe`; - -export const TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : processes.getWindowsShell(); +let _TERMINAL_DEFAULT_SHELL_WINDOWS: string = null; +export function getTerminalDefaultShellWindows(): string { + if (!_TERMINAL_DEFAULT_SHELL_WINDOWS) { + const isAtLeastWindows10 = platform.isWindows && parseFloat(os.release()) >= 10; + const is32ProcessOn64Windows = process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432'); + const powerShellPath = `${process.env.windir}\\${is32ProcessOn64Windows ? 'Sysnative' : 'System32'}\\WindowsPowerShell\\v1.0\\powershell.exe`; + _TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : processes.getWindowsShell(); + } + return _TERMINAL_DEFAULT_SHELL_WINDOWS; +} if (platform.isLinux) { const file = '/etc/os-release'; @@ -40,4 +51,4 @@ if (platform.isLinux) { }); } -export let isFedora = false; \ No newline at end of file +export let isFedora = false; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index df182935d06..eb6eafdbb3e 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -20,7 +20,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IChoiceService, IMessageService } from 'vs/platform/message/common/message'; import Severity from 'vs/base/common/severity'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; -import { TERMINAL_DEFAULT_SHELL_WINDOWS } from 'vs/workbench/parts/terminal/electron-browser/terminal'; +import { getTerminalDefaultShellWindows } from 'vs/workbench/parts/terminal/electron-browser/terminal'; import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel'; import { TerminalTab } from 'vs/workbench/parts/terminal/electron-browser/terminalTab'; @@ -121,7 +121,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina } // Never suggest if the setting is non-default already (ie. they set the setting manually) - if (this._configHelper.config.shell.windows !== TERMINAL_DEFAULT_SHELL_WINDOWS) { + if (this._configHelper.config.shell.windows !== getTerminalDefaultShellWindows()) { this._storageService.store(NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY, true); return; } diff --git a/src/vs/workbench/parts/update/electron-browser/update.contribution.ts b/src/vs/workbench/parts/update/electron-browser/update.contribution.ts index c0fb85b7c64..73400b9d5c1 100644 --- a/src/vs/workbench/parts/update/electron-browser/update.contribution.ts +++ b/src/vs/workbench/parts/update/electron-browser/update.contribution.ts @@ -8,6 +8,7 @@ import * as nls from 'vs/nls'; import 'vs/css!./media/update.contribution'; import 'vs/platform/update/node/update.config.contribution'; +import * as platform from 'vs/base/common/platform'; import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { ReleaseNotesEditor } from 'vs/workbench/parts/update/electron-browser/releaseNotesEditor'; @@ -23,7 +24,7 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; Registry.as(WorkbenchExtensions.Workbench) .registerWorkbenchContribution(ProductContribution, LifecyclePhase.Running); -if (process.platform === 'win32' && process.arch === 'ia32') { +if (platform.isWindows && process.arch === 'ia32') { Registry.as(WorkbenchExtensions.Workbench) .registerWorkbenchContribution(Win3264BitContribution, LifecyclePhase.Running); } diff --git a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts index 642cecf588e..a2948effde7 100644 --- a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts +++ b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts @@ -39,7 +39,7 @@ export class GettingStarted implements IWorkbenchContribution { private openExternal(url: string) { // Don't open the welcome page as the root user on Linux, this is due to a bug with xdg-open // which recommends against running itself as root. - if (platform.isLinux && platform.isRootUser) { + if (platform.isLinux && platform.isRootUser()) { return; } window.open(url); @@ -61,4 +61,4 @@ export class GettingStarted implements IWorkbenchContribution { }); } } -} \ No newline at end of file +} diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index 0b93a411e49..3ccc7b05872 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -44,8 +44,20 @@ import product from 'vs/platform/node/product'; import * as strings from 'vs/base/common/strings'; import { RPCProtocol } from 'vs/workbench/services/extensions/node/rpcProtocol'; -const SystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', 'extensions')); -const ExtraDevSystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', '.build', 'builtInExtensions')); +let _SystemExtensionsRoot: string = null; +function getSystemExtensionsRoot(): string { + if (!_SystemExtensionsRoot) { + _SystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', 'extensions')); + } + return _SystemExtensionsRoot; +} +let _ExtraDevSystemExtensionsRoot: string = null; +function getExtraDevSystemExtensionsRoot(): string { + if (!_ExtraDevSystemExtensionsRoot) { + _ExtraDevSystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', '.build', 'builtInExtensions')); + } + return _ExtraDevSystemExtensionsRoot; +} interface IBuiltInExtension { name: string; @@ -71,7 +83,7 @@ class ExtraBuiltInExtensionResolver implements IExtensionResolver { case 'disabled': break; case 'marketplace': - result.push({ name: ext.name, path: path.join(ExtraDevSystemExtensionsRoot, ext.name) }); + result.push({ name: ext.name, path: path.join(getExtraDevSystemExtensionsRoot(), ext.name) }); break; default: result.push({ name: ext.name, path: controlState }); @@ -667,7 +679,7 @@ export class ExtensionService extends Disposable implements IExtensionService { messageService, environmentService, BUILTIN_MANIFEST_CACHE_FILE, - new ExtensionScannerInput(version, commit, locale, devMode, SystemExtensionsRoot, true, translations), + new ExtensionScannerInput(version, commit, locale, devMode, getSystemExtensionsRoot(), true, translations), log ); @@ -682,7 +694,7 @@ export class ExtensionService extends Disposable implements IExtensionService { const controlFile = pfs.readFile(controlFilePath, 'utf8') .then(raw => JSON.parse(raw), () => ({} as any)); - const input = new ExtensionScannerInput(version, commit, locale, devMode, ExtraDevSystemExtensionsRoot, true, translations); + const input = new ExtensionScannerInput(version, commit, locale, devMode, getExtraDevSystemExtensionsRoot(), true, translations); const extraBuiltinExtensions = TPromise.join([builtInExtensions, controlFile]) .then(([builtInExtensions, control]) => new ExtraBuiltInExtensionResolver(builtInExtensions, control)) .then(resolver => ExtensionScanner.scanExtensions(input, log, resolver)); From 119d49590d11266a311df66495f0bf17ba8181c2 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 16 Feb 2018 11:43:39 +0100 Subject: [PATCH 25/60] minor polish --- .../electron-browser/execution.contribution.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts index cd4d426b8d2..e56fffecff5 100644 --- a/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts +++ b/src/vs/workbench/parts/execution/electron-browser/execution.contribution.ts @@ -79,24 +79,25 @@ getDefaultTerminalLinuxReady().then(defaultTerminalLinux => { const OPEN_IN_TERMINAL_COMMAND_ID = 'openInTerminal'; CommandsRegistry.registerCommand({ id: OPEN_IN_TERMINAL_COMMAND_ID, - handler: (accessor, selectedResource: uri) => { + handler: (accessor, resource: uri) => { const configurationService = accessor.get(IConfigurationService); const editorService = accessor.get(IWorkbenchEditorService); const fileService = accessor.get(IFileService); const integratedTerminalService = accessor.get(IIntegratedTerminalService); const terminalService = accessor.get(ITerminalService); - let resources:uri[] = []; - let directorySet:Set = new Set(); - resources = getMultiSelectedResources(selectedResource, accessor.get(IListService), editorService); - return resources.map((resource) => { - return fileService.resolveFile(resource).then(stat => { + + const directorySet = new Set(); + const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService); + + return resources.map(r => { + return fileService.resolveFile(r).then(stat => { return stat.isDirectory ? stat.resource.fsPath : paths.dirname(stat.resource.fsPath); }).then(directoryToOpen => { if (!directorySet.has(directoryToOpen)) { directorySet.add(directoryToOpen); if (configurationService.getValue().terminal.explorerKind === 'integrated') { const instance = integratedTerminalService.createInstance({ cwd: directoryToOpen }, true); - if (instance && (selectedResource === resource)) { + if (instance && (resource === r || resources.length === 1)) { integratedTerminalService.setActiveInstance(instance); integratedTerminalService.showPanel(true); } From 6831fb4a2ce1dadb228ed83fa7ff20324710f888 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 16 Feb 2018 11:49:29 +0100 Subject: [PATCH 26/60] fixes #43432 --- .../workbench/parts/debug/browser/media/debug.contribution.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css index 350cf6e3345..a6e9d4c0ef3 100644 --- a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css +++ b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css @@ -14,7 +14,7 @@ } .monaco-editor .debug-top-stack-frame-range { - background: #ffeca0; + background: rgba(255, 255, 102, 0.6); } .monaco-editor .debug-top-stack-frame-column::before { From dbd76d987cf1a412401bdbd3fb785217ac94197e Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 16 Feb 2018 12:54:35 +0200 Subject: [PATCH 27/60] Adopt latest loader (which is snapshot-friendly) --- .../electron-browser/issue/issueReporter.js | 2 + .../sharedProcess/sharedProcess.js | 2 + src/vs/css.js | 13 +- src/vs/loader.js | 377 +++++++++--------- src/vs/nls.js | 33 +- .../electron-browser/bootstrap/index.js | 2 + 6 files changed, 225 insertions(+), 204 deletions(-) diff --git a/src/vs/code/electron-browser/issue/issueReporter.js b/src/vs/code/electron-browser/issue/issueReporter.js index 07e8b8663d7..01d097357b0 100644 --- a/src/vs/code/electron-browser/issue/issueReporter.js +++ b/src/vs/code/electron-browser/issue/issueReporter.js @@ -146,6 +146,8 @@ function main() { // In the bundled version the nls plugin is packaged with the loader so the NLS Plugins // loads as soon as the loader loads. To be able to have pseudo translation createScript(rootUrl + '/vs/loader.js', function () { + var define = global.define; + global.define = undefined; define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code window.MonacoEnvironment = {}; diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcess.js b/src/vs/code/electron-browser/sharedProcess/sharedProcess.js index b4e968d7990..ffc640718d0 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcess.js +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcess.js @@ -131,6 +131,8 @@ function main() { // In the bundled version the nls plugin is packaged with the loader so the NLS Plugins // loads as soon as the loader loads. To be able to have pseudo translation createScript(rootUrl + '/vs/loader.js', function () { + var define = global.define; + global.define = undefined; define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code window.MonacoEnvironment = {}; diff --git a/src/vs/css.js b/src/vs/css.js index ae281dacb7b..4a2d5a4d299 100644 --- a/src/vs/css.js +++ b/src/vs/css.js @@ -20,7 +20,7 @@ var CSSLoaderPlugin; * Known issue: * - In IE there is no way to know if the CSS file loaded successfully or not. */ - var BrowserCSSLoader = (function () { + var BrowserCSSLoader = /** @class */ (function () { function BrowserCSSLoader() { this._pendingLoads = 0; } @@ -93,7 +93,7 @@ var CSSLoaderPlugin; return BrowserCSSLoader; }()); // ------------------------------ Finally, the plugin - var CSSPlugin = (function () { + var CSSPlugin = /** @class */ (function () { function CSSPlugin() { this._cssLoader = new BrowserCSSLoader(); } @@ -110,12 +110,5 @@ var CSSLoaderPlugin; return CSSPlugin; }()); CSSLoaderPlugin.CSSPlugin = CSSPlugin; - function init() { - define('vs/css', new CSSPlugin()); - } - CSSLoaderPlugin.init = init; - ; - if (typeof doNotInitLoader === 'undefined') { - init(); - } + define('vs/css', new CSSPlugin()); })(CSSLoaderPlugin || (CSSLoaderPlugin = {})); diff --git a/src/vs/loader.js b/src/vs/loader.js index aa1ae79ae5e..291f0e8b6b3 100644 --- a/src/vs/loader.js +++ b/src/vs/loader.js @@ -22,20 +22,55 @@ var _amdLoaderGlobal = this; var AMDLoader; (function (AMDLoader) { AMDLoader.global = _amdLoaderGlobal; - var Environment = (function () { - function Environment(opts) { - this.isWindows = opts.isWindows; - this.isNode = opts.isNode; - this.isElectronRenderer = opts.isElectronRenderer; - this.isWebWorker = opts.isWebWorker; + var Environment = /** @class */ (function () { + function Environment() { + this._detected = false; + this._isWindows = false; + this._isNode = false; + this._isElectronRenderer = false; + this._isWebWorker = false; } - Environment.detect = function () { - return new Environment({ - isWindows: this._isWindows(), - isNode: (typeof module !== 'undefined' && !!module.exports), - isElectronRenderer: (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer'), - isWebWorker: (typeof AMDLoader.global.importScripts === 'function') - }); + Object.defineProperty(Environment.prototype, "isWindows", { + get: function () { + this._detect(); + return this._isWindows; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Environment.prototype, "isNode", { + get: function () { + this._detect(); + return this._isNode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Environment.prototype, "isElectronRenderer", { + get: function () { + this._detect(); + return this._isElectronRenderer; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Environment.prototype, "isWebWorker", { + get: function () { + this._detect(); + return this._isWebWorker; + }, + enumerable: true, + configurable: true + }); + Environment.prototype._detect = function () { + if (this._detected) { + return; + } + this._detected = true; + this._isWindows = Environment._isWindows(); + this._isNode = (typeof module !== 'undefined' && !!module.exports); + this._isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer'); + this._isWebWorker = (typeof AMDLoader.global.importScripts === 'function'); }; Environment._isWindows = function () { if (typeof navigator !== 'undefined') { @@ -58,20 +93,7 @@ var AMDLoader; *--------------------------------------------------------------------------------------------*/ var AMDLoader; (function (AMDLoader) { - var LoaderEventType; - (function (LoaderEventType) { - LoaderEventType[LoaderEventType["LoaderAvailable"] = 1] = "LoaderAvailable"; - LoaderEventType[LoaderEventType["BeginLoadingScript"] = 10] = "BeginLoadingScript"; - LoaderEventType[LoaderEventType["EndLoadingScriptOK"] = 11] = "EndLoadingScriptOK"; - LoaderEventType[LoaderEventType["EndLoadingScriptError"] = 12] = "EndLoadingScriptError"; - LoaderEventType[LoaderEventType["BeginInvokeFactory"] = 21] = "BeginInvokeFactory"; - LoaderEventType[LoaderEventType["EndInvokeFactory"] = 22] = "EndInvokeFactory"; - LoaderEventType[LoaderEventType["NodeBeginEvaluatingScript"] = 31] = "NodeBeginEvaluatingScript"; - LoaderEventType[LoaderEventType["NodeEndEvaluatingScript"] = 32] = "NodeEndEvaluatingScript"; - LoaderEventType[LoaderEventType["NodeBeginNativeRequire"] = 33] = "NodeBeginNativeRequire"; - LoaderEventType[LoaderEventType["NodeEndNativeRequire"] = 34] = "NodeEndNativeRequire"; - })(LoaderEventType = AMDLoader.LoaderEventType || (AMDLoader.LoaderEventType = {})); - var LoaderEvent = (function () { + var LoaderEvent = /** @class */ (function () { function LoaderEvent(type, detail, timestamp) { this.type = type; this.detail = detail; @@ -80,9 +102,9 @@ var AMDLoader; return LoaderEvent; }()); AMDLoader.LoaderEvent = LoaderEvent; - var LoaderEventRecorder = (function () { + var LoaderEventRecorder = /** @class */ (function () { function LoaderEventRecorder(loaderAvailableTimestamp) { - this._events = [new LoaderEvent(LoaderEventType.LoaderAvailable, '', loaderAvailableTimestamp)]; + this._events = [new LoaderEvent(1 /* LoaderAvailable */, '', loaderAvailableTimestamp)]; } LoaderEventRecorder.prototype.record = function (type, detail) { this._events.push(new LoaderEvent(type, detail, AMDLoader.Utilities.getHighPerformanceTimestamp())); @@ -93,7 +115,7 @@ var AMDLoader; return LoaderEventRecorder; }()); AMDLoader.LoaderEventRecorder = LoaderEventRecorder; - var NullLoaderEventRecorder = (function () { + var NullLoaderEventRecorder = /** @class */ (function () { function NullLoaderEventRecorder() { } NullLoaderEventRecorder.prototype.record = function (type, detail) { @@ -102,9 +124,9 @@ var AMDLoader; NullLoaderEventRecorder.prototype.getEvents = function () { return []; }; + NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder(); return NullLoaderEventRecorder; }()); - NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder(); AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder; })(AMDLoader || (AMDLoader = {})); /*--------------------------------------------------------------------------------------------- @@ -113,7 +135,7 @@ var AMDLoader; *--------------------------------------------------------------------------------------------*/ var AMDLoader; (function (AMDLoader) { - var Utilities = (function () { + var Utilities = /** @class */ (function () { function Utilities() { } /** @@ -199,11 +221,11 @@ var AMDLoader; } return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now()); }; + Utilities.NEXT_ANONYMOUS_ID = 1; + Utilities.PERFORMANCE_NOW_PROBED = false; + Utilities.HAS_PERFORMANCE_NOW = false; return Utilities; }()); - Utilities.NEXT_ANONYMOUS_ID = 1; - Utilities.PERFORMANCE_NOW_PROBED = false; - Utilities.HAS_PERFORMANCE_NOW = false; AMDLoader.Utilities = Utilities; })(AMDLoader || (AMDLoader = {})); /*--------------------------------------------------------------------------------------------- @@ -212,13 +234,13 @@ var AMDLoader; *--------------------------------------------------------------------------------------------*/ var AMDLoader; (function (AMDLoader) { - var ConfigurationOptionsUtil = (function () { + var ConfigurationOptionsUtil = /** @class */ (function () { function ConfigurationOptionsUtil() { } /** * Ensure configuration options make sense */ - ConfigurationOptionsUtil.validateConfigurationOptions = function (isWebWorker, options) { + ConfigurationOptionsUtil.validateConfigurationOptions = function (options) { function defaultOnError(err) { if (err.errorCode === 'load') { console.error('Loading "' + err.moduleId + '" failed'); @@ -253,8 +275,7 @@ var AMDLoader; options.config = {}; } if (typeof options.catchError === 'undefined') { - // Catch errors by default in web workers, do not catch errors by default in other contexts - options.catchError = isWebWorker; + options.catchError = false; } if (typeof options.urlArgs !== 'string') { options.urlArgs = ''; @@ -295,7 +316,7 @@ var AMDLoader; } return options; }; - ConfigurationOptionsUtil.mergeConfigurationOptions = function (isWebWorker, overwrite, base) { + ConfigurationOptionsUtil.mergeConfigurationOptions = function (overwrite, base) { if (overwrite === void 0) { overwrite = null; } if (base === void 0) { base = null; } var result = AMDLoader.Utilities.recursiveClone(base || {}); @@ -314,25 +335,25 @@ var AMDLoader; result[key] = AMDLoader.Utilities.recursiveClone(value); } }); - return ConfigurationOptionsUtil.validateConfigurationOptions(isWebWorker, result); + return ConfigurationOptionsUtil.validateConfigurationOptions(result); }; return ConfigurationOptionsUtil; }()); AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil; - var Configuration = (function () { + var Configuration = /** @class */ (function () { function Configuration(env, options) { this._env = env; - this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(this._env.isWebWorker, options); + this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options); this._createIgnoreDuplicateModulesMap(); this._createNodeModulesMap(); this._createSortedPathsRules(); if (this.options.baseUrl === '') { - if (this._env.isNode && this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename) { + if (this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename && this._env.isNode) { var nodeMain = this.options.nodeRequire.main.filename; var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\')); this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1); } - if (this._env.isNode && this.options.nodeMain) { + if (this.options.nodeMain && this._env.isNode) { var nodeMain = this.options.nodeMain; var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\')); this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1); @@ -383,7 +404,7 @@ var AMDLoader; * @result A new configuration */ Configuration.prototype.cloneAndMerge = function (options) { - return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(this._env.isWebWorker, options, this.options)); + return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(options, this.options)); }; /** * Get current options bag. Useful for passing it forward to plugins. @@ -530,41 +551,49 @@ var AMDLoader; /** * Load `scriptSrc` only once (avoid multiple