Sublime Forum

Linux/Win differs from OSX in command to show open file dialog

#1

Am I correct in thinking that on Linux/Windows the ST command to show the open file dialog is prompt_open_file while on OSX a different command, prompt_open, is used to do the same thing?

That’s what the ST Default (OS).sublime-keymap files show.

Thanks.

0 Likes

API Suggestions
#2

I did a bit of testing across MacOS, Windows 7 and my Linux box (all running Sublime 3126) and discovered that this indeed seems to be the case.

On Windows/Linux the prompt_open command does nothing at all, while on OSX it opens a file dialog. On the other hand, all three of them respond to prompt_open_file by opening the file dialog.

I’m not seeing anything overtly different on MacOS using one command versus the other, but I can’t say what might be going on behind the scenes. The command list in the unofficial docs doesn’t seem to mention either version of the command.

3 Likes

#3

Thanks Odat.

To further confirm this I downloaded the Linux 64 deb file for 3080 and 3006 (earliest ST3 version available) and found the same thing in both: Linux/Windows use prompt_open_file, OSX prompt_open.

Strange that prompt_open_file works on OSX, perhaps all it does is call prompt_open, no matter anyway.

I would submit this to the unofficial docs but they still haven’t responded to a helpful issue I raised in October and have open pull requests going back several years.

0 Likes

#4

@mattst How do you actually get the filename that the user selected in the prompt?

0 Likes

#5

prompt_open_file is not part of the ST API, you can not get the path of the file the user selects. It can be run from within a plugin - e.g. window.run_command("prompt_open_file") - but that will just initiate the opening file process, the file chosen by the user will be opened in ST just as if Ctrl+O had been pressed. The ST API does not have a file selector dialog which returns the path of the chosen file. HTH.

0 Likes