Update window service fill

This commit is contained in:
Asher 2019-04-08 18:04:41 -05:00
parent 94b8b9a5cf
commit a2f20aa25c
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC
2 changed files with 22 additions and 19 deletions

View File

@ -11,6 +11,8 @@ import { IStorageService, WillSaveStateReason } from "vs/platform/storage/common
import * as paths from "./paths"; import * as paths from "./paths";
import { workbench } from "../workbench"; import { workbench } from "../workbench";
// tslint:disable completed-docs
class StorageDatabase implements workspaceStorage.IStorageDatabase { class StorageDatabase implements workspaceStorage.IStorageDatabase {
public readonly onDidChangeItemsExternal = Event.None; public readonly onDidChangeItemsExternal = Event.None;
private readonly items = new Map<string, string>(); private readonly items = new Map<string, string>();

View File

@ -1,15 +1,18 @@
import * as electron from "electron"; import * as electron from "electron";
import { Emitter } from "@coder/events"; import { Emitter } from "@coder/events";
import { IWindowsService, INativeOpenDialogOptions, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IMessageBoxResult, IDevToolsOptions, IEnterWorkspaceResult, CrashReporterStartOptions, INewWindowOptions, IOpenFileRequest, IAddFoldersRequest } from "vs/platform/windows/common/windows"; import { logger } from "@coder/logger";
import { IWindowsService, INativeOpenDialogOptions, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IMessageBoxResult, IDevToolsOptions, IEnterWorkspaceResult, CrashReporterStartOptions, INewWindowOptions, IOpenFileRequest, IAddFoldersRequest, IURIToOpen, IOpenSettings } from "vs/platform/windows/common/windows";
import { ParsedArgs } from "vs/platform/environment/common/environment"; import { ParsedArgs } from "vs/platform/environment/common/environment";
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces"; import { IWorkspaceIdentifier, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces";
import { URI } from "vs/base/common/uri"; import { URI } from "vs/base/common/uri";
import { IRecentlyOpened } from "vs/platform/history/common/history"; import { IRecentlyOpened, IRecent } from "vs/platform/history/common/history";
import { ISerializableCommandAction } from "vs/platform/actions/common/actions"; import { ISerializableCommandAction } from "vs/platform/actions/common/actions";
import { client } from "../client"; import { client } from "../client";
import { showOpenDialog } from "../dialog"; import { showOpenDialog } from "../dialog";
import { workbench } from "../workbench"; import { workbench } from "../workbench";
// tslint:disable completed-docs
// VS Code overrides window.open to call openExternal, but we then call // VS Code overrides window.open to call openExternal, but we then call
// window.open which results in an infinite loop. Store the function but also // window.open which results in an infinite loop. Store the function but also
// make it unable to be set (doesn't work otherwise). // make it unable to be set (doesn't work otherwise).
@ -59,7 +62,7 @@ export class WindowsService implements IWindowsService {
}], }],
} as IOpenFileRequest); } as IOpenFileRequest);
}).catch((ex) => { }).catch((ex) => {
// logger.error(ex.message);
}); });
} }
@ -77,7 +80,7 @@ export class WindowsService implements IWindowsService {
}], }],
} as IOpenFileRequest); } as IOpenFileRequest);
}).catch((ex) => { }).catch((ex) => {
// logger.error(ex.message);
}); });
} }
@ -90,7 +93,7 @@ export class WindowsService implements IWindowsService {
}).then((path) => { }).then((path) => {
workbench.workspace = URI.file(path); workbench.workspace = URI.file(path);
}).catch((ex) => { }).catch((ex) => {
// logger.error(ex.message);
}); });
} }
@ -106,7 +109,7 @@ export class WindowsService implements IWindowsService {
foldersToAdd: [URI.file(path)], foldersToAdd: [URI.file(path)],
} as IAddFoldersRequest); } as IAddFoldersRequest);
}).catch((ex) => { }).catch((ex) => {
// logger.error(ex.message);
}); });
} }
@ -129,16 +132,14 @@ export class WindowsService implements IWindowsService {
}); });
} }
public showOpenDialog(windowId: number, options: OpenDialogOptions): Promise<string[]> { public async showOpenDialog(_windowId: number, options: OpenDialogOptions): Promise<string[]> {
return showOpenDialog({ return [await showOpenDialog({
...(options || {}), ...(options || {}),
properties: { properties: {
openDirectory: true, openDirectory: true,
openFile: true, openFile: true,
}, },
}).then((path) => { })];
return [path];
});
} }
public reloadWindow(windowId: number, _args?: ParsedArgs): Promise<void> { public reloadWindow(windowId: number, _args?: ParsedArgs): Promise<void> {
@ -157,14 +158,14 @@ export class WindowsService implements IWindowsService {
throw new Error("not implemented"); throw new Error("not implemented");
} }
public enterWorkspace(_windowId: number, _path: URI): Promise<IEnterWorkspaceResult> { public enterWorkspace(_windowId: number, uri: URI): Promise<IEnterWorkspaceResult> {
if (_path.path.endsWith(".json")) { if (uri.path.endsWith(".json")) {
workbench.workspace = { workbench.workspace = {
id: "Untitled", id: "Untitled",
configPath: _path.path, configPath: uri,
}; };
} else { } else {
workbench.workspace = _path; workbench.workspace = uri;
} }
return undefined!; return undefined!;
@ -188,7 +189,7 @@ export class WindowsService implements IWindowsService {
return Promise.resolve(this.getWindowById(windowId).setRepresentedFilename(fileName)); return Promise.resolve(this.getWindowById(windowId).setRepresentedFilename(fileName));
} }
public addRecentlyOpened(_files: URI[]): Promise<void> { public addRecentlyOpened(_files: IRecent[]): Promise<void> {
throw new Error("not implemented"); throw new Error("not implemented");
} }
@ -292,7 +293,7 @@ export class WindowsService implements IWindowsService {
} }
// Global methods // Global methods
public openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Promise<void> { public openWindow(_windowId: number, _uris: IURIToOpen[], _options?: IOpenSettings): Promise<void> {
throw new Error("not implemented"); throw new Error("not implemented");
} }
@ -316,8 +317,8 @@ export class WindowsService implements IWindowsService {
throw new Error("not implemented"); throw new Error("not implemented");
} }
public async showItemInFolder(_path: string): Promise<void> { public async showItemInFolder(uri: URI): Promise<void> {
workbench.workspace = URI.file(_path); workbench.workspace = uri;
} }
public getActiveWindowId(): Promise<number | undefined> { public getActiveWindowId(): Promise<number | undefined> {