Fix dysfunctional Save As dialog on Linux.
The code under scrutiny here sets
path.join(initdir, initfile) which doesn't seem right because it points to a file, not a directory. Even though this may work for the distributed Mac and Windows packages, on Linux with nw.js 0.17.6 it definitely doesn't work. Instead the "Save As" dialog comes up without a path under which to save (rather than showing the directory of the patch or the cwd), and the "Save" button doesn't work until you explicitly select one. I've verified this on both Arch and Ubuntu (14.04 and 16.04), it's 100% reproducible there.
The proposed patch fixes this. It sets
initdir (as you'd expect) and
path.join(initdir, initfile) (which is what https://github.com/nwjs/nw.js/issues/3372 suggests to make it work on Windows; on Linux setting
nwsaveas to just
initfile also works). I've tested this on Arch as well as Ubuntu 14.04 and 16.04 and it works fine there. I've also tested the same change on OSX (using an older installation of the 2nd alpha release on my MacBook) and it appears to work there, too. I can't test on Windows right now, though. Jonathan, maybe you could test it there with the latest nw.js available on Windows and see whether it works for you?