简体   繁体   中英

Is it possible to get a combined open folder/open file dialog in VSCode when using the simple file dialog?

Using the simple file dialog on MacOS allows me to use + O to open either a file or a folder .

But on Linux (or Windows), I have to use CTRL + KCTRL + O if I want to open a folder, or just CTRL + O to open a single file. This is frustrating, and I always forget it when I jump from my MacOS work-machine to my personal Linux machine.

On Linux, it looks like this for files: 在 Linux 上打开文件对话框

Since this is a VSCode in-application dialog ( not an operating system dialog ), there shouldn't be any operating system limitations to it.

Is there any option to enable the MacOS-style combined behavior for it?

VSCode is implemented on Electron and Electron doesn't support such dialogs on windows and linux.

Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.

 dialog.showOpenDialogSync(mainWindow, { properties: ['openFile', 'openDirectory']})

https://www.electronjs.org/docs/latest/api/dialog#methods

but you can drag and drop a file or folder from the file explorer into the VSCode and it works similar to it.

OK, so it was much simpler than I thought.

There is a keybinding for this, it is simply called "File: Open" under "Keyboard shortcuts", and its full name is workbench.action.files.openFileFolder .

It currently has the when-constraint isMacNative && openFolderWorkspaceSupport , but you can simply remove this by right-clicking the binding, and selecting "Edit When Expression".

Then simply bind it to CTRL + O or whatever you desire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM