randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.37k stars 83 forks source link

terminus_minimize command should use the "title" as panel_name #331

Open jwortmann opened 2 years ago

jwortmann commented 2 years ago

When I create a terminal via the terminus_open command, it seems to be created as a panel, exactly if "panel_name" is set to a (non-falsey) value. So a terminal created as a tab (regular view), will usually have "panel_name" = None.

When a tab terminal gets minimized via "Terminus: Minimize to Panel", the output panel name will just be "Output: Terminus". I would suggest that it uses the "title" attribute (tab title) instead, so that

  1. it has a useful display name in the output panel menu
  2. plugins can find it via the window.find_output_panel() API

And if I use { "panel_name": "My terminal", "show_in_panel": false } for terminus_open, is it supposed to open in a new tab then? It doesn't seem to work like that with the latest release. I see that there was a related recent commit https://github.com/randy3k/Terminus/commit/0aadf611f25f48dafec47da88893621ee197b28f, but it wasn't published in a new version yet.

So I would suggest that "panel_name" should get preserved (if set) on minimize/maximize, and if it is None, then it should use the "title" as "panel_name" on minimize.

randy3k commented 2 years ago

It is precisely what the recent commit is trying to achieve, ie allow users to define panel name without showing the terminal in panal at the first place.

I have thought about using title as the fallback value for the panel name too. There are a few edge cases that we have to handle before we are able to do it. For example, what if there are multiple terminals with the same title? Should we replace the exiting terminal at all? I think it makes sense to replace terminal with the same panel_name, but not sure about the same title.

jwortmann commented 2 years ago

Thanks for clarification!

Good point about multiple terminals with the same title, I didn't think about that. I agree that replacing a terminal might be useful if the panel_name is set to the same value, but not in case the panel_name is None and only the title matches the other terminal's panel_name. I would probably append an incrementing number to the title in the latter case, i.e. "title (2)", "title (3)", and so on.

From a user perspective, I would even think that having both panel_name and title is redundant and maybe they could be refactored into a single attribute. But I don't know how they are exactly used in the codebase, and probably it would be difficult to do in a backwards compatible way. Anyway, I'm sure you find a good solution, and feel free to close this issue.