提交 3fa0bdbb 编写于 作者: B Benjamin Pasero

fix #49587

上级 8fbfcb1c
......@@ -716,7 +716,11 @@ export class WindowsManager implements IWindowsMainService {
return window;
}
private doOpenFolderOrWorkspace(openConfig: IOpenConfiguration, folderOrWorkspace: IPathToOpen, openInNewWindow: boolean, filesToOpen: IPath[], filesToCreate: IPath[], filesToDiff: IPath[], filesToWait: IPathsToWaitFor, windowToUse?: ICodeWindow): ICodeWindow {
private doOpenFolderOrWorkspace(openConfig: IOpenConfiguration, folderOrWorkspace: IPathToOpen, forceNewWindow: boolean, filesToOpen: IPath[], filesToCreate: IPath[], filesToDiff: IPath[], filesToWait: IPathsToWaitFor, windowToUse?: ICodeWindow): ICodeWindow {
if (!forceNewWindow && !windowToUse && typeof openConfig.contextWindowId === 'number') {
windowToUse = this.getWindowById(openConfig.contextWindowId); // fix for https://github.com/Microsoft/vscode/issues/49587
}
const browserWindow = this.openInBrowserWindow({
userEnv: openConfig.userEnv,
cli: openConfig.cli,
......@@ -727,7 +731,7 @@ export class WindowsManager implements IWindowsMainService {
filesToCreate,
filesToDiff,
filesToWait,
forceNewWindow: openInNewWindow,
forceNewWindow,
windowToUse
});
......
......@@ -151,7 +151,7 @@ export interface IWindowsService {
toggleSharedProcess(): TPromise<void>;
// Global methods
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean; }): TPromise<void>;
openWindow(windowId: number, paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean; }): TPromise<void>;
openNewWindow(): TPromise<void>;
showWindow(windowId: number): TPromise<void>;
getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]>;
......@@ -200,6 +200,7 @@ export interface IWindowService {
getRecentlyOpened(): TPromise<IRecentlyOpened>;
focusWindow(): TPromise<void>;
closeWindow(): TPromise<void>;
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean; }): TPromise<void>;
isFocused(): TPromise<boolean>;
setDocumentEdited(flag: boolean): TPromise<void>;
onWindowTitleDoubleClick(): TPromise<void>;
......
......@@ -52,7 +52,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'onWindowTitleDoubleClick', arg: number): TPromise<void>;
call(command: 'setDocumentEdited', arg: [number, boolean]): TPromise<void>;
call(command: 'quit'): TPromise<void>;
call(command: 'openWindow', arg: [string[], { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }]): TPromise<void>;
call(command: 'openWindow', arg: [number, string[], { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }]): TPromise<void>;
call(command: 'openNewWindow'): TPromise<void>;
call(command: 'showWindow', arg: number): TPromise<void>;
call(command: 'getWindows'): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderPath?: string; title: string; filename?: string; }[]>;
......@@ -131,7 +131,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'unmaximizeWindow': return this.service.unmaximizeWindow(arg);
case 'onWindowTitleDoubleClick': return this.service.onWindowTitleDoubleClick(arg);
case 'setDocumentEdited': return this.service.setDocumentEdited(arg[0], arg[1]);
case 'openWindow': return this.service.openWindow(arg[0], arg[1]);
case 'openWindow': return this.service.openWindow(arg[0], arg[1], arg[2]);
case 'openNewWindow': return this.service.openNewWindow();
case 'showWindow': return this.service.showWindow(arg);
case 'getWindows': return this.service.getWindows();
......@@ -309,8 +309,8 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('toggleSharedProcess');
}
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
return this.channel.call('openWindow', [paths, options]);
openWindow(windowId: number, paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
return this.channel.call('openWindow', [windowId, paths, options]);
}
openNewWindow(): TPromise<void> {
......
......@@ -85,6 +85,10 @@ export class WindowService implements IWindowService {
return this.windowsService.saveAndEnterWorkspace(this.windowId, path);
}
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean; }): TPromise<void> {
return this.windowsService.openWindow(this.windowId, paths, options);
}
closeWindow(): TPromise<void> {
return this.windowsService.closeWindow(this.windowId);
}
......
......@@ -119,6 +119,7 @@ export interface IWindowsMainService {
export interface IOpenConfiguration {
context: OpenContext;
contextWindowId?: number;
cli: ParsedArgs;
userEnv?: IProcessEnvironment;
pathsToOpen?: string[];
......
......@@ -360,7 +360,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
return TPromise.as(null);
}
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
openWindow(windowId: number, paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
this.logService.trace('windowsService#openWindow');
if (!paths || !paths.length) {
return TPromise.as(null);
......@@ -368,6 +368,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
this.windowsMainService.open({
context: OpenContext.API,
contextWindowId: windowId,
cli: this.environmentService.args,
pathsToOpen: paths,
forceNewWindow: options && options.forceNewWindow,
......
......@@ -8,7 +8,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import * as nls from 'vs/nls';
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
......@@ -228,7 +228,7 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
label: string,
@IWorkspaceContextService private workspaceContextService: IWorkspaceContextService,
@IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService,
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IWorkspacesService private workspacesService: IWorkspacesService
) {
super(id, label);
......@@ -239,7 +239,7 @@ export class DuplicateWorkspaceInNewWindowAction extends Action {
return this.workspacesService.createWorkspace(folders).then(newWorkspace => {
return this.workspaceEditingService.copyWorkspaceSettings(newWorkspace).then(() => {
return this.windowsService.openWindow([newWorkspace.configPath], { forceNewWindow: true });
return this.windowService.openWindow([newWorkspace.configPath], { forceNewWindow: true });
});
});
}
......
......@@ -299,7 +299,7 @@ export class ResourcesDropHandler {
// Open
workspacesToOpen.then(workspaces => {
this.windowsService.openWindow(workspaces, { forceReuseWindow: true });
this.windowService.openWindow(workspaces, { forceReuseWindow: true });
});
return true;
......
......@@ -702,7 +702,6 @@ export abstract class BaseOpenRecentAction extends Action {
constructor(
id: string,
label: string,
private windowsService: IWindowsService,
private windowService: IWindowService,
private quickOpenService: IQuickOpenService,
private contextService: IWorkspaceContextService,
......@@ -757,7 +756,7 @@ export abstract class BaseOpenRecentAction extends Action {
const runPick = (path: string, isFile: boolean, context: IEntryRunContext) => {
const forceNewWindow = context.keymods.ctrlCmd;
this.windowsService.openWindow([path], { forceNewWindow, forceOpenWorkspaceAsFile: isFile });
this.windowService.openWindow([path], { forceNewWindow, forceOpenWorkspaceAsFile: isFile });
};
const workspacePicks: IFilePickOpenEntry[] = recentWorkspaces.map((workspace, index) => toPick(workspace, index === 0 ? { label: nls.localize('workspaces', "workspaces") } : void 0, isSingleFolderWorkspaceIdentifier(workspace) ? FileKind.FOLDER : FileKind.ROOT_FOLDER, this.environmentService, !this.isQuickNavigate() ? this.removeAction : void 0));
......@@ -812,7 +811,6 @@ export class OpenRecentAction extends BaseOpenRecentAction {
constructor(
id: string,
label: string,
@IWindowsService windowsService: IWindowsService,
@IWindowService windowService: IWindowService,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
......@@ -820,7 +818,7 @@ export class OpenRecentAction extends BaseOpenRecentAction {
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService
) {
super(id, label, windowsService, windowService, quickOpenService, contextService, environmentService, keybindingService, instantiationService);
super(id, label, windowService, quickOpenService, contextService, environmentService, keybindingService, instantiationService);
}
protected isQuickNavigate(): boolean {
......@@ -836,7 +834,6 @@ export class QuickOpenRecentAction extends BaseOpenRecentAction {
constructor(
id: string,
label: string,
@IWindowsService windowsService: IWindowsService,
@IWindowService windowService: IWindowService,
@IQuickOpenService quickOpenService: IQuickOpenService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
......@@ -844,7 +841,7 @@ export class QuickOpenRecentAction extends BaseOpenRecentAction {
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService
) {
super(id, label, windowsService, windowService, quickOpenService, contextService, environmentService, keybindingService, instantiationService);
super(id, label, windowService, quickOpenService, contextService, environmentService, keybindingService, instantiationService);
}
protected isQuickNavigate(): boolean {
......
......@@ -39,7 +39,7 @@ import { IUntitledResourceInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService, ServicesAccessor, IConstructorSignature2 } from 'vs/platform/instantiation/common/instantiation';
import { ITextModel } from 'vs/editor/common/model';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { COPY_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, SAVE_ALL_COMMAND_ID, SAVE_ALL_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID } from 'vs/workbench/parts/files/electron-browser/fileCommands';
import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
......@@ -1380,7 +1380,7 @@ export class ShowOpenedFileInNewWindow extends Action {
constructor(
id: string,
label: string,
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@INotificationService private notificationService: INotificationService,
) {
......@@ -1390,7 +1390,7 @@ export class ShowOpenedFileInNewWindow extends Action {
public run(): TPromise<any> {
const fileResource = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true, filter: Schemas.file /* todo@remote */ });
if (fileResource) {
this.windowsService.openWindow([fileResource.fsPath], { forceNewWindow: true, forceOpenWorkspaceAsFile: true });
this.windowService.openWindow([fileResource.fsPath], { forceNewWindow: true, forceOpenWorkspaceAsFile: true });
} else {
this.notificationService.info(nls.localize('openFileToShowInNewWindow', "Open a file first to open in new window"));
}
......
......@@ -12,7 +12,7 @@ import * as labels from 'vs/base/common/labels';
import URI from 'vs/base/common/uri';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { toResource, IEditorCommandsContext } from 'vs/workbench/common/editor';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -77,8 +77,9 @@ export const REMOVE_ROOT_FOLDER_COMMAND_ID = 'removeRootFolder';
export const REMOVE_ROOT_FOLDER_LABEL = nls.localize('removeFolderFromWorkspace', "Remove Folder from Workspace");
export const openWindowCommand = (accessor: ServicesAccessor, paths: string[], forceNewWindow: boolean) => {
const windowsService = accessor.get(IWindowsService);
windowsService.openWindow(paths, { forceNewWindow });
const windowService = accessor.get(IWindowService);
windowService.openWindow(paths, { forceNewWindow });
};
function save(resource: URI, isSaveAs: boolean, editorService: IWorkbenchEditorService, fileService: IFileService, untitledEditorService: IUntitledEditorService,
......
......@@ -14,7 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Position } from 'vs/platform/editor/common/editor';
import { onUnexpectedError, isPromiseCanceledError } from 'vs/base/common/errors';
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { TPromise } from 'vs/base/common/winjs.base';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
......@@ -221,7 +221,6 @@ class WelcomePage {
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IInstantiationService private instantiationService: IInstantiationService,
@IWindowService private windowService: IWindowService,
@IWindowsService private windowsService: IWindowsService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService private environmentService: IEnvironmentService,
......@@ -317,7 +316,7 @@ class WelcomePage {
id: 'openRecentFolder',
from: telemetryFrom
});
this.windowsService.openWindow([wsPath], { forceNewWindow: e.ctrlKey || e.metaKey });
this.windowService.openWindow([wsPath], { forceNewWindow: e.ctrlKey || e.metaKey });
e.preventDefault();
e.stopPropagation();
});
......
......@@ -938,6 +938,10 @@ export class TestWindowService implements IWindowService {
return TPromise.as(void 0);
}
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
return TPromise.as(void 0);
}
closeWindow(): TPromise<void> {
return TPromise.as(void 0);
}
......@@ -1125,7 +1129,7 @@ export class TestWindowsService implements IWindowsService {
}
// Global methods
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
openWindow(windowId: number, paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise<void> {
return TPromise.as(void 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册