Skip to content

Commit e0a8269

Browse files
author
Benjamin Pasero
committed
Open file/folder dialog needs to know its target window (fixes microsoft#5796)
1 parent dcbfc1a commit e0a8269

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/vs/code/electron-main/windows.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ interface INativeOpenDialogOptions {
7575
pickFiles?: boolean;
7676
path?: string;
7777
forceNewWindow?: boolean;
78+
window?: VSCodeWindow;
7879
}
7980

8081
const ReopenFoldersSetting = {
@@ -100,8 +101,8 @@ export interface IWindowsMainService {
100101
open(openConfig: IOpenConfiguration): VSCodeWindow[];
101102
openPluginDevelopmentHostWindow(openConfig: IOpenConfiguration): void;
102103
openFileFolderPicker(forceNewWindow?: boolean): void;
103-
openFilePicker(forceNewWindow?: boolean, path?: string): void;
104-
openFolderPicker(forceNewWindow?: boolean): void;
104+
openFilePicker(forceNewWindow?: boolean, path?: string, window?: VSCodeWindow): void;
105+
openFolderPicker(forceNewWindow?: boolean, window?: VSCodeWindow): void;
105106
openAccessibilityOptions(): void;
106107
focusLastActive(cli: ParsedArgs): VSCodeWindow;
107108
getLastActiveWindow(): VSCodeWindow;
@@ -862,12 +863,12 @@ export class WindowsManager implements IWindowsMainService {
862863
this.doPickAndOpen({ pickFolders: true, pickFiles: true, forceNewWindow });
863864
}
864865

865-
public openFilePicker(forceNewWindow?: boolean, path?: string): void {
866-
this.doPickAndOpen({ pickFiles: true, forceNewWindow, path });
866+
public openFilePicker(forceNewWindow?: boolean, path?: string, window?: VSCodeWindow): void {
867+
this.doPickAndOpen({ pickFiles: true, forceNewWindow, path, window });
867868
}
868869

869-
public openFolderPicker(forceNewWindow?: boolean): void {
870-
this.doPickAndOpen({ pickFolders: true, forceNewWindow });
870+
public openFolderPicker(forceNewWindow?: boolean, window?: VSCodeWindow): void {
871+
this.doPickAndOpen({ pickFolders: true, forceNewWindow, window });
871872
}
872873

873874
public openAccessibilityOptions(): void {
@@ -896,7 +897,7 @@ export class WindowsManager implements IWindowsMainService {
896897

897898
private getFileOrFolderPaths(options: INativeOpenDialogOptions, clb: (paths: string[]) => void): void {
898899
const workingDir = options.path || this.storageService.getItem<string>(WindowsManager.workingDirPickerStorageKey);
899-
const focussedWindow = this.getFocusedWindow();
900+
const focussedWindow = options.window || this.getFocusedWindow();
900901

901902
let pickerProperties: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[];
902903
if (options.pickFiles && options.pickFolders) {

src/vs/platform/windows/electron-main/windowsService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ export class WindowsService implements IWindowsService, IDisposable {
4949
}
5050

5151
openFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void> {
52-
this.windowsMainService.openFolderPicker(forceNewWindow);
52+
const vscodeWindow = this.windowsMainService.getWindowById(windowId);
53+
this.windowsMainService.openFolderPicker(forceNewWindow, vscodeWindow);
54+
5355
return TPromise.as(null);
5456
}
5557

0 commit comments

Comments
 (0)