Sublime Forum

One Tab per pane

#1

Hello, I’ve been trying to make a sublime plugin for days now and I decided to go here before I end up pulling all my hair out.

Anyway, I wanted to make sure that all panes only had 1 tab on them (or just disable tabs entirely).

Basically, after selecting a file, it closes all the other tabs on the pane it opened on.

I tried making one where I open the overlay but I don’t know how to run another command after I’m finished selecting a file from the overlay.

Can anyone help me here?

Thanks!

0 Likes

#2

I am questioning the usefulness of a plugin like this, but whatever. (Something like packagecontrol.io/packages/TabsLimiter, right?)

You have to provide a callback to the overlay (I assume you are talking about a quick panel) in which you can then proceed with the algorithm.

0 Likes

#3

In vim, I never really used the tab feature, so i’m kinda used to that.

So whenever I closed the current file in the pane, it’s the only file in the pane.

Old habits die hard I guess.

Thanks.

0 Likes

#4

I only just saw that you were asking about this on IRC earlier. I only glimpse into it a few times a day tbh.

You can not pass callbacks to window.run_command because commands can only be passed primitive objects, i.e. JSON-serializable objects. Besides, there are no built-in commands that accept them.

What command were you trying to run anyway?

0 Likes

#5

I want to:

  1. Show the goto overlay.
  2. Select a file.
  3. Remove all other tabs in the current view.

But whenever I run

def run(self, edit):
        window = self.view.window()
        window.run_command("show_overlay", {
            "overlay": "goto",
            "show_files": True
        })
        group_index, view_index = window.get_view_index(self.view)
        window.run_command("close_others_by_index", { "group": group_index, "index": view_index})

It’s executed at the same time.

Thanks.

0 Likes

#6

Yes, the overlay is asynchronous.

Assuming you don’t want this behavior always and still allow some groups to have multiple panels (i.e. when you open a new view in a different manner),
your best bet is probably to set some global state and then hook on_load/on_new to close the current file. Or you could use on_deactivated.
The state would have to either be timed (assuming the user completes the action in a reasonable timeframe) or be cancellable by means that allow you to monitor the presence of the goto overlay. An example would be a key binding similar to the one that’s closing it normally.

Hope that was clear.

0 Likes