Setting default_dir doesn't take effect immediately

Kai Grossjohann 6 years ago • updated 6 years ago 1
When I create a new view and set default_dir in it, then this takes effect only on the second Command+O.

To reproduce, put the following in Packages/User/foo.py and bind the "foo" command to a key.  (Running the command from the console doesn't exhibit the bug.)

import sublime, sublime_pluginclass

    def run(self):
        v = self.window.new_file()
        v.settings().set('default_dir', '/tmp')
I used the following key binding:

{ "keys": ["super+shift+x"], "command": "foo" }

This happens with build 2155.

I'd like to clarify what I mean by "takes effect only on the second Command+O".  I am looking at the foo.py file with the command.  I hit the keybinding (Super+Shift+X) for the command.  I am now looking at the new view.  I hit Command+O.  The file chooser shows me the Packages/User directory where foo.py is.  Without entering anything, I hit Escape, the file chooser disappears.  I hit Command+O again.  The file chooser appears again.  But this time, it shows me the /tmp directory!

If, instead of hitting the keybinding, I enter the console and run the command there, then the first file chooser shows the correct directory.

I hope it's easy to reproduce with these instructions.