aziz / SublimeFileBrowser

Ditch sidebar and browse your files in a normal tab with keyboard, like a pro!
MIT License
394 stars 46 forks source link

Some issues with closing sidebar windows and file placement...possible command to close all direds in current window #111

Open excetara2 opened 8 years ago

excetara2 commented 8 years ago

1.) If you open a dired in the sidebar and you call the command to close the window when selecting a file then it opens it in that little sidebar window. Then you have a sidebar window with the file open and your main window. Can it open the file in the main window like the normal behavior and then close the sidebar?

2.) Also is there a command you can run to possibly close the sidebar if it is open instead of jumping to it or possibly it could just close all dired windows open in the current window and this would cover it?

3.) This isn't a huge issue but I have had happen to me and I think it is due to sublemacs window killing. If I close a group with sublemacs [ctrl+x], [d] then I have one window that the dired window is still there. Then if I hit the command to bring up the dired sidebar again it puts the main window to my set window width and the side bar is moved to a new group that is the length of the main window so it does the reverse of what it normally does.

Thanks, this package is great!

excetara2 commented 8 years ago

4.) Also if you have groups in any other format than single window the command puts the sidebar always on the next window instead as a sidebar on the side as desired. I assume there is no way around this?

vovkkk commented 8 years ago

4) By window you mean group, right? There probably is way around, but we did it deliberately: other_group argument taken into account in case of single group; and in case of multiple groups it chooses the neighbour of currently active, see #8 and get_group function

I’ll reply to other points later.

excetara2 commented 8 years ago

Yes sorry I meant group. Sometimes I forget what exactly to write because I'm used to coming from emacs so using windows and buffers. Okay thanks for clarification.

vovkkk commented 8 years ago

1) If I understood correctly, just add other_group argument:

{
  "keys": ["enter"],
  "command": "dired_select", "args": {"other_group": true, "and_close": true},
  "context": [
    { "key": "selector", "operator": "equal", "operand": "text.dired" },
    { "key": "setting.dired_rename_mode", "operand": false }
  ]
}

2) If you launch dired command with other_group argument while dired buffer is active it will close it, so just tap a key twice.

3) Cannot reproduce, but I remember something like this (without sublemacs), it is probably race condition since when tabs are being moved to another group the active/focused group can be changed or something; all in all, we need to figure out the certain steps to reproduce.

excetara2 commented 8 years ago

Yeah I've kind of figured out when to use other_group and new_view now for what I want accomplish with and_close being added by pressing ctrl.

What I did notice that I'm not sure is the desired behaivor is pressing enter with other_group and only having a single window open will send it to the side bar. This is rather annoying and I think shouldn't be the default behavior at least my thinking? If you hit super+enter aka 'new_view` in this same situation this doesn't happen and it opens in the single group without creating a new one.

2) Yeah I didn't realize that until I played around more but that works well actually because it will take you to the group as well instantly if you are not in the window. What does single_pane do exactly as I have it set in dired as well but not exactly sure the function?

3) Yeah I've also reproduced it once using the built-in commands but today I am struggling to produce it again.

4) The only other very useful command that I have sometimes wanted is to open a terminal at the current folder.

vovkkk commented 8 years ago

pressing enter with other_group and only having a single window open will send it to the side bar. This is rather annoying and I think shouldn't be the default behavior at least my thinking? If you hit super+enter aka 'new_view` in this same situation this doesn't happen and it opens in the single group without creating a new one.

Opinions. IIRC, it was done this way to demonstrate user available options. If you don’t like defaults, then you simply re-define them in user keybindings file.

What does single_pane do exactly as I have it set in dired as well but not exactly sure the function?

It make sure to re-use the first existing dired buffer (if any) whenever you launch dired command; otherwise, it will look if existing buffer has same path you’re trying to open. I.e. single_pane won’t ever create new filebrowser if one already was open.

open a terminal at the current folder.

Didn’t you had intention to send pull request? I mean it was you, right? Go ahead, prs are welcomed.

excetara2 commented 8 years ago

Yes I had worked on it but had some issues with calling Popen correctly for some reason. I know it is implemented in Sublime Files package so I will have a look there how they implemented it and try to submit a PR if all works fine.

vovkkk commented 8 years ago

Do you mean subprocess.Popen? it is part of Python standard library https://docs.python.org/3/library/subprocess.html#popen-constructor

excetara2 commented 8 years ago

Yes subprocess.Popen. I've used it before so I know how it works but maybe I just don't understand exactly how sublime works. I tried creating this and couldn't figure out why such a minimal example wouldn't work. Any ideas and I'll create a PR obviously updated with relevant code for every OS and a setting for specifying the none default terminal because on OSX it would have to be Terminal not iTerm.

class DiredOpenTerminalCommand(TextCommand, DiredBaseCommand):
    """open dir in external terminal"""
    def run(self, edit):
        path = "/Users/home/"
        term_command = "open -a iTerm"
        command = shlex.split(str(term_command))
        command.append(path)
        try:
            return subprocess.Popen(command)
        except:
            sublime.status_message('Unable to open terminal')
excetara2 commented 8 years ago

This was in the dired_misc.py.

vovkkk commented 8 years ago

I’ve no OSX so I cannot be sure, maybe plugin was not reloaded properly, restart ST will fix it Or maybe you call command in wrong way, test in console:

view.run_command('dired_open_terminal')
excetara2 commented 8 years ago

Okay I'll try over the weekend to figure it out. I mean I can code the script just fine to work outside of sublime text so not sure what is going on.