diff --git a/build/builtin/browser-main.js b/build/builtin/browser-main.js index e5956179567..d105181d634 100644 --- a/build/builtin/browser-main.js +++ b/build/builtin/browser-main.js @@ -6,8 +6,7 @@ const fs = require('fs'); const path = require('path'); const os = require('os'); -const { remote } = require('electron'); -const dialog = remote.dialog; +const { ipcRenderer } = require('electron'); const builtInExtensionsPath = path.join(__dirname, '..', '..', 'product.json'); const controlFilePath = path.join(os.homedir(), '.vscode-oss-dev', 'extensions', 'control.json'); @@ -84,17 +83,13 @@ function render(el, state) { } const localInput = renderOption(form, `local-${ext.name}`, 'Local', 'local', !!local); - localInput.onchange = function () { - const result = dialog.showOpenDialog(remote.getCurrentWindow(), { - title: 'Choose Folder', - properties: ['openDirectory'] - }); + localInput.onchange = async function () { + const result = await ipcRenderer.invoke('pickdir'); - if (result && result.length >= 1) { - control[ext.name] = result[0]; + if (result) { + control[ext.name] = result; + setState({ builtin, control }); } - - setState({ builtin, control }); }; if (local) { diff --git a/build/builtin/main.js b/build/builtin/main.js index 7379de7a93d..42865157c36 100644 --- a/build/builtin/main.js +++ b/build/builtin/main.js @@ -3,12 +3,25 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -const { app, BrowserWindow } = require('electron'); +const { app, BrowserWindow, ipcMain, dialog } = require('electron'); const url = require('url'); const path = require('path'); let window = null; +ipcMain.handle('pickdir', async () => { + const result = await dialog.showOpenDialog(window, { + title: 'Choose Folder', + properties: ['openDirectory'] + }); + + if (result.canceled || result.filePaths.length < 1) { + return undefined; + } + + return result.filePaths[0]; +}); + app.once('ready', () => { window = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, webviewTag: true, enableWebSQL: false, nativeWindowOpen: true } }); window.setMenuBarVisibility(false);