mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
support forceReuseWindow in openWindow API
This commit is contained in:
@@ -25,6 +25,7 @@ export interface IWindowsService {
|
||||
openDevTools(windowId: number): TPromise<void>;
|
||||
toggleDevTools(windowId: number): TPromise<void>;
|
||||
// TODO@joao: rename, shouldn't this be closeWindow?
|
||||
// @ben: no, this actually leaves the window open but changes it to have no workspace opened
|
||||
closeFolder(windowId: number): TPromise<void>;
|
||||
toggleFullScreen(windowId: number): TPromise<void>;
|
||||
setRepresentedFilename(windowId: number, fileName: string): TPromise<void>;
|
||||
@@ -40,8 +41,7 @@ export interface IWindowsService {
|
||||
quit(): TPromise<void>;
|
||||
|
||||
// Global methods
|
||||
// TODO@joao: rename, shouldn't this be openWindow?
|
||||
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void>;
|
||||
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; }[]>;
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface IWindowsChannel extends IChannel {
|
||||
call(command: 'setDocumentEdited', arg: [number, boolean]): TPromise<void>;
|
||||
call(command: 'toggleMenuBar', arg: number): TPromise<void>;
|
||||
call(command: 'quit'): TPromise<void>;
|
||||
call(command: 'windowOpen', arg: [string[], boolean]): TPromise<void>;
|
||||
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; }[]>;
|
||||
@@ -76,7 +76,7 @@ export class WindowsChannel implements IWindowsChannel {
|
||||
case 'unmaximizeWindow': return this.service.unmaximizeWindow(arg);
|
||||
case 'setDocumentEdited': return this.service.setDocumentEdited(arg[0], arg[1]);
|
||||
case 'toggleMenuBar': return this.service.toggleMenuBar(arg);
|
||||
case 'windowOpen': return this.service.windowOpen(arg[0], arg[1]);
|
||||
case 'openWindow': return this.service.openWindow(arg[0], arg[1]);
|
||||
case 'openNewWindow': return this.service.openNewWindow();
|
||||
case 'showWindow': return this.service.showWindow(arg);
|
||||
case 'getWindows': return this.service.getWindows();
|
||||
@@ -179,8 +179,8 @@ export class WindowsChannelClient implements IWindowsService {
|
||||
return this.channel.call('quit');
|
||||
}
|
||||
|
||||
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void> {
|
||||
return this.channel.call('windowOpen', [paths, forceNewWindow]);
|
||||
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void> {
|
||||
return this.channel.call('openWindow', [paths, options]);
|
||||
}
|
||||
|
||||
openNewWindow(): TPromise<void> {
|
||||
|
||||
@@ -198,12 +198,12 @@ export class WindowsService implements IWindowsService, IDisposable {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void> {
|
||||
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void> {
|
||||
if (!paths || !paths.length) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
this.windowsMainService.open({ context: OpenContext.OTHER, cli: this.environmentService.args, pathsToOpen: paths, forceNewWindow });
|
||||
this.windowsMainService.open({ context: OpenContext.OTHER, cli: this.environmentService.args, pathsToOpen: paths, forceNewWindow: options && options.forceNewWindow, forceReuseWindow: options && options.forceReuseWindow });
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -588,8 +588,8 @@ export class OpenRecentAction extends Action {
|
||||
}
|
||||
|
||||
const runPick = (path: string, context: IEntryRunContext) => {
|
||||
const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
|
||||
this.windowsService.windowOpen([path], newWindow);
|
||||
const forceNewWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
|
||||
this.windowsService.openWindow([path], { forceNewWindow });
|
||||
};
|
||||
|
||||
const folderPicks: IFilePickOpenEntry[] = recentFolders.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('folders', "folders") } : void 0, true));
|
||||
|
||||
@@ -137,7 +137,7 @@ export class ElectronWindow {
|
||||
DOM.EventHelper.stop(e, true);
|
||||
|
||||
this.focus(); // make sure this window has focus so that the open call reaches the right window!
|
||||
this.windowsService.windowOpen(draggedExternalResources.map(r => r.fsPath));
|
||||
this.windowsService.openWindow(draggedExternalResources.map(r => r.fsPath), { forceReuseWindow: true });
|
||||
|
||||
cleanUp();
|
||||
})
|
||||
|
||||
@@ -154,7 +154,7 @@ export class ShowOpenedFileInNewWindow extends Action {
|
||||
public run(): TPromise<any> {
|
||||
const fileResource = toResource(this.editorService.getActiveEditorInput(), { supportSideBySide: true, filter: 'file' });
|
||||
if (fileResource) {
|
||||
this.windowsService.windowOpen([fileResource.fsPath], true);
|
||||
this.windowsService.openWindow([fileResource.fsPath], { forceNewWindow: true });
|
||||
} else {
|
||||
this.messageService.show(severity.Info, nls.localize('openFileToShow', "Open a file first to open in new window"));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ CommandsRegistry.registerCommand('_files.openFolderPicker', (accessor: ServicesA
|
||||
|
||||
CommandsRegistry.registerCommand('_files.windowOpen', (accessor: ServicesAccessor, paths: string[], forceNewWindow: boolean) => {
|
||||
const windowsService = accessor.get(IWindowsService);
|
||||
windowsService.windowOpen(paths, forceNewWindow);
|
||||
windowsService.openWindow(paths, { forceNewWindow });
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand('workbench.action.files.openFileInNewWindow', (accessor: ServicesAccessor) => {
|
||||
|
||||
@@ -70,7 +70,7 @@ export class CloneAction extends Action {
|
||||
|
||||
return clone.then(path => {
|
||||
const forceNewWindow = this.workspaceService.hasWorkspace();
|
||||
return this.windowsService.windowOpen([path], forceNewWindow);
|
||||
return this.windowsService.openWindow([path], { forceNewWindow, forceReuseWindow: !forceNewWindow });
|
||||
|
||||
}).then<void>(null, e => {
|
||||
if (/already exists and is not an empty directory/.test(e.stderr || '')) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class OpenSnippetsAction extends actions.Action {
|
||||
}
|
||||
|
||||
private openFile(filePath: string): winjs.TPromise<void> {
|
||||
return this.windowsService.windowOpen([filePath]);
|
||||
return this.windowsService.openWindow([filePath], { forceReuseWindow: true });
|
||||
}
|
||||
|
||||
public run(): winjs.Promise {
|
||||
|
||||
@@ -887,8 +887,7 @@ export class TestWindowsService implements IWindowsService {
|
||||
}
|
||||
|
||||
// Global methods
|
||||
// TODO@joao: rename, shouldn't this be openWindow?
|
||||
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void> {
|
||||
openWindow(paths: string[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean }): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
openNewWindow(): TPromise<void> {
|
||||
|
||||
Reference in New Issue
Block a user