mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 11:38:36 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Event, latch, anyEvent } from 'vs/base/common/event';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IProcessEnvironment, isMacintosh, isWindows } from 'vs/base/common/platform';
|
||||
import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
|
||||
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { ExportData } from 'vs/base/common/performance';
|
||||
@@ -103,72 +102,70 @@ export interface IWindowsService {
|
||||
onRecentlyOpenedChange: Event<void>;
|
||||
|
||||
// Dialogs
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
showMessageBox(windowId: number, options: MessageBoxOptions): TPromise<IMessageBoxResult>;
|
||||
showSaveDialog(windowId: number, options: SaveDialogOptions): TPromise<string>;
|
||||
showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise<string[]>;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
showMessageBox(windowId: number, options: MessageBoxOptions): Promise<IMessageBoxResult>;
|
||||
showSaveDialog(windowId: number, options: SaveDialogOptions): Promise<string>;
|
||||
showOpenDialog(windowId: number, options: OpenDialogOptions): Promise<string[]>;
|
||||
|
||||
reloadWindow(windowId: number, args?: ParsedArgs): TPromise<void>;
|
||||
openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void>;
|
||||
toggleDevTools(windowId: number): TPromise<void>;
|
||||
closeWorkspace(windowId: number): TPromise<void>;
|
||||
enterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult>;
|
||||
createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult>;
|
||||
saveAndEnterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult>;
|
||||
toggleFullScreen(windowId: number): TPromise<void>;
|
||||
setRepresentedFilename(windowId: number, fileName: string): TPromise<void>;
|
||||
addRecentlyOpened(files: URI[]): TPromise<void>;
|
||||
removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): TPromise<void>;
|
||||
clearRecentlyOpened(): TPromise<void>;
|
||||
getRecentlyOpened(windowId: number): TPromise<IRecentlyOpened>;
|
||||
focusWindow(windowId: number): TPromise<void>;
|
||||
closeWindow(windowId: number): TPromise<void>;
|
||||
isFocused(windowId: number): TPromise<boolean>;
|
||||
isMaximized(windowId: number): TPromise<boolean>;
|
||||
maximizeWindow(windowId: number): TPromise<void>;
|
||||
unmaximizeWindow(windowId: number): TPromise<void>;
|
||||
minimizeWindow(windowId: number): TPromise<void>;
|
||||
onWindowTitleDoubleClick(windowId: number): TPromise<void>;
|
||||
setDocumentEdited(windowId: number, flag: boolean): TPromise<void>;
|
||||
quit(): TPromise<void>;
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void>;
|
||||
reloadWindow(windowId: number, args?: ParsedArgs): Promise<void>;
|
||||
openDevTools(windowId: number, options?: IDevToolsOptions): Promise<void>;
|
||||
toggleDevTools(windowId: number): Promise<void>;
|
||||
closeWorkspace(windowId: number): Promise<void>;
|
||||
enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult | undefined>;
|
||||
toggleFullScreen(windowId: number): Promise<void>;
|
||||
setRepresentedFilename(windowId: number, fileName: string): Promise<void>;
|
||||
addRecentlyOpened(files: URI[]): Promise<void>;
|
||||
removeFromRecentlyOpened(paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string>): Promise<void>;
|
||||
clearRecentlyOpened(): Promise<void>;
|
||||
getRecentlyOpened(windowId: number): Promise<IRecentlyOpened>;
|
||||
focusWindow(windowId: number): Promise<void>;
|
||||
closeWindow(windowId: number): Promise<void>;
|
||||
isFocused(windowId: number): Promise<boolean>;
|
||||
isMaximized(windowId: number): Promise<boolean>;
|
||||
maximizeWindow(windowId: number): Promise<void>;
|
||||
unmaximizeWindow(windowId: number): Promise<void>;
|
||||
minimizeWindow(windowId: number): Promise<void>;
|
||||
onWindowTitleDoubleClick(windowId: number): Promise<void>;
|
||||
setDocumentEdited(windowId: number, flag: boolean): Promise<void>;
|
||||
quit(): Promise<void>;
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Promise<void>;
|
||||
|
||||
// macOS Native Tabs
|
||||
newWindowTab(): TPromise<void>;
|
||||
showPreviousWindowTab(): TPromise<void>;
|
||||
showNextWindowTab(): TPromise<void>;
|
||||
moveWindowTabToNewWindow(): TPromise<void>;
|
||||
mergeAllWindowTabs(): TPromise<void>;
|
||||
toggleWindowTabsBar(): TPromise<void>;
|
||||
newWindowTab(): Promise<void>;
|
||||
showPreviousWindowTab(): Promise<void>;
|
||||
showNextWindowTab(): Promise<void>;
|
||||
moveWindowTabToNewWindow(): Promise<void>;
|
||||
mergeAllWindowTabs(): Promise<void>;
|
||||
toggleWindowTabsBar(): Promise<void>;
|
||||
|
||||
// macOS TouchBar
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise<void>;
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void>;
|
||||
|
||||
// Shared process
|
||||
whenSharedProcessReady(): TPromise<void>;
|
||||
toggleSharedProcess(): TPromise<void>;
|
||||
whenSharedProcessReady(): Promise<void>;
|
||||
toggleSharedProcess(): Promise<void>;
|
||||
|
||||
// Global methods
|
||||
openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise<void>;
|
||||
openNewWindow(options?: INewWindowOptions): TPromise<void>;
|
||||
showWindow(windowId: number): TPromise<void>;
|
||||
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>;
|
||||
getWindowCount(): TPromise<number>;
|
||||
log(severity: string, ...messages: string[]): TPromise<void>;
|
||||
showItemInFolder(path: string): TPromise<void>;
|
||||
getActiveWindowId(): TPromise<number | undefined>;
|
||||
openWindow(windowId: number, paths: URI[], options?: IOpenSettings): Promise<void>;
|
||||
openNewWindow(options?: INewWindowOptions): Promise<void>;
|
||||
showWindow(windowId: number): Promise<void>;
|
||||
getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>;
|
||||
getWindowCount(): Promise<number>;
|
||||
log(severity: string, ...messages: string[]): Promise<void>;
|
||||
showItemInFolder(path: string): Promise<void>;
|
||||
getActiveWindowId(): Promise<number | undefined>;
|
||||
|
||||
// This needs to be handled from browser process to prevent
|
||||
// foreground ordering issues on Windows
|
||||
openExternal(url: string): TPromise<boolean>;
|
||||
openExternal(url: string): Promise<boolean>;
|
||||
|
||||
// TODO: this is a bit backwards
|
||||
startCrashReporter(config: CrashReporterStartOptions): TPromise<void>;
|
||||
startCrashReporter(config: CrashReporterStartOptions): Promise<void>;
|
||||
|
||||
openAboutDialog(): TPromise<void>;
|
||||
openAboutDialog(): Promise<void>;
|
||||
resolveProxy(windowId: number, url: string): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
@@ -179,44 +176,53 @@ export interface IMessageBoxResult {
|
||||
checkboxChecked?: boolean;
|
||||
}
|
||||
|
||||
export interface IOpenSettings {
|
||||
forceNewWindow?: boolean;
|
||||
forceReuseWindow?: boolean;
|
||||
forceOpenWorkspaceAsFile?: boolean;
|
||||
diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
args?: ParsedArgs;
|
||||
}
|
||||
|
||||
export interface IWindowService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
onDidChangeFocus: Event<boolean>;
|
||||
onDidChangeMaximize: Event<boolean>;
|
||||
readonly onDidChangeFocus: Event<boolean>;
|
||||
readonly onDidChangeMaximize: Event<boolean>;
|
||||
|
||||
readonly hasFocus: boolean;
|
||||
|
||||
getConfiguration(): IWindowConfiguration;
|
||||
getCurrentWindowId(): number;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void>;
|
||||
reloadWindow(args?: ParsedArgs): TPromise<void>;
|
||||
openDevTools(options?: IDevToolsOptions): TPromise<void>;
|
||||
toggleDevTools(): TPromise<void>;
|
||||
closeWorkspace(): TPromise<void>;
|
||||
updateTouchBar(items: ISerializableCommandAction[][]): TPromise<void>;
|
||||
enterWorkspace(path: string): TPromise<IEnterWorkspaceResult>;
|
||||
createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult>;
|
||||
saveAndEnterWorkspace(path: string): TPromise<IEnterWorkspaceResult>;
|
||||
toggleFullScreen(): TPromise<void>;
|
||||
setRepresentedFilename(fileName: string): TPromise<void>;
|
||||
getRecentlyOpened(): TPromise<IRecentlyOpened>;
|
||||
focusWindow(): TPromise<void>;
|
||||
closeWindow(): TPromise<void>;
|
||||
openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise<void>;
|
||||
isFocused(): TPromise<boolean>;
|
||||
setDocumentEdited(flag: boolean): TPromise<void>;
|
||||
isMaximized(): TPromise<boolean>;
|
||||
maximizeWindow(): TPromise<void>;
|
||||
unmaximizeWindow(): TPromise<void>;
|
||||
minimizeWindow(): TPromise<void>;
|
||||
onWindowTitleDoubleClick(): TPromise<void>;
|
||||
show(): TPromise<void>;
|
||||
showMessageBox(options: MessageBoxOptions): TPromise<IMessageBoxResult>;
|
||||
showSaveDialog(options: SaveDialogOptions): TPromise<string>;
|
||||
showOpenDialog(options: OpenDialogOptions): TPromise<string[]>;
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void>;
|
||||
reloadWindow(args?: ParsedArgs): Promise<void>;
|
||||
openDevTools(options?: IDevToolsOptions): Promise<void>;
|
||||
toggleDevTools(): Promise<void>;
|
||||
closeWorkspace(): Promise<void>;
|
||||
updateTouchBar(items: ISerializableCommandAction[][]): Promise<void>;
|
||||
enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined>;
|
||||
toggleFullScreen(): Promise<void>;
|
||||
setRepresentedFilename(fileName: string): Promise<void>;
|
||||
getRecentlyOpened(): Promise<IRecentlyOpened>;
|
||||
focusWindow(): Promise<void>;
|
||||
closeWindow(): Promise<void>;
|
||||
openWindow(paths: URI[], options?: IOpenSettings): Promise<void>;
|
||||
isFocused(): Promise<boolean>;
|
||||
setDocumentEdited(flag: boolean): Promise<void>;
|
||||
isMaximized(): Promise<boolean>;
|
||||
maximizeWindow(): Promise<void>;
|
||||
unmaximizeWindow(): Promise<void>;
|
||||
minimizeWindow(): Promise<void>;
|
||||
onWindowTitleDoubleClick(): Promise<void>;
|
||||
show(): Promise<void>;
|
||||
showMessageBox(options: MessageBoxOptions): Promise<IMessageBoxResult>;
|
||||
showSaveDialog(options: SaveDialogOptions): Promise<string>;
|
||||
showOpenDialog(options: OpenDialogOptions): Promise<string[]>;
|
||||
resolveProxy(url: string): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
@@ -241,7 +247,6 @@ export interface IWindowSettings {
|
||||
nativeFullScreen: boolean;
|
||||
enableMenuBarMnemonics: boolean;
|
||||
closeWhenEmpty: boolean;
|
||||
smoothScrollingWorkaround: boolean;
|
||||
clickThroughInactive: boolean;
|
||||
}
|
||||
|
||||
@@ -264,11 +269,6 @@ export function getTitleBarStyle(configurationService: IConfigurationService, en
|
||||
return 'native'; // simple fullscreen does not work well with custom title style (https://github.com/Microsoft/vscode/issues/63291)
|
||||
}
|
||||
|
||||
const smoothScrollingWorkaround = isWindows && configuration.smoothScrollingWorkaround === true;
|
||||
if (smoothScrollingWorkaround) {
|
||||
return 'native'; // smooth scrolling workaround does not work with custom title style
|
||||
}
|
||||
|
||||
const style = configuration.titleBarStyle;
|
||||
if (style === 'native') {
|
||||
return 'native';
|
||||
@@ -410,14 +410,18 @@ export interface IRunActionInWindowRequest {
|
||||
args?: any[];
|
||||
}
|
||||
|
||||
export interface IRunKeybindingInWindowRequest {
|
||||
userSettingsLabel: string;
|
||||
}
|
||||
|
||||
export class ActiveWindowManager implements IDisposable {
|
||||
|
||||
private disposables: IDisposable[] = [];
|
||||
private firstActiveWindowIdPromise: TPromise<any> | null;
|
||||
private firstActiveWindowIdPromise: Promise<any> | null;
|
||||
private _activeWindowId: number | undefined;
|
||||
|
||||
constructor(@IWindowsService windowsService: IWindowsService) {
|
||||
const onActiveWindowChange = latch(anyEvent(windowsService.onWindowOpen, windowsService.onWindowFocus));
|
||||
const onActiveWindowChange = Event.latch(Event.any(windowsService.onWindowOpen, windowsService.onWindowFocus));
|
||||
onActiveWindowChange(this.setActiveWindow, this, this.disposables);
|
||||
|
||||
this.firstActiveWindowIdPromise = windowsService.getActiveWindowId()
|
||||
@@ -432,12 +436,12 @@ export class ActiveWindowManager implements IDisposable {
|
||||
this._activeWindowId = windowId;
|
||||
}
|
||||
|
||||
getActiveClientId(): TPromise<string> {
|
||||
getActiveClientId(): Promise<string> {
|
||||
if (this.firstActiveWindowIdPromise) {
|
||||
return this.firstActiveWindowIdPromise;
|
||||
}
|
||||
|
||||
return TPromise.as(`window:${this._activeWindowId}`);
|
||||
return Promise.resolve(`window:${this._activeWindowId}`);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
@@ -3,33 +3,41 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Event, filterEvent, mapEvent, anyEvent } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions } from 'vs/platform/windows/common/windows';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions, IOpenSettings } from 'vs/platform/windows/common/windows';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class WindowService implements IWindowService {
|
||||
export class WindowService extends Disposable implements IWindowService {
|
||||
|
||||
readonly onDidChangeFocus: Event<boolean>;
|
||||
readonly onDidChangeMaximize: Event<boolean>;
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _hasFocus: boolean;
|
||||
get hasFocus(): boolean { return this._hasFocus; }
|
||||
|
||||
constructor(
|
||||
private windowId: number,
|
||||
private configuration: IWindowConfiguration,
|
||||
@IWindowsService private windowsService: IWindowsService
|
||||
@IWindowsService private readonly windowsService: IWindowsService
|
||||
) {
|
||||
const onThisWindowFocus = mapEvent(filterEvent(windowsService.onWindowFocus, id => id === windowId), _ => true);
|
||||
const onThisWindowBlur = mapEvent(filterEvent(windowsService.onWindowBlur, id => id === windowId), _ => false);
|
||||
const onThisWindowMaximize = mapEvent(filterEvent(windowsService.onWindowMaximize, id => id === windowId), _ => true);
|
||||
const onThisWindowUnmaximize = mapEvent(filterEvent(windowsService.onWindowUnmaximize, id => id === windowId), _ => false);
|
||||
this.onDidChangeFocus = anyEvent(onThisWindowFocus, onThisWindowBlur);
|
||||
this.onDidChangeMaximize = anyEvent(onThisWindowMaximize, onThisWindowUnmaximize);
|
||||
super();
|
||||
|
||||
const onThisWindowFocus = Event.map(Event.filter(windowsService.onWindowFocus, id => id === windowId), _ => true);
|
||||
const onThisWindowBlur = Event.map(Event.filter(windowsService.onWindowBlur, id => id === windowId), _ => false);
|
||||
const onThisWindowMaximize = Event.map(Event.filter(windowsService.onWindowMaximize, id => id === windowId), _ => true);
|
||||
const onThisWindowUnmaximize = Event.map(Event.filter(windowsService.onWindowUnmaximize, id => id === windowId), _ => false);
|
||||
this.onDidChangeFocus = Event.any(onThisWindowFocus, onThisWindowBlur);
|
||||
this.onDidChangeMaximize = Event.any(onThisWindowMaximize, onThisWindowUnmaximize);
|
||||
|
||||
this._hasFocus = document.hasFocus();
|
||||
this.isFocused().then(focused => this._hasFocus = focused);
|
||||
this._register(this.onDidChangeFocus(focus => this._hasFocus = focus));
|
||||
}
|
||||
|
||||
getCurrentWindowId(): number {
|
||||
@@ -40,127 +48,119 @@ export class WindowService implements IWindowService {
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
options.windowId = this.windowId;
|
||||
|
||||
return this.windowsService.pickFileFolderAndOpen(options);
|
||||
}
|
||||
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
options.windowId = this.windowId;
|
||||
|
||||
return this.windowsService.pickFileAndOpen(options);
|
||||
}
|
||||
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
options.windowId = this.windowId;
|
||||
|
||||
return this.windowsService.pickFolderAndOpen(options);
|
||||
}
|
||||
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
options.windowId = this.windowId;
|
||||
|
||||
return this.windowsService.pickWorkspaceAndOpen(options);
|
||||
}
|
||||
|
||||
reloadWindow(args?: ParsedArgs): TPromise<void> {
|
||||
reloadWindow(args?: ParsedArgs): Promise<void> {
|
||||
return this.windowsService.reloadWindow(this.windowId, args);
|
||||
}
|
||||
|
||||
openDevTools(options?: IDevToolsOptions): TPromise<void> {
|
||||
openDevTools(options?: IDevToolsOptions): Promise<void> {
|
||||
return this.windowsService.openDevTools(this.windowId, options);
|
||||
}
|
||||
|
||||
toggleDevTools(): TPromise<void> {
|
||||
toggleDevTools(): Promise<void> {
|
||||
return this.windowsService.toggleDevTools(this.windowId);
|
||||
}
|
||||
|
||||
closeWorkspace(): TPromise<void> {
|
||||
closeWorkspace(): Promise<void> {
|
||||
return this.windowsService.closeWorkspace(this.windowId);
|
||||
}
|
||||
|
||||
enterWorkspace(path: string): TPromise<IEnterWorkspaceResult> {
|
||||
enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined> {
|
||||
return this.windowsService.enterWorkspace(this.windowId, path);
|
||||
}
|
||||
|
||||
createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
|
||||
return this.windowsService.createAndEnterWorkspace(this.windowId, folders, path);
|
||||
}
|
||||
|
||||
saveAndEnterWorkspace(path: string): TPromise<IEnterWorkspaceResult> {
|
||||
return this.windowsService.saveAndEnterWorkspace(this.windowId, path);
|
||||
}
|
||||
|
||||
openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise<void> {
|
||||
openWindow(paths: URI[], options?: IOpenSettings): Promise<void> {
|
||||
return this.windowsService.openWindow(this.windowId, paths, options);
|
||||
}
|
||||
|
||||
closeWindow(): TPromise<void> {
|
||||
closeWindow(): Promise<void> {
|
||||
return this.windowsService.closeWindow(this.windowId);
|
||||
}
|
||||
|
||||
toggleFullScreen(): TPromise<void> {
|
||||
toggleFullScreen(): Promise<void> {
|
||||
return this.windowsService.toggleFullScreen(this.windowId);
|
||||
}
|
||||
|
||||
setRepresentedFilename(fileName: string): TPromise<void> {
|
||||
setRepresentedFilename(fileName: string): Promise<void> {
|
||||
return this.windowsService.setRepresentedFilename(this.windowId, fileName);
|
||||
}
|
||||
|
||||
getRecentlyOpened(): TPromise<IRecentlyOpened> {
|
||||
getRecentlyOpened(): Promise<IRecentlyOpened> {
|
||||
return this.windowsService.getRecentlyOpened(this.windowId);
|
||||
}
|
||||
|
||||
focusWindow(): TPromise<void> {
|
||||
focusWindow(): Promise<void> {
|
||||
return this.windowsService.focusWindow(this.windowId);
|
||||
}
|
||||
|
||||
isFocused(): TPromise<boolean> {
|
||||
isFocused(): Promise<boolean> {
|
||||
return this.windowsService.isFocused(this.windowId);
|
||||
}
|
||||
|
||||
isMaximized(): TPromise<boolean> {
|
||||
isMaximized(): Promise<boolean> {
|
||||
return this.windowsService.isMaximized(this.windowId);
|
||||
}
|
||||
|
||||
maximizeWindow(): TPromise<void> {
|
||||
maximizeWindow(): Promise<void> {
|
||||
return this.windowsService.maximizeWindow(this.windowId);
|
||||
}
|
||||
|
||||
unmaximizeWindow(): TPromise<void> {
|
||||
unmaximizeWindow(): Promise<void> {
|
||||
return this.windowsService.unmaximizeWindow(this.windowId);
|
||||
}
|
||||
|
||||
minimizeWindow(): TPromise<void> {
|
||||
minimizeWindow(): Promise<void> {
|
||||
return this.windowsService.minimizeWindow(this.windowId);
|
||||
}
|
||||
|
||||
onWindowTitleDoubleClick(): TPromise<void> {
|
||||
onWindowTitleDoubleClick(): Promise<void> {
|
||||
return this.windowsService.onWindowTitleDoubleClick(this.windowId);
|
||||
}
|
||||
|
||||
setDocumentEdited(flag: boolean): TPromise<void> {
|
||||
setDocumentEdited(flag: boolean): Promise<void> {
|
||||
return this.windowsService.setDocumentEdited(this.windowId, flag);
|
||||
}
|
||||
|
||||
show(): TPromise<void> {
|
||||
show(): Promise<void> {
|
||||
return this.windowsService.showWindow(this.windowId);
|
||||
}
|
||||
|
||||
showMessageBox(options: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
|
||||
showMessageBox(options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
return this.windowsService.showMessageBox(this.windowId, options);
|
||||
}
|
||||
|
||||
showSaveDialog(options: Electron.SaveDialogOptions): TPromise<string> {
|
||||
showSaveDialog(options: Electron.SaveDialogOptions): Promise<string> {
|
||||
return this.windowsService.showSaveDialog(this.windowId, options);
|
||||
}
|
||||
|
||||
showOpenDialog(options: Electron.OpenDialogOptions): TPromise<string[]> {
|
||||
showOpenDialog(options: Electron.OpenDialogOptions): Promise<string[]> {
|
||||
return this.windowsService.showOpenDialog(this.windowId, options);
|
||||
}
|
||||
|
||||
updateTouchBar(items: ISerializableCommandAction[][]): TPromise<void> {
|
||||
updateTouchBar(items: ISerializableCommandAction[][]): Promise<void> {
|
||||
return this.windowsService.updateTouchBar(this.windowId, items);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { OpenContext, IWindowConfiguration, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, INewWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IProcessEnvironment } from 'vs/base/common/platform';
|
||||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -30,23 +29,23 @@ export const enum WindowMode {
|
||||
}
|
||||
|
||||
export interface ICodeWindow {
|
||||
id: number;
|
||||
win: Electron.BrowserWindow;
|
||||
config: IWindowConfiguration;
|
||||
readonly id: number;
|
||||
readonly win: Electron.BrowserWindow;
|
||||
readonly config: IWindowConfiguration;
|
||||
|
||||
openedFolderUri: URI;
|
||||
openedWorkspace: IWorkspaceIdentifier;
|
||||
backupPath: string;
|
||||
readonly openedFolderUri: URI;
|
||||
readonly openedWorkspace: IWorkspaceIdentifier;
|
||||
readonly backupPath: string;
|
||||
|
||||
remoteAuthority: string;
|
||||
readonly remoteAuthority: string;
|
||||
|
||||
isExtensionDevelopmentHost: boolean;
|
||||
isExtensionTestHost: boolean;
|
||||
readonly isExtensionDevelopmentHost: boolean;
|
||||
readonly isExtensionTestHost: boolean;
|
||||
|
||||
lastFocusTime: number;
|
||||
readonly lastFocusTime: number;
|
||||
|
||||
isReady: boolean;
|
||||
ready(): Thenable<ICodeWindow>;
|
||||
readonly isReady: boolean;
|
||||
ready(): Promise<ICodeWindow>;
|
||||
|
||||
addTabbedWindow(window: ICodeWindow): void;
|
||||
|
||||
@@ -80,26 +79,22 @@ export interface ICodeWindow {
|
||||
export const IWindowsMainService = createDecorator<IWindowsMainService>('windowsMainService');
|
||||
|
||||
export interface IWindowsCountChangedEvent {
|
||||
oldCount: number;
|
||||
newCount: number;
|
||||
readonly oldCount: number;
|
||||
readonly newCount: number;
|
||||
}
|
||||
|
||||
export interface IWindowsMainService {
|
||||
_serviceBrand: any;
|
||||
|
||||
// events
|
||||
onWindowReady: Event<ICodeWindow>;
|
||||
onActiveWindowChanged: Event<ICodeWindow>;
|
||||
onWindowsCountChanged: Event<IWindowsCountChangedEvent>;
|
||||
onWindowClose: Event<number>;
|
||||
onWindowReload: Event<number>;
|
||||
readonly onWindowReady: Event<ICodeWindow>;
|
||||
readonly onWindowsCountChanged: Event<IWindowsCountChangedEvent>;
|
||||
readonly onWindowClose: Event<number>;
|
||||
|
||||
// methods
|
||||
ready(initialUserEnv: IProcessEnvironment): void;
|
||||
reload(win: ICodeWindow, cli?: ParsedArgs): void;
|
||||
enterWorkspace(win: ICodeWindow, path: string): TPromise<IEnterWorkspaceResult>;
|
||||
createAndEnterWorkspace(win: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult>;
|
||||
saveAndEnterWorkspace(win: ICodeWindow, path: string): TPromise<IEnterWorkspaceResult>;
|
||||
enterWorkspace(win: ICodeWindow, path: URI): Promise<IEnterWorkspaceResult>;
|
||||
closeWorkspace(win: ICodeWindow): void;
|
||||
open(openConfig: IOpenConfiguration): ICodeWindow[];
|
||||
openExtensionDevelopmentHostWindow(openConfig: IOpenConfiguration): void;
|
||||
@@ -107,12 +102,12 @@ export interface IWindowsMainService {
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): void;
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): void;
|
||||
showMessageBox(options: Electron.MessageBoxOptions, win?: ICodeWindow): Thenable<IMessageBoxResult>;
|
||||
showSaveDialog(options: Electron.SaveDialogOptions, win?: ICodeWindow): Thenable<string>;
|
||||
showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Thenable<string[]>;
|
||||
showMessageBox(options: Electron.MessageBoxOptions, win?: ICodeWindow): Promise<IMessageBoxResult>;
|
||||
showSaveDialog(options: Electron.SaveDialogOptions, win?: ICodeWindow): Promise<string>;
|
||||
showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Promise<string[]>;
|
||||
focusLastActive(cli: ParsedArgs, context: OpenContext): ICodeWindow;
|
||||
getLastActiveWindow(): ICodeWindow;
|
||||
waitForWindowCloseOrLoad(windowId: number): TPromise<void>;
|
||||
waitForWindowCloseOrLoad(windowId: number): Promise<void>;
|
||||
openNewWindow(context: OpenContext, options?: INewWindowOptions): ICodeWindow[];
|
||||
openNewTabbedWindow(context: OpenContext): ICodeWindow[];
|
||||
sendToFocused(channel: string, ...args: any[]): void;
|
||||
@@ -125,23 +120,23 @@ export interface IWindowsMainService {
|
||||
}
|
||||
|
||||
export interface IOpenConfiguration {
|
||||
context: OpenContext;
|
||||
contextWindowId?: number;
|
||||
cli: ParsedArgs;
|
||||
userEnv?: IProcessEnvironment;
|
||||
urisToOpen?: URI[];
|
||||
preferNewWindow?: boolean;
|
||||
forceNewWindow?: boolean;
|
||||
forceNewTabbedWindow?: boolean;
|
||||
forceReuseWindow?: boolean;
|
||||
forceEmpty?: boolean;
|
||||
diffMode?: boolean;
|
||||
readonly context: OpenContext;
|
||||
readonly contextWindowId?: number;
|
||||
readonly cli: ParsedArgs;
|
||||
readonly userEnv?: IProcessEnvironment;
|
||||
readonly urisToOpen?: URI[];
|
||||
readonly preferNewWindow?: boolean;
|
||||
readonly forceNewWindow?: boolean;
|
||||
readonly forceNewTabbedWindow?: boolean;
|
||||
readonly forceReuseWindow?: boolean;
|
||||
readonly forceEmpty?: boolean;
|
||||
readonly diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
forceOpenWorkspaceAsFile?: boolean;
|
||||
initialStartup?: boolean;
|
||||
readonly forceOpenWorkspaceAsFile?: boolean;
|
||||
readonly initialStartup?: boolean;
|
||||
}
|
||||
|
||||
export interface ISharedProcess {
|
||||
whenReady(): TPromise<void>;
|
||||
whenReady(): Promise<void>;
|
||||
toggle(): void;
|
||||
}
|
||||
@@ -5,20 +5,19 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as os from 'os';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import product from 'vs/platform/node/product';
|
||||
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IDevToolsOptions, INewWindowOptions, IOpenSettings } from 'vs/platform/windows/common/windows';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { shell, crashReporter, app, Menu, clipboard } from 'electron';
|
||||
import { Event, fromNodeEventEmitter, mapEvent, filterEvent, anyEvent, latch } from 'vs/base/common/event';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
|
||||
import { IWindowsMainService, ISharedProcess } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IWindowsMainService, ISharedProcess, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
@@ -33,375 +32,252 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
|
||||
private _activeWindowId: number | undefined;
|
||||
|
||||
readonly onWindowOpen: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-created', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowBlur: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowMaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowUnmaximize: Event<number> = filterEvent(fromNodeEventEmitter(app, 'browser-window-unmaximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowFocus: Event<number> = anyEvent(
|
||||
mapEvent(filterEvent(mapEvent(this.windowsMainService.onWindowsCountChanged, () => this.windowsMainService.getLastActiveWindow()), w => !!w), w => w.id),
|
||||
filterEvent(fromNodeEventEmitter(app, 'browser-window-focus', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id))
|
||||
readonly onWindowOpen: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-created', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowBlur: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-blur', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowMaximize: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-maximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowUnmaximize: Event<number> = Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-unmaximize', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id));
|
||||
readonly onWindowFocus: Event<number> = Event.any(
|
||||
Event.map(Event.filter(Event.map(this.windowsMainService.onWindowsCountChanged, () => this.windowsMainService.getLastActiveWindow()), w => !!w), w => w.id),
|
||||
Event.filter(Event.fromNodeEventEmitter(app, 'browser-window-focus', (_, w: Electron.BrowserWindow) => w.id), id => !!this.windowsMainService.getWindowById(id))
|
||||
);
|
||||
|
||||
readonly onRecentlyOpenedChange: Event<void> = this.historyService.onRecentlyOpenedChange;
|
||||
|
||||
constructor(
|
||||
private sharedProcess: ISharedProcess,
|
||||
@IWindowsMainService private windowsMainService: IWindowsMainService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IURLService urlService: IURLService,
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IHistoryMainService private historyService: IHistoryMainService,
|
||||
@ILogService private logService: ILogService
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IHistoryMainService private readonly historyService: IHistoryMainService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
urlService.registerHandler(this);
|
||||
|
||||
// remember last active window id
|
||||
latch(anyEvent(this.onWindowOpen, this.onWindowFocus))
|
||||
Event.latch(Event.any(this.onWindowOpen, this.onWindowFocus))
|
||||
(id => this._activeWindowId = id, null, this.disposables);
|
||||
}
|
||||
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
async pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#pickFileFolderAndOpen');
|
||||
|
||||
this.windowsMainService.pickFileFolderAndOpen(options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
async pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#pickFileAndOpen');
|
||||
|
||||
this.windowsMainService.pickFileAndOpen(options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
async pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#pickFolderAndOpen');
|
||||
|
||||
this.windowsMainService.pickFolderAndOpen(options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#pickWorkspaceAndOpen');
|
||||
|
||||
this.windowsMainService.pickWorkspaceAndOpen(options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
showMessageBox(windowId: number, options: Electron.MessageBoxOptions): Thenable<IMessageBoxResult> {
|
||||
async showMessageBox(windowId: number, options: Electron.MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
this.logService.trace('windowsService#showMessageBox', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
return this.windowsMainService.showMessageBox(options, codeWindow);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.showMessageBox(options, codeWindow), () => this.windowsMainService.showMessageBox(options))!;
|
||||
}
|
||||
|
||||
showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): Thenable<string> {
|
||||
async showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): Promise<string> {
|
||||
this.logService.trace('windowsService#showSaveDialog', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
return this.windowsMainService.showSaveDialog(options, codeWindow);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.showSaveDialog(options, codeWindow), () => this.windowsMainService.showSaveDialog(options))!;
|
||||
}
|
||||
|
||||
showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): Thenable<string[]> {
|
||||
async showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): Promise<string[]> {
|
||||
this.logService.trace('windowsService#showOpenDialog', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
return this.windowsMainService.showOpenDialog(options, codeWindow);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options))!;
|
||||
}
|
||||
|
||||
reloadWindow(windowId: number, args: ParsedArgs): TPromise<void> {
|
||||
async reloadWindow(windowId: number, args: ParsedArgs): Promise<void> {
|
||||
this.logService.trace('windowsService#reloadWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
this.windowsMainService.reload(codeWindow, args);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.reload(codeWindow, args));
|
||||
}
|
||||
|
||||
openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void> {
|
||||
async openDevTools(windowId: number, options?: IDevToolsOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#openDevTools', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.webContents.openDevTools(options);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.webContents.openDevTools(options));
|
||||
}
|
||||
|
||||
toggleDevTools(windowId: number): TPromise<void> {
|
||||
async toggleDevTools(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#toggleDevTools', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return this.withWindow(windowId, codeWindow => {
|
||||
const contents = codeWindow.win.webContents;
|
||||
if (isMacintosh && codeWindow.hasHiddenTitleBarStyle() && !codeWindow.isFullScreen() && !contents.isDevToolsOpened()) {
|
||||
contents.openDevTools({ mode: 'undocked' }); // due to https://github.com/electron/electron/issues/3647
|
||||
} else {
|
||||
contents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
});
|
||||
}
|
||||
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise<void> {
|
||||
async updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void> {
|
||||
this.logService.trace('windowsService#updateTouchBar', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.updateTouchBar(items);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.updateTouchBar(items));
|
||||
}
|
||||
|
||||
closeWorkspace(windowId: number): TPromise<void> {
|
||||
async closeWorkspace(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#closeWorkspace', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
this.windowsMainService.closeWorkspace(codeWindow);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.closeWorkspace(codeWindow));
|
||||
}
|
||||
|
||||
enterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
|
||||
async enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult | undefined> {
|
||||
this.logService.trace('windowsService#enterWorkspace', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return this.windowsMainService.enterWorkspace(codeWindow, path);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => this.windowsMainService.enterWorkspace(codeWindow, path));
|
||||
}
|
||||
|
||||
createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
|
||||
this.logService.trace('windowsService#createAndEnterWorkspace', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return this.windowsMainService.createAndEnterWorkspace(codeWindow, folders, path);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
saveAndEnterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
|
||||
this.logService.trace('windowsService#saveAndEnterWorkspace', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return this.windowsMainService.saveAndEnterWorkspace(codeWindow, path);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
toggleFullScreen(windowId: number): TPromise<void> {
|
||||
async toggleFullScreen(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#toggleFullScreen', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.toggleFullScreen();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.toggleFullScreen());
|
||||
}
|
||||
|
||||
setRepresentedFilename(windowId: number, fileName: string): TPromise<void> {
|
||||
async setRepresentedFilename(windowId: number, fileName: string): Promise<void> {
|
||||
this.logService.trace('windowsService#setRepresentedFilename', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.setRepresentedFilename(fileName);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.setRepresentedFilename(fileName));
|
||||
}
|
||||
|
||||
addRecentlyOpened(files: URI[]): TPromise<void> {
|
||||
async addRecentlyOpened(files: URI[]): Promise<void> {
|
||||
this.logService.trace('windowsService#addRecentlyOpened');
|
||||
this.historyService.addRecentlyOpened(void 0, files);
|
||||
|
||||
return TPromise.as(null);
|
||||
this.historyService.addRecentlyOpened(undefined, files);
|
||||
}
|
||||
|
||||
removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): TPromise<void> {
|
||||
async removeFromRecentlyOpened(paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string>): Promise<void> {
|
||||
this.logService.trace('windowsService#removeFromRecentlyOpened');
|
||||
|
||||
this.historyService.removeFromRecentlyOpened(paths);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
clearRecentlyOpened(): TPromise<void> {
|
||||
async clearRecentlyOpened(): Promise<void> {
|
||||
this.logService.trace('windowsService#clearRecentlyOpened');
|
||||
|
||||
this.historyService.clearRecentlyOpened();
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
getRecentlyOpened(windowId: number): TPromise<IRecentlyOpened> {
|
||||
async getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
|
||||
this.logService.trace('windowsService#getRecentlyOpened', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return TPromise.as(this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen));
|
||||
}
|
||||
|
||||
return TPromise.as(this.historyService.getRecentlyOpened());
|
||||
return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened())!;
|
||||
}
|
||||
|
||||
newWindowTab(): TPromise<void> {
|
||||
async newWindowTab(): Promise<void> {
|
||||
this.logService.trace('windowsService#newWindowTab');
|
||||
|
||||
this.windowsMainService.openNewTabbedWindow(OpenContext.API);
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
showPreviousWindowTab(): TPromise<void> {
|
||||
async showPreviousWindowTab(): Promise<void> {
|
||||
this.logService.trace('windowsService#showPreviousWindowTab');
|
||||
|
||||
Menu.sendActionToFirstResponder('selectPreviousTab:');
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
showNextWindowTab(): TPromise<void> {
|
||||
async showNextWindowTab(): Promise<void> {
|
||||
this.logService.trace('windowsService#showNextWindowTab');
|
||||
|
||||
Menu.sendActionToFirstResponder('selectNextTab:');
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
moveWindowTabToNewWindow(): TPromise<void> {
|
||||
async moveWindowTabToNewWindow(): Promise<void> {
|
||||
this.logService.trace('windowsService#moveWindowTabToNewWindow');
|
||||
|
||||
Menu.sendActionToFirstResponder('moveTabToNewWindow:');
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
mergeAllWindowTabs(): TPromise<void> {
|
||||
async mergeAllWindowTabs(): Promise<void> {
|
||||
this.logService.trace('windowsService#mergeAllWindowTabs');
|
||||
|
||||
Menu.sendActionToFirstResponder('mergeAllWindows:');
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
toggleWindowTabsBar(): TPromise<void> {
|
||||
async toggleWindowTabsBar(): Promise<void> {
|
||||
this.logService.trace('windowsService#toggleWindowTabsBar');
|
||||
|
||||
Menu.sendActionToFirstResponder('toggleTabBar:');
|
||||
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
focusWindow(windowId: number): TPromise<void> {
|
||||
async focusWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#focusWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.focus();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.focus());
|
||||
}
|
||||
|
||||
closeWindow(windowId: number): TPromise<void> {
|
||||
async closeWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#closeWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.close();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.close());
|
||||
}
|
||||
|
||||
isFocused(windowId: number): TPromise<boolean> {
|
||||
async isFocused(windowId: number): Promise<boolean> {
|
||||
this.logService.trace('windowsService#isFocused', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return TPromise.as(codeWindow.win.isFocused());
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false)!;
|
||||
}
|
||||
|
||||
isMaximized(windowId: number): TPromise<boolean> {
|
||||
async isMaximized(windowId: number): Promise<boolean> {
|
||||
this.logService.trace('windowsService#isMaximized', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
return TPromise.as(codeWindow.win.isMaximized());
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false)!;
|
||||
}
|
||||
|
||||
maximizeWindow(windowId: number): TPromise<void> {
|
||||
async maximizeWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#maximizeWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.maximize();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.maximize());
|
||||
}
|
||||
|
||||
unmaximizeWindow(windowId: number): TPromise<void> {
|
||||
async unmaximizeWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#unmaximizeWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.unmaximize();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.unmaximize());
|
||||
}
|
||||
|
||||
minimizeWindow(windowId: number): TPromise<void> {
|
||||
async minimizeWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#minimizeWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.minimize();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.minimize());
|
||||
}
|
||||
|
||||
onWindowTitleDoubleClick(windowId: number): TPromise<void> {
|
||||
async onWindowTitleDoubleClick(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#onWindowTitleDoubleClick', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.onWindowTitleDoubleClick();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.onWindowTitleDoubleClick());
|
||||
}
|
||||
|
||||
setDocumentEdited(windowId: number, flag: boolean): TPromise<void> {
|
||||
async setDocumentEdited(windowId: number, flag: boolean): Promise<void> {
|
||||
this.logService.trace('windowsService#setDocumentEdited', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow && codeWindow.win.isDocumentEdited() !== flag) {
|
||||
codeWindow.win.setDocumentEdited(flag);
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => {
|
||||
if (codeWindow.win.isDocumentEdited() !== flag) {
|
||||
codeWindow.win.setDocumentEdited(flag);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise<void> {
|
||||
async openWindow(windowId: number, paths: URI[], options?: IOpenSettings): Promise<void> {
|
||||
this.logService.trace('windowsService#openWindow');
|
||||
if (!paths || !paths.length) {
|
||||
return TPromise.as(null);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
this.windowsMainService.open({
|
||||
@@ -411,100 +287,94 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
cli: options && options.args ? { ...this.environmentService.args, ...options.args } : this.environmentService.args,
|
||||
forceNewWindow: options && options.forceNewWindow,
|
||||
forceReuseWindow: options && options.forceReuseWindow,
|
||||
forceOpenWorkspaceAsFile: options && options.forceOpenWorkspaceAsFile
|
||||
forceOpenWorkspaceAsFile: options && options.forceOpenWorkspaceAsFile,
|
||||
diffMode: options && options.diffMode,
|
||||
addMode: options && options.addMode
|
||||
});
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
openNewWindow(options?: INewWindowOptions): TPromise<void> {
|
||||
async openNewWindow(options?: INewWindowOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#openNewWindow ' + JSON.stringify(options));
|
||||
|
||||
this.windowsMainService.openNewWindow(OpenContext.API, options);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
showWindow(windowId: number): TPromise<void> {
|
||||
async showWindow(windowId: number): Promise<void> {
|
||||
this.logService.trace('windowsService#showWindow', windowId);
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
|
||||
if (codeWindow) {
|
||||
codeWindow.win.show();
|
||||
}
|
||||
|
||||
return TPromise.as(null);
|
||||
return this.withWindow(windowId, codeWindow => codeWindow.win.show());
|
||||
}
|
||||
|
||||
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
async getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
this.logService.trace('windowsService#getWindows');
|
||||
|
||||
const windows = this.windowsMainService.getWindows();
|
||||
const result = windows.map(w => ({ id: w.id, workspace: w.openedWorkspace, folderUri: w.openedFolderUri, title: w.win.getTitle(), filename: w.getRepresentedFilename() }));
|
||||
|
||||
return TPromise.as(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
getWindowCount(): TPromise<number> {
|
||||
async getWindowCount(): Promise<number> {
|
||||
this.logService.trace('windowsService#getWindowCount');
|
||||
return TPromise.as(this.windowsMainService.getWindows().length);
|
||||
|
||||
return this.windowsMainService.getWindows().length;
|
||||
}
|
||||
|
||||
log(severity: string, ...messages: string[]): TPromise<void> {
|
||||
async log(severity: string, ...messages: string[]): Promise<void> {
|
||||
console[severity].apply(console, ...messages);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
showItemInFolder(path: string): TPromise<void> {
|
||||
async showItemInFolder(path: string): Promise<void> {
|
||||
this.logService.trace('windowsService#showItemInFolder');
|
||||
|
||||
shell.showItemInFolder(path);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
getActiveWindowId(): TPromise<number | undefined> {
|
||||
return TPromise.as(this._activeWindowId);
|
||||
async getActiveWindowId(): Promise<number | undefined> {
|
||||
return this._activeWindowId;
|
||||
}
|
||||
|
||||
openExternal(url: string): TPromise<boolean> {
|
||||
async openExternal(url: string): Promise<boolean> {
|
||||
this.logService.trace('windowsService#openExternal');
|
||||
return TPromise.as(shell.openExternal(url));
|
||||
|
||||
return shell.openExternal(url);
|
||||
}
|
||||
|
||||
startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void> {
|
||||
async startCrashReporter(config: Electron.CrashReporterStartOptions): Promise<void> {
|
||||
this.logService.trace('windowsService#startCrashReporter');
|
||||
|
||||
crashReporter.start(config);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
quit(): TPromise<void> {
|
||||
async quit(): Promise<void> {
|
||||
this.logService.trace('windowsService#quit');
|
||||
|
||||
this.windowsMainService.quit();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
|
||||
async relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
|
||||
this.logService.trace('windowsService#relaunch');
|
||||
this.lifecycleService.relaunch(options);
|
||||
|
||||
return TPromise.as(null);
|
||||
this.lifecycleService.relaunch(options);
|
||||
}
|
||||
|
||||
whenSharedProcessReady(): TPromise<void> {
|
||||
async whenSharedProcessReady(): Promise<void> {
|
||||
this.logService.trace('windowsService#whenSharedProcessReady');
|
||||
|
||||
return this.sharedProcess.whenReady();
|
||||
}
|
||||
|
||||
toggleSharedProcess(): TPromise<void> {
|
||||
async toggleSharedProcess(): Promise<void> {
|
||||
this.logService.trace('windowsService#toggleSharedProcess');
|
||||
|
||||
this.sharedProcess.toggle();
|
||||
return TPromise.as(null);
|
||||
|
||||
}
|
||||
|
||||
openAboutDialog(): TPromise<void> {
|
||||
async openAboutDialog(): Promise<void> {
|
||||
this.logService.trace('windowsService#openAboutDialog');
|
||||
const lastActiveWindow = this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
|
||||
|
||||
let version = app.getVersion();
|
||||
|
||||
if (product.target) {
|
||||
version = `${version} (${product.target} setup)`;
|
||||
}
|
||||
@@ -540,34 +410,32 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
buttons,
|
||||
noLink: true,
|
||||
defaultId: buttons.indexOf(ok)
|
||||
}, lastActiveWindow).then(result => {
|
||||
}, this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow()).then(result => {
|
||||
if (buttons[result.button] === copy) {
|
||||
clipboard.writeText(detail);
|
||||
}
|
||||
});
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
handleURL(uri: URI): TPromise<boolean> {
|
||||
async handleURL(uri: URI): Promise<boolean> {
|
||||
|
||||
// Catch file URLs
|
||||
if (uri.authority === Schemas.file && !!uri.path) {
|
||||
this.openFileForURI(URI.file(uri.fsPath));
|
||||
return TPromise.as(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return TPromise.wrap(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
private openFileForURI(uri: URI): TPromise<boolean> {
|
||||
private openFileForURI(uri: URI): void {
|
||||
const cli = assign(Object.create(null), this.environmentService.args, { goto: true });
|
||||
const urisToOpen = [uri];
|
||||
|
||||
this.windowsMainService.open({ context: OpenContext.API, cli, urisToOpen });
|
||||
return TPromise.wrap(true);
|
||||
}
|
||||
|
||||
resolveProxy(windowId: number, url: string): Promise<string | undefined> {
|
||||
async resolveProxy(windowId: number, url: string): Promise<string | undefined> {
|
||||
return new Promise(resolve => {
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
if (codeWindow) {
|
||||
@@ -580,6 +448,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
|
||||
});
|
||||
}
|
||||
|
||||
private withWindow<T>(windowId: number, fn: (window: ICodeWindow) => T, fallback?: () => T): T | undefined {
|
||||
const codeWindow = this.windowsMainService.getWindowById(windowId);
|
||||
if (codeWindow) {
|
||||
return fn(codeWindow);
|
||||
}
|
||||
|
||||
if (fallback) {
|
||||
return fallback();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Event, buffer } from 'vs/base/common/event';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows';
|
||||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IRecentlyOpened } from 'vs/platform/history/common/history';
|
||||
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
@@ -23,12 +22,12 @@ export class WindowsChannel implements IServerChannel {
|
||||
private onRecentlyOpenedChange: Event<void>;
|
||||
|
||||
constructor(private service: IWindowsService) {
|
||||
this.onWindowOpen = buffer(service.onWindowOpen, true);
|
||||
this.onWindowFocus = buffer(service.onWindowFocus, true);
|
||||
this.onWindowBlur = buffer(service.onWindowBlur, true);
|
||||
this.onWindowMaximize = buffer(service.onWindowMaximize, true);
|
||||
this.onWindowUnmaximize = buffer(service.onWindowUnmaximize, true);
|
||||
this.onRecentlyOpenedChange = buffer(service.onRecentlyOpenedChange, true);
|
||||
this.onWindowOpen = Event.buffer(service.onWindowOpen, true);
|
||||
this.onWindowFocus = Event.buffer(service.onWindowFocus, true);
|
||||
this.onWindowBlur = Event.buffer(service.onWindowBlur, true);
|
||||
this.onWindowMaximize = Event.buffer(service.onWindowMaximize, true);
|
||||
this.onWindowUnmaximize = Event.buffer(service.onWindowUnmaximize, true);
|
||||
this.onRecentlyOpenedChange = Event.buffer(service.onRecentlyOpenedChange, true);
|
||||
}
|
||||
|
||||
listen(_, event: string): Event<any> {
|
||||
@@ -44,7 +43,7 @@ export class WindowsChannel implements IServerChannel {
|
||||
throw new Error(`Event not found: ${event}`);
|
||||
}
|
||||
|
||||
call(_, command: string, arg?: any): Thenable<any> {
|
||||
call(_, command: string, arg?: any): Promise<any> {
|
||||
switch (command) {
|
||||
case 'pickFileFolderAndOpen': return this.service.pickFileFolderAndOpen(arg);
|
||||
case 'pickFileAndOpen': return this.service.pickFileAndOpen(arg);
|
||||
@@ -57,27 +56,12 @@ export class WindowsChannel implements IServerChannel {
|
||||
case 'openDevTools': return this.service.openDevTools(arg[0], arg[1]);
|
||||
case 'toggleDevTools': return this.service.toggleDevTools(arg);
|
||||
case 'closeWorkspace': return this.service.closeWorkspace(arg);
|
||||
case 'enterWorkspace': return this.service.enterWorkspace(arg[0], arg[1]);
|
||||
case 'createAndEnterWorkspace': {
|
||||
const rawFolders: IWorkspaceFolderCreationData[] = arg[1];
|
||||
let folders: IWorkspaceFolderCreationData[] | undefined = undefined;
|
||||
if (Array.isArray(rawFolders)) {
|
||||
folders = rawFolders.map(rawFolder => {
|
||||
return {
|
||||
uri: URI.revive(rawFolder.uri), // convert raw URI back to real URI
|
||||
name: rawFolder.name
|
||||
} as IWorkspaceFolderCreationData;
|
||||
});
|
||||
}
|
||||
|
||||
return this.service.createAndEnterWorkspace(arg[0], folders, arg[2]);
|
||||
}
|
||||
case 'saveAndEnterWorkspace': return this.service.saveAndEnterWorkspace(arg[0], arg[1]);
|
||||
case 'enterWorkspace': return this.service.enterWorkspace(arg[0], URI.revive(arg[1]));
|
||||
case 'toggleFullScreen': return this.service.toggleFullScreen(arg);
|
||||
case 'setRepresentedFilename': return this.service.setRepresentedFilename(arg[0], arg[1]);
|
||||
case 'addRecentlyOpened': return this.service.addRecentlyOpened(arg.map(URI.revive));
|
||||
case 'removeFromRecentlyOpened': {
|
||||
let paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[] = arg;
|
||||
let paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string> = arg;
|
||||
if (Array.isArray(paths)) {
|
||||
paths = paths.map(path => isWorkspaceIdentifier(path) || typeof path === 'string' ? path : URI.revive(path));
|
||||
}
|
||||
@@ -136,213 +120,205 @@ export class WindowsChannelClient implements IWindowsService {
|
||||
get onWindowUnmaximize(): Event<number> { return this.channel.listen('onWindowUnmaximize'); }
|
||||
get onRecentlyOpenedChange(): Event<void> { return this.channel.listen('onRecentlyOpenedChange'); }
|
||||
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('pickFileFolderAndOpen', options));
|
||||
pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
return this.channel.call('pickFileFolderAndOpen', options);
|
||||
}
|
||||
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('pickFileAndOpen', options));
|
||||
pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
return this.channel.call('pickFileAndOpen', options);
|
||||
}
|
||||
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('pickFolderAndOpen', options));
|
||||
pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
return this.channel.call('pickFolderAndOpen', options);
|
||||
}
|
||||
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('pickWorkspaceAndOpen', options));
|
||||
pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> {
|
||||
return this.channel.call('pickWorkspaceAndOpen', options);
|
||||
}
|
||||
|
||||
showMessageBox(windowId: number, options: MessageBoxOptions): TPromise<IMessageBoxResult> {
|
||||
return TPromise.wrap(this.channel.call('showMessageBox', [windowId, options]));
|
||||
showMessageBox(windowId: number, options: MessageBoxOptions): Promise<IMessageBoxResult> {
|
||||
return this.channel.call('showMessageBox', [windowId, options]);
|
||||
}
|
||||
|
||||
showSaveDialog(windowId: number, options: SaveDialogOptions): TPromise<string> {
|
||||
return TPromise.wrap(this.channel.call('showSaveDialog', [windowId, options]));
|
||||
showSaveDialog(windowId: number, options: SaveDialogOptions): Promise<string> {
|
||||
return this.channel.call('showSaveDialog', [windowId, options]);
|
||||
}
|
||||
|
||||
showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise<string[]> {
|
||||
return TPromise.wrap(this.channel.call('showOpenDialog', [windowId, options]));
|
||||
showOpenDialog(windowId: number, options: OpenDialogOptions): Promise<string[]> {
|
||||
return this.channel.call('showOpenDialog', [windowId, options]);
|
||||
}
|
||||
|
||||
reloadWindow(windowId: number, args?: ParsedArgs): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('reloadWindow', [windowId, args]));
|
||||
reloadWindow(windowId: number, args?: ParsedArgs): Promise<void> {
|
||||
return this.channel.call('reloadWindow', [windowId, args]);
|
||||
}
|
||||
|
||||
openDevTools(windowId: number, options?: IDevToolsOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('openDevTools', [windowId, options]));
|
||||
openDevTools(windowId: number, options?: IDevToolsOptions): Promise<void> {
|
||||
return this.channel.call('openDevTools', [windowId, options]);
|
||||
}
|
||||
|
||||
toggleDevTools(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('toggleDevTools', windowId));
|
||||
toggleDevTools(windowId: number): Promise<void> {
|
||||
return this.channel.call('toggleDevTools', windowId);
|
||||
}
|
||||
|
||||
closeWorkspace(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('closeWorkspace', windowId));
|
||||
closeWorkspace(windowId: number): Promise<void> {
|
||||
return this.channel.call('closeWorkspace', windowId);
|
||||
}
|
||||
|
||||
enterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.wrap(this.channel.call('enterWorkspace', [windowId, path]));
|
||||
enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult> {
|
||||
return this.channel.call('enterWorkspace', [windowId, path]);
|
||||
}
|
||||
|
||||
createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.wrap(this.channel.call('createAndEnterWorkspace', [windowId, folders, path]));
|
||||
toggleFullScreen(windowId: number): Promise<void> {
|
||||
return this.channel.call('toggleFullScreen', windowId);
|
||||
}
|
||||
|
||||
saveAndEnterWorkspace(windowId: number, path: string): TPromise<IEnterWorkspaceResult> {
|
||||
return TPromise.wrap(this.channel.call('saveAndEnterWorkspace', [windowId, path]));
|
||||
setRepresentedFilename(windowId: number, fileName: string): Promise<void> {
|
||||
return this.channel.call('setRepresentedFilename', [windowId, fileName]);
|
||||
}
|
||||
|
||||
toggleFullScreen(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('toggleFullScreen', windowId));
|
||||
addRecentlyOpened(files: URI[]): Promise<void> {
|
||||
return this.channel.call('addRecentlyOpened', files);
|
||||
}
|
||||
|
||||
setRepresentedFilename(windowId: number, fileName: string): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('setRepresentedFilename', [windowId, fileName]));
|
||||
removeFromRecentlyOpened(paths: Array<IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI>): Promise<void> {
|
||||
return this.channel.call('removeFromRecentlyOpened', paths);
|
||||
}
|
||||
|
||||
addRecentlyOpened(files: URI[]): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('addRecentlyOpened', files));
|
||||
clearRecentlyOpened(): Promise<void> {
|
||||
return this.channel.call('clearRecentlyOpened');
|
||||
}
|
||||
|
||||
removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI)[]): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('removeFromRecentlyOpened', paths));
|
||||
}
|
||||
|
||||
clearRecentlyOpened(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('clearRecentlyOpened'));
|
||||
}
|
||||
|
||||
getRecentlyOpened(windowId: number): TPromise<IRecentlyOpened> {
|
||||
return TPromise.wrap<IRecentlyOpened>(this.channel.call('getRecentlyOpened', windowId))
|
||||
.then(recentlyOpened => {
|
||||
getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
|
||||
return this.channel.call('getRecentlyOpened', windowId)
|
||||
.then((recentlyOpened: IRecentlyOpened) => {
|
||||
recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace));
|
||||
recentlyOpened.files = recentlyOpened.files.map(URI.revive);
|
||||
return recentlyOpened;
|
||||
});
|
||||
}
|
||||
|
||||
newWindowTab(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('newWindowTab'));
|
||||
newWindowTab(): Promise<void> {
|
||||
return this.channel.call('newWindowTab');
|
||||
}
|
||||
|
||||
showPreviousWindowTab(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('showPreviousWindowTab'));
|
||||
showPreviousWindowTab(): Promise<void> {
|
||||
return this.channel.call('showPreviousWindowTab');
|
||||
}
|
||||
|
||||
showNextWindowTab(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('showNextWindowTab'));
|
||||
showNextWindowTab(): Promise<void> {
|
||||
return this.channel.call('showNextWindowTab');
|
||||
}
|
||||
|
||||
moveWindowTabToNewWindow(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('moveWindowTabToNewWindow'));
|
||||
moveWindowTabToNewWindow(): Promise<void> {
|
||||
return this.channel.call('moveWindowTabToNewWindow');
|
||||
}
|
||||
|
||||
mergeAllWindowTabs(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('mergeAllWindowTabs'));
|
||||
mergeAllWindowTabs(): Promise<void> {
|
||||
return this.channel.call('mergeAllWindowTabs');
|
||||
}
|
||||
|
||||
toggleWindowTabsBar(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('toggleWindowTabsBar'));
|
||||
toggleWindowTabsBar(): Promise<void> {
|
||||
return this.channel.call('toggleWindowTabsBar');
|
||||
}
|
||||
|
||||
focusWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('focusWindow', windowId));
|
||||
focusWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('focusWindow', windowId);
|
||||
}
|
||||
|
||||
closeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('closeWindow', windowId));
|
||||
closeWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('closeWindow', windowId);
|
||||
}
|
||||
|
||||
isFocused(windowId: number): TPromise<boolean> {
|
||||
return TPromise.wrap(this.channel.call('isFocused', windowId));
|
||||
isFocused(windowId: number): Promise<boolean> {
|
||||
return this.channel.call('isFocused', windowId);
|
||||
}
|
||||
|
||||
isMaximized(windowId: number): TPromise<boolean> {
|
||||
return TPromise.wrap(this.channel.call('isMaximized', windowId));
|
||||
isMaximized(windowId: number): Promise<boolean> {
|
||||
return this.channel.call('isMaximized', windowId);
|
||||
}
|
||||
|
||||
maximizeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('maximizeWindow', windowId));
|
||||
maximizeWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('maximizeWindow', windowId);
|
||||
}
|
||||
|
||||
unmaximizeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('unmaximizeWindow', windowId));
|
||||
unmaximizeWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('unmaximizeWindow', windowId);
|
||||
}
|
||||
|
||||
minimizeWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('minimizeWindow', windowId));
|
||||
minimizeWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('minimizeWindow', windowId);
|
||||
}
|
||||
|
||||
onWindowTitleDoubleClick(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('onWindowTitleDoubleClick', windowId));
|
||||
onWindowTitleDoubleClick(windowId: number): Promise<void> {
|
||||
return this.channel.call('onWindowTitleDoubleClick', windowId);
|
||||
}
|
||||
|
||||
setDocumentEdited(windowId: number, flag: boolean): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('setDocumentEdited', [windowId, flag]));
|
||||
setDocumentEdited(windowId: number, flag: boolean): Promise<void> {
|
||||
return this.channel.call('setDocumentEdited', [windowId, flag]);
|
||||
}
|
||||
|
||||
quit(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('quit'));
|
||||
quit(): Promise<void> {
|
||||
return this.channel.call('quit');
|
||||
}
|
||||
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('relaunch', [options]));
|
||||
relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
|
||||
return this.channel.call('relaunch', [options]);
|
||||
}
|
||||
|
||||
whenSharedProcessReady(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('whenSharedProcessReady'));
|
||||
whenSharedProcessReady(): Promise<void> {
|
||||
return this.channel.call('whenSharedProcessReady');
|
||||
}
|
||||
|
||||
toggleSharedProcess(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('toggleSharedProcess'));
|
||||
toggleSharedProcess(): Promise<void> {
|
||||
return this.channel.call('toggleSharedProcess');
|
||||
}
|
||||
|
||||
openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('openWindow', [windowId, paths, options]));
|
||||
openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Promise<void> {
|
||||
return this.channel.call('openWindow', [windowId, paths, options]);
|
||||
}
|
||||
|
||||
openNewWindow(options?: INewWindowOptions): TPromise<void> {
|
||||
openNewWindow(options?: INewWindowOptions): Promise<void> {
|
||||
return this.channel.call('openNewWindow', options);
|
||||
}
|
||||
|
||||
showWindow(windowId: number): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('showWindow', windowId));
|
||||
showWindow(windowId: number): Promise<void> {
|
||||
return this.channel.call('showWindow', windowId);
|
||||
}
|
||||
|
||||
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
return TPromise.wrap(this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; }));
|
||||
getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> {
|
||||
return this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; });
|
||||
}
|
||||
|
||||
getWindowCount(): TPromise<number> {
|
||||
return TPromise.wrap(this.channel.call('getWindowCount'));
|
||||
getWindowCount(): Promise<number> {
|
||||
return this.channel.call('getWindowCount');
|
||||
}
|
||||
|
||||
log(severity: string, ...messages: string[]): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('log', [severity, messages]));
|
||||
log(severity: string, ...messages: string[]): Promise<void> {
|
||||
return this.channel.call('log', [severity, messages]);
|
||||
}
|
||||
|
||||
showItemInFolder(path: string): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('showItemInFolder', path));
|
||||
showItemInFolder(path: string): Promise<void> {
|
||||
return this.channel.call('showItemInFolder', path);
|
||||
}
|
||||
|
||||
getActiveWindowId(): TPromise<number | undefined> {
|
||||
return TPromise.wrap(this.channel.call('getActiveWindowId'));
|
||||
getActiveWindowId(): Promise<number | undefined> {
|
||||
return this.channel.call('getActiveWindowId');
|
||||
}
|
||||
|
||||
openExternal(url: string): TPromise<boolean> {
|
||||
return TPromise.wrap(this.channel.call('openExternal', url));
|
||||
openExternal(url: string): Promise<boolean> {
|
||||
return this.channel.call('openExternal', url);
|
||||
}
|
||||
|
||||
startCrashReporter(config: CrashReporterStartOptions): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('startCrashReporter', config));
|
||||
startCrashReporter(config: CrashReporterStartOptions): Promise<void> {
|
||||
return this.channel.call('startCrashReporter', config);
|
||||
}
|
||||
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('updateTouchBar', [windowId, items]));
|
||||
updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void> {
|
||||
return this.channel.call('updateTouchBar', [windowId, items]);
|
||||
}
|
||||
|
||||
openAboutDialog(): TPromise<void> {
|
||||
return TPromise.wrap(this.channel.call('openAboutDialog'));
|
||||
openAboutDialog(): Promise<void> {
|
||||
return this.channel.call('openAboutDialog');
|
||||
}
|
||||
|
||||
resolveProxy(windowId: number, url: string): Promise<string | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user