mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 09:35:38 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -7,10 +7,9 @@
|
||||
|
||||
import * as path from 'path';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { stopProfiling } from 'vs/base/node/profiler';
|
||||
import nls = require('vs/nls');
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IStorageService } from 'vs/platform/storage/node/storage';
|
||||
import { IStateService } from 'vs/platform/state/common/state';
|
||||
import { shell, screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage } from 'electron';
|
||||
import { TPromise, TValueCallback } from 'vs/base/common/winjs.base';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
@@ -18,7 +17,6 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import product from 'vs/platform/node/product';
|
||||
import pkg from 'vs/platform/node/package';
|
||||
import { IWindowSettings, MenuBarVisibility, IWindowConfiguration, ReadyState, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
@@ -26,6 +24,8 @@ import { ICodeWindow } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IWorkspaceIdentifier, IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IBackupMainService } from 'vs/platform/backup/common/backup';
|
||||
import { ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { mark, exportEntries } from 'vs/base/common/performance';
|
||||
import { resolveMarketplaceHeaders } from 'vs/platform/extensionManagement/node/extensionGalleryService';
|
||||
|
||||
export interface IWindowState {
|
||||
width?: number;
|
||||
@@ -71,15 +71,15 @@ interface ITouchBarSegment extends Electron.SegmentedControlSegment {
|
||||
|
||||
export class CodeWindow implements ICodeWindow {
|
||||
|
||||
public static themeStorageKey = 'theme';
|
||||
public static themeBackgroundStorageKey = 'themeBackground';
|
||||
public static readonly themeStorageKey = 'theme';
|
||||
public static readonly themeBackgroundStorageKey = 'themeBackground';
|
||||
|
||||
private static DEFAULT_BG_LIGHT = '#FFFFFF';
|
||||
private static DEFAULT_BG_DARK = '#1E1E1E';
|
||||
private static DEFAULT_BG_HC_BLACK = '#000000';
|
||||
private static readonly DEFAULT_BG_LIGHT = '#FFFFFF';
|
||||
private static readonly DEFAULT_BG_DARK = '#1E1E1E';
|
||||
private static readonly DEFAULT_BG_HC_BLACK = '#000000';
|
||||
|
||||
private static MIN_WIDTH = 200;
|
||||
private static MIN_HEIGHT = 120;
|
||||
private static readonly MIN_WIDTH = 200;
|
||||
private static readonly MIN_HEIGHT = 120;
|
||||
|
||||
private hiddenTitleBarStyle: boolean;
|
||||
private showTimeoutHandle: any;
|
||||
@@ -97,6 +97,8 @@ export class CodeWindow implements ICodeWindow {
|
||||
private currentConfig: IWindowConfiguration;
|
||||
private pendingLoadConfig: IWindowConfiguration;
|
||||
|
||||
private marketplaceHeadersPromise: TPromise<object>;
|
||||
|
||||
private touchBarGroups: Electron.TouchBarSegmentedControl[];
|
||||
|
||||
constructor(
|
||||
@@ -104,9 +106,9 @@ export class CodeWindow implements ICodeWindow {
|
||||
@ILogService private logService: ILogService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@IWorkspacesMainService private workspaceService: IWorkspacesMainService,
|
||||
@IBackupMainService private backupService: IBackupMainService
|
||||
@IStateService private stateService: IStateService,
|
||||
@IWorkspacesMainService private workspacesMainService: IWorkspacesMainService,
|
||||
@IBackupMainService private backupMainService: IBackupMainService
|
||||
) {
|
||||
this.touchBarGroups = [];
|
||||
this._lastFocusTime = -1;
|
||||
@@ -123,6 +125,9 @@ export class CodeWindow implements ICodeWindow {
|
||||
// macOS: touch bar support
|
||||
this.createTouchBar();
|
||||
|
||||
// Request handling
|
||||
this.handleMarketplaceRequests();
|
||||
|
||||
// Eventing
|
||||
this.registerListeners();
|
||||
}
|
||||
@@ -160,7 +165,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
options.icon = path.join(this.environmentService.appRoot, 'resources/linux/code.png'); // Windows and Mac are better off using the embedded icon(s)
|
||||
}
|
||||
|
||||
const windowConfig = this.configurationService.getConfiguration<IWindowSettings>('window');
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
|
||||
let useNativeTabs = false;
|
||||
if (windowConfig && windowConfig.nativeTabs) {
|
||||
@@ -206,7 +211,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
this.logService.log(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
|
||||
this.logService.warn(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,17 +339,21 @@ export class CodeWindow implements ICodeWindow {
|
||||
return this._readyState;
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];
|
||||
const headers = {
|
||||
'X-Market-Client-Id': `VSCode ${pkg.version}`,
|
||||
'User-Agent': `VSCode ${pkg.version}`,
|
||||
'X-Market-User-Id': this.environmentService.machineUUID
|
||||
};
|
||||
private handleMarketplaceRequests(): void {
|
||||
|
||||
this._win.webContents.session.webRequest.onBeforeSendHeaders({ urls }, (details, cb) => {
|
||||
cb({ cancel: false, requestHeaders: objects.assign(details.requestHeaders, headers) });
|
||||
// Resolve marketplace headers
|
||||
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.environmentService);
|
||||
|
||||
// Inject headers when requests are incoming
|
||||
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];
|
||||
this._win.webContents.session.webRequest.onBeforeSendHeaders({ urls }, (details: any, cb: any) => {
|
||||
this.marketplaceHeadersPromise.done(headers => {
|
||||
cb({ cancel: false, requestHeaders: objects.assign(details.requestHeaders, headers) });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// Prevent loading of svgs
|
||||
this._win.webContents.session.webRequest.onBeforeRequest(null, (details, callback) => {
|
||||
@@ -358,7 +367,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
return callback({});
|
||||
});
|
||||
|
||||
this._win.webContents.session.webRequest.onHeadersReceived(null, (details, callback) => {
|
||||
this._win.webContents.session.webRequest.onHeadersReceived(null, (details: any, callback: any) => {
|
||||
const contentType: string[] = (details.responseHeaders['content-type'] || details.responseHeaders['Content-Type']) as any;
|
||||
if (contentType && Array.isArray(contentType) && contentType.some(x => x.toLowerCase().indexOf('image/svg') >= 0)) {
|
||||
return callback({ cancel: true });
|
||||
@@ -433,7 +442,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
this.toDispose.push(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated()));
|
||||
|
||||
// Handle Workspace events
|
||||
this.toDispose.push(this.workspaceService.onUntitledWorkspaceDeleted(e => this.onUntitledWorkspaceDeleted(e)));
|
||||
this.toDispose.push(this.workspacesMainService.onUntitledWorkspaceDeleted(e => this.onUntitledWorkspaceDeleted(e)));
|
||||
}
|
||||
|
||||
private onUntitledWorkspaceDeleted(workspace: IWorkspaceIdentifier): void {
|
||||
@@ -454,14 +463,14 @@ export class CodeWindow implements ICodeWindow {
|
||||
|
||||
// Swipe command support (macOS)
|
||||
if (isMacintosh) {
|
||||
const config = this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>();
|
||||
const config = this.configurationService.getValue<IWorkbenchEditorConfiguration>();
|
||||
if (config && config.workbench && config.workbench.editor && config.workbench.editor.swipeToNavigate) {
|
||||
this.registerNavigationListenerOn('swipe', 'left', 'right', true);
|
||||
} else {
|
||||
this._win.removeAllListeners('swipe');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private registerNavigationListenerOn(command: 'swipe' | 'app-command', back: 'left' | 'browser-backward', forward: 'right' | 'browser-forward', acrossEditors: boolean) {
|
||||
this._win.on(command as 'swipe' /* | 'app-command' */, (e: Electron.Event, cmd: string) => {
|
||||
@@ -496,7 +505,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
|
||||
// Clear Document Edited if needed
|
||||
if (isMacintosh && this._win.isDocumentEdited()) {
|
||||
if (!isReload || !this.backupService.isHotExitEnabled()) {
|
||||
if (!isReload || !this.backupMainService.isHotExitEnabled()) {
|
||||
this._win.setDocumentEdited(false);
|
||||
}
|
||||
}
|
||||
@@ -511,6 +520,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
}
|
||||
|
||||
// Load URL
|
||||
mark('main:loadWindow');
|
||||
this._win.loadURL(this.getUrl(config));
|
||||
|
||||
// Make window visible if it did not open in N seconds because this indicates an error
|
||||
@@ -524,12 +534,6 @@ export class CodeWindow implements ICodeWindow {
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
// (--prof-startup) save profile to disk
|
||||
const { profileStartup } = this.environmentService;
|
||||
if (profileStartup) {
|
||||
stopProfiling(profileStartup.dir, profileStartup.prefix).done(undefined, err => this.logService.error(err));
|
||||
}
|
||||
}
|
||||
|
||||
public reload(configuration?: IWindowConfiguration, cli?: ParsedArgs): void {
|
||||
@@ -564,7 +568,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
private getUrl(windowConfiguration: IWindowConfiguration): string {
|
||||
|
||||
// Set zoomlevel
|
||||
const windowConfig = this.configurationService.getConfiguration<IWindowSettings>('window');
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const zoomLevel = windowConfig && windowConfig.zoomLevel;
|
||||
if (typeof zoomLevel === 'number') {
|
||||
windowConfiguration.zoomLevel = zoomLevel;
|
||||
@@ -582,6 +586,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
windowConfiguration.backgroundColor = this.getBackgroundColor();
|
||||
|
||||
// Perf Counters
|
||||
windowConfiguration.perfEntries = exportEntries();
|
||||
windowConfiguration.perfStartTime = global.perfStartTime;
|
||||
windowConfiguration.perfAppReady = global.perfAppReady;
|
||||
windowConfiguration.perfWindowLoadTime = Date.now();
|
||||
@@ -603,7 +608,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
return 'hc-black';
|
||||
}
|
||||
|
||||
const theme = this.storageService.getItem<string>(CodeWindow.themeStorageKey, 'vs-dark');
|
||||
const theme = this.stateService.getItem<string>(CodeWindow.themeStorageKey, 'vs-dark');
|
||||
|
||||
return theme.split(' ')[0];
|
||||
}
|
||||
@@ -613,7 +618,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
return CodeWindow.DEFAULT_BG_HC_BLACK;
|
||||
}
|
||||
|
||||
const background = this.storageService.getItem<string>(CodeWindow.themeBackgroundStorageKey, null);
|
||||
const background = this.stateService.getItem<string>(CodeWindow.themeBackgroundStorageKey, null);
|
||||
if (!background) {
|
||||
const baseTheme = this.getBaseTheme();
|
||||
|
||||
@@ -624,6 +629,9 @@ export class CodeWindow implements ICodeWindow {
|
||||
}
|
||||
|
||||
public serializeWindowState(): IWindowState {
|
||||
if (!this._win) {
|
||||
return defaultWindowState();
|
||||
}
|
||||
|
||||
// fullscreen gets special treatment
|
||||
if (this._win.isFullScreen()) {
|
||||
@@ -676,7 +684,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
try {
|
||||
state = this.validateWindowState(state);
|
||||
} catch (err) {
|
||||
this.logService.log(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
|
||||
this.logService.warn(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,7 +802,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
}
|
||||
|
||||
private getMenuBarVisibility(): MenuBarVisibility {
|
||||
const windowConfig = this.configurationService.getConfiguration<IWindowSettings>('window');
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
if (!windowConfig || !windowConfig.menuBarVisibility) {
|
||||
return 'default';
|
||||
}
|
||||
@@ -831,7 +839,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
|
||||
if (notify) {
|
||||
this.send('vscode:showInfoMessage', nls.localize('hiddenMenuBar', "You can still access the menu bar by pressing the **Alt** key."));
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
case ('hidden'):
|
||||
@@ -845,7 +853,7 @@ export class CodeWindow implements ICodeWindow {
|
||||
this._win.setAutoHideMenuBar(false);
|
||||
});
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public onWindowTitleDoubleClick(): void {
|
||||
@@ -972,4 +980,4 @@ export class CodeWindow implements ICodeWindow {
|
||||
|
||||
this._win = null; // Important to dereference the window object to allow for GC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user