提交 f5902b5a 编写于 作者: B Benjamin Pasero

adopt workspace for getWindows() call

上级 e4b90c2b
......@@ -53,7 +53,6 @@ import { KeyboardLayoutMonitor } from "vs/code/electron-main/keyboard";
import URI from 'vs/base/common/uri';
import { WorkspacesChannel } from "vs/platform/workspaces/common/workspacesIpc";
import { IWorkspacesMainService } from "vs/platform/workspaces/common/workspaces";
import { WorkspacesMainService } from "vs/platform/workspaces/electron-main/workspacesMainService";
export class CodeApplication {
private toDispose: IDisposable[];
......@@ -290,7 +289,6 @@ export class CodeApplication {
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager));
services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess));
services.set(ILaunchService, new SyncDescriptor(LaunchService));
services.set(IWorkspacesMainService, new SyncDescriptor(WorkspacesMainService));
// Telemtry
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !!product.enableTelemetry) {
......
......@@ -35,12 +35,15 @@ import * as fs from 'original-fs';
import { CodeApplication } from "vs/code/electron-main/app";
import { HistoryMainService } from "vs/platform/history/electron-main/historyMainService";
import { IHistoryMainService } from "vs/platform/history/common/history";
import { WorkspacesMainService } from "vs/platform/workspaces/electron-main/workspacesMainService";
import { IWorkspacesMainService } from "vs/platform/workspaces/common/workspaces";
function createServices(args: ParsedArgs): IInstantiationService {
const services = new ServiceCollection();
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, args, process.execPath));
services.set(ILogService, new SyncDescriptor(LogMainService));
services.set(IWorkspacesMainService, new SyncDescriptor(WorkspacesMainService));
services.set(IHistoryMainService, new SyncDescriptor(HistoryMainService));
services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
services.set(IStorageService, new SyncDescriptor(StorageService));
......
......@@ -56,7 +56,7 @@ export interface IWindowsService {
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void>;
openNewWindow(): TPromise<void>;
showWindow(windowId: number): TPromise<void>;
getWindows(): TPromise<{ id: number; path: string; title: string; filename?: string; }[]>;
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]>;
getWindowCount(): TPromise<number>;
log(severity: string, ...messages: string[]): TPromise<void>;
// TODO@joao: what?
......
......@@ -41,7 +41,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'openWindow', arg: [string[], { forceNewWindow?: boolean, forceReuseWindow?: boolean }]): TPromise<void>;
call(command: 'openNewWindow'): TPromise<void>;
call(command: 'showWindow', arg: number): TPromise<void>;
call(command: 'getWindows'): TPromise<{ id: number; path: string; title: string; }[]>;
call(command: 'getWindows'): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]>;
call(command: 'getWindowCount'): TPromise<number>;
call(command: 'relaunch', arg: { addArgs?: string[], removeArgs?: string[] }): TPromise<number>;
call(command: 'whenSharedProcessReady'): TPromise<void>;
......@@ -237,7 +237,7 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('showWindow', windowId);
}
getWindows(): TPromise<{ id: number; path: string; title: string; }[]> {
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
return this.channel.call('getWindows');
}
......
......@@ -274,9 +274,9 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
getWindows(): TPromise<{ id: number; path: string; title: string; }[]> {
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
const windows = this.windowsMainService.getWindows();
const result = windows.map(w => ({ path: w.openedFolderPath, title: w.win.getTitle(), id: w.id, filename: w.getRepresentedFilename() }));
const result = windows.map(w => ({ id: w.id, workspace: w.openedWorkspace, openedFolderPath: w.openedFolderPath, title: w.win.getTitle(), filename: w.getRepresentedFilename() }));
return TPromise.as(result);
}
......
......@@ -576,11 +576,11 @@ export abstract class BaseSwitchWindow extends Action {
public run(): TPromise<void> {
const currentWindowId = this.windowService.getCurrentWindowId();
return this.windowsService.getWindows().then(workspaces => {
return this.windowsService.getWindows().then(windows => {
const placeHolder = nls.localize('switchWindowPlaceHolder', "Select a window to switch to");
const picks = workspaces.map(win => ({
resource: win.filename ? URI.file(win.filename) : win.path,
isFolder: !win.filename && !!win.path,
const picks = windows.map(win => ({
resource: win.filename ? URI.file(win.filename) : win.folderPath ? URI.file(win.folderPath) : win.workspace ? URI.file(win.workspace.configPath) : void 0,
isFolder: !win.workspace && !win.filename && !!win.folderPath,
label: win.title,
description: (currentWindowId === win.id) ? nls.localize('current', "Current Window") : void 0,
run: () => {
......@@ -702,9 +702,19 @@ export abstract class BaseOpenRecentAction extends Action {
const hasWorkspace = this.contextService.hasWorkspace();
let autoFocusFirstEntry = !hasWorkspace;
let autoFocusSecondEntry = !autoFocusFirstEntry;
if (workspacePicks.length > 0 && folderPicks.length > 0) {
// if we show both workspace picks and folder picks, we can no longer make any smart
// auto focus choice because the list is no longer in pure MRU order. In this case
// we simply do not focus any entry.
autoFocusFirstEntry = false;
autoFocusSecondEntry = false;
}
this.quickOpenService.pick([...workspacePicks, ...folderPicks, ...filePicks], {
contextKey: inRecentFilesPickerContextKey,
autoFocus: { autoFocusFirstEntry: !hasWorkspace, autoFocusSecondEntry: hasWorkspace },
autoFocus: { autoFocusFirstEntry, autoFocusSecondEntry },
placeHolder: isMacintosh ? nls.localize('openRecentPlaceHolderMac', "Select to open (hold Cmd-key to open in new window)") : nls.localize('openRecentPlaceHolder', "Select to open (hold Ctrl-key to open in new window)"),
matchOnDescription: true,
quickNavigateConfiguration: this.isQuickNavigate() ? { keybindings: this.keybindingService.lookupKeybindings(this.id) } : void 0
......
......@@ -1092,7 +1092,7 @@ export class TestWindowsService implements IWindowsService {
return TPromise.as(void 0);
}
getWindows(): TPromise<{ id: number; path: string; title: string; }[]> {
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]> {
return TPromise.as(void 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册