ejoubaud / SublimeTabsLimiter

A Sublime Text plugin to limit the number of tabs. Once the limit is reached, newer tabs will just replace old ones.
1 stars 1 forks source link

Nice Job #1

Closed StefanoRausch closed 11 years ago

StefanoRausch commented 11 years ago

I really like your plugin, well done!

Food for thoughts: ST 2.0.1 build 2217

Maybe I am missing something along the lines ...

ejoubaud commented 11 years ago

Thanks a lot for your feedback Stefano.

Thanks again.

StefanoRausch commented 11 years ago

1 / 2 : Great and good to hear.

I normally do split the view into 2 groups 80% on the left and 20% on the right - these views however can be resized to the opposite, i.e. 20% L and 80% R depending on where the file is that I want to work on. The smaller view is generally speaking for keeping files "out of sight" but handy in reach. Furthermore, I do constantly have a TAP ( Test Anything Protocol ) document open :wink:

The opening order is ( normally again ) on the left side and if I want to keep it out of sight I just push / put it to the right side. I do use the Goto Anything command for opening, it is so blasting fast.

See the following Key Bindings of mine:

[
    { "keys" : [ "alt+1" ], "command" : "focus_group", "args" : { "group" : 0 } },

    { "keys" : [ "alt+2" ], "command" : "focus_group", "args" : { "group" : 1 } },

    {   // workspace left
        "keys" : [ "ctrl+alt+super+left" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.80, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
            ]
        }
    },

    {   // fetch from the right
        "keys" : [ "ctrl+alt+left" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {   // give visual feedback due to change of focus, if coming from the right
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.80, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" },
                { "command" : "move_to_group", "args" : { "group" : 0 }, "context" : "window" },
                { "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
            ]
        }
    },

    {   // put to the right
        "keys" : [ "ctrl+alt+right" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {   // give visual feedback due to change of focus, if coming from the right
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.80, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" },
                { "command" : "move_to_group", "args" : { "group" : 1 }, "context" : "window" },
                { "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" }
            ]
        }
    },

    {   // workspace right
        "keys" : [ "ctrl+alt+super+right" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.20, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
            ]
        }
    },

    {   // fetch from the left
        "keys" : [ "alt+super+right" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {   // give visual feedback due to change of focus, if coming from the left
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.20, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 0 }, "context" : "window" },
                { "command" : "move_to_group", "args" : { "group" : 1 }, "context" : "window" },
                { "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
            ]
        }
    },

    {   // put to the left
        "keys" : [ "alt+super+left" ],
        "command" : "run_multiple_commands",
        "args" : {
            "commands" : [
                {   // give visual feedback due to change of focus, if coming from the left
                    "command" : "set_layout",
                    "args" : {
                        "cols" : [ 0.0, 0.20, 1.0 ],
                        "rows" : [ 0.0, 1.0 ],
                        "cells" : [ [ 0, 0, 1, 1 ], [ 1, 0, 2, 1 ] ]
                    },
                    "context" : "window"
                },
                { "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" },
                { "command" : "move_to_group", "args" : { "group" : 0 }, "context" : "window" },
                { "command" : "focus_group", "args" : { "group" : 1 }, "context" : "window" }
            ]
        }
    }

]

Now I would like to limit the numbers of tabs on a group level to have more flexibility, if needed. Unfortunately the setting does not apply.

ejoubaud commented 11 years ago

Limiting on the group level seems to work fine (at least in my tests), as long as you have set "limit_tabs_by_group": true. I just updated the plugin to make it the default. Which version of Sublime are you using ?

Regarding the limit to n-1 (n being the tab_limit_number setting value), I only have this problem when I have n tabs already open and I try to either:

I know this is a pain and I'm sorry about that, but it is a Sublime limitation and there is not much I can do.

There is no on_opened_tab event in the API, so I have to rely on the on_load event, that's triggered erratically when you double-click the side-bar, and not called again when you actually open the tab of a file you were already previewing. I spent a lot of time trying some workarounds, unsuccessfully :(

However, what should work fine is this:

To finish on a positive note, I have added access to User/Package settings in the Preference menu.

StefanoRausch commented 11 years ago

Excellent, thanks a lot for the Package Settings, much appreciated.

As stated in the beginning, I am using ST 2.0.1 build 2217.

I just did a simple test and opened 8 new tabs in a fresh new window, with the setting tab_number_limit set to 8 while having my set up as described above groups-wise. I can not open the 8th tab – i.e. TabsLimiter only allows 7 tabs to be open, regardless in which group I am ...

And now the last resort measure : I did restart Sublime Text and now everything is working like a charm with the only exception that the tab_number_limit is always n - 1 tabs.

Again, excellent job so far and the little issue can be resolved with setting tab_number_limit to n + 1 and everything is good :wink: