1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-26 04:14:29 +00:00
code-server-2/packages/vscode/src/fill/workspacesService.ts
Asher 14da71499f
Set platform based on server (#32)
* Set platform based on server

Had to refactor a bit to ensure our values get set before VS Code tries
to use them.

* Pave the way for mnemonics on all platforms

* Fix context menus on Mac

* Fix a bunch of things on Mac including menu bar

* Set keybindings based on client's OS
2019-02-26 12:01:14 -06:00

41 lines
1.7 KiB
TypeScript

import { URI } from "vs/base/common/uri";
import { IEnvironmentService } from "vs/platform/environment/common/environment";
import { ILogService } from "vs/platform/log/common/log";
import { IWorkspaceFolderCreationData, IWorkspaceIdentifier, IWorkspacesService } from "vs/platform/workspaces/common/workspaces";
import { WorkspacesMainService } from "vs/platform/workspaces/electron-main/workspacesMainService";
import * as workspacesIpc from "vs/platform/workspaces/node/workspacesIpc";
import { workbench } from "../workbench";
/**
* Instead of going to the shared process, we'll directly run these methods on
* the client. This setup means we can only control the current window.
*/
class WorkspacesService implements IWorkspacesService {
// tslint:disable-next-line:no-any
public _serviceBrand: any;
public createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[] | undefined): Promise<IWorkspaceIdentifier> {
const mainService = new WorkspacesMainService(
workbench.serviceCollection.get<IEnvironmentService>(IEnvironmentService) as IEnvironmentService,
workbench.serviceCollection.get<ILogService>(ILogService) as ILogService,
);
// lib/vscode/src/vs/platform/workspaces/node/workspacesIpc.ts
const rawFolders: IWorkspaceFolderCreationData[] = folders!;
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 mainService.createUntitledWorkspace(folders);
}
}
const target = workspacesIpc as typeof workspacesIpc;
// @ts-ignore TODO: don't ignore it.
target.WorkspacesChannelClient = WorkspacesService;