Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native OS save as dialog #2

Open
keith-hall opened this issue Apr 27, 2017 · 4 comments
Open

Use native OS save as dialog #2

keith-hall opened this issue Apr 27, 2017 · 4 comments

Comments

@keith-hall
Copy link

Wouldn't it be better to use the OS' native "save as" dialog, instead of an input panel?
I realize that there is no API to ask the user to choose a file, but wouldn't the following suffice?

import sublime
import sublime_plugin


class SaveCopyAsCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        previous_path = self.view.file_name()
        self.view.run_command('prompt_save_as')
        self.view.retarget(previous_path or '')

    def is_enabled(self):
        return self.view.file_name() is not None

i.e. let ST show it's normal Save As prompt, then set the view back to tracking the original file path

@NickHatBoecker
Copy link
Owner

Thanks for your input. I like the current way without a dialog, but would like to implement some options, so the user can choose if a dialog should show up or not. Will see what I can do

@Cerberus-tm
Copy link

Cerberus-tm commented Oct 4, 2017

Thanks, Skyliner, for coming up with this plug-in!

@keith-hall I'd love to have it work as you describe! It has happened to me several times that I inadvertently continued to work in the copy rather than the main file, wondering why my changes never showed... and the disadvantage of the present plug-in is that I often don't know the exact path of the desired directory by heart, not to mention the effort it takes to type a whole new path without making any typos.

Do you have any idea of how I could use your code? I'm a total and utter noob. Should I try to create a new plug-in in Sublime Text (which I've never done) and copy-paste your code into it? I'm a bit scared of messing things up.

@keith-hall
Copy link
Author

@Cerberus-tm the code I posted here is designed as a drop-in replacement for https://github.com/theskyliner/SaveCopyAs/blob/e11e70c2928aef3b3571af7a0625a778b337292e/SaveCopyAs.py. So you can install https://packagecontrol.io/packages/PackageResourceViewer and:

  1. Open the Command Palette
  2. Type PRV: O
  3. Select PackageResourceViewer: Open Resource
  4. Select Save Copy As
  5. Select SaveCopyAs.py
  6. Select all code in that file and replace with the code from my comment above
  7. Save it

@Cerberus-tm
Copy link

Cerberus-tm commented Oct 4, 2017

@keith-hall Great! This does exactly what I wanted, thank you! As a bonus, I have now learned about Package Resource Viewer.

P.S. Perhaps you should upload your version to Package Control as a new/separate plug-in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants