wbond / sublime_terminal

Launch terminals from the current file or the root project folder
https://packagecontrol.io/packages/Terminal
MIT License
600 stars 117 forks source link

Defaults to home folder if path can't be found #211

Open mazunki opened 5 years ago

mazunki commented 5 years ago

Using os.path.expanduser("~"), a built-in python function, we can open a terminal in the user's home directory. Tries to do this before returning an error. If it can't find the path, it falls back to the old error. Should work on all platforms.

Related to issue #91 .

twolfson commented 5 years ago

I can see both sides of the argument here:

@wbond What are your thoughts?

wbond commented 5 years ago

So the original intent of this package is to open a terminal where they are editing. The situation where this comes into play is when editing a file that hasn't been saved yet.

However, it could get a little tricky. For instance, if you open a new file from the sidebar and edit it, but haven't saved yet, then invoke Terminal. Most users would probably expect it to open a terminal at the folder where they clicked "New File", however with this change it just opens the home dir. I'll have to poke around and see how the save dialog pulls this off. If the dir is in a setting, it would be trivial for us to tap into that.

The downside of the error is that it isn't necessarily clear to the user that the issue is they haven't saved their file yet. Perhaps the most user-friendly thing is to improve the error message?

The other possibility is to allow the user to configure if they want a specific folder opened when there is no folder in the sidebar. We could mention this setting in the popup?

mazunki commented 5 years ago

As I see it, adding a user-setting to have this option is not a bad idea, regardless of what the default is. Changing the output message to something like "To open a terminal, you must first have an active saved file/folder. Couldn't find a path." is an alternative.

mazunki commented 5 years ago

I added the mentioned setting, allowing the user to set priorities. @twolfson @wbond

twolfson commented 5 years ago

The code looks good. I think my sticking point is if we provide home in the fallback listing, then we'll never get to the message state like @wbond had mentioned before. I'm fine with either scenario but would like a definitive decision from @wbond first

braver commented 1 year ago

@twolfson and @wbond how would you guys feel about moving this repo to https://github.com/SublimeText? More and more general purpose packages are moving there so that the active members of the community can contribute, more merge requests forward, and in general keep important packages like this healthy. @wbond of course already has access to that org, @twolfson could be added too.

This PR is one I'd like to work on and there are various other minor issues that I would like to improve (I heavily rely on this package day to day), but the current state of these PR's aren't encouraging.

braver commented 1 year ago

@mazunki the Terminal package is now managed at https://github.com/SublimeText/Terminal, and the latest release incorporates your suggestion via https://github.com/SublimeText/Terminal/commit/fc7d64d1c7407dd44c7061d4795e60c03855be20