-
-
Notifications
You must be signed in to change notification settings - Fork 184
[BUG] Terminal id collisions with custom terminals #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@willothy I didn't dig into the code, but maybe one possible solution could be to provide a custom id for custom terminals. |
That could work, but since regular and custom terminals use the same class, differentiating between custom and regular terminals would be difficult. Ideally we'd find something that keeps IDs consistent between custom and standard terminals as well so that you can still toggle custom terminals by id without having to type a bunch of characters. Maybe using some sort of "reserved" id list could work like I initially suggested. I'll try these ideas out and see how it goes. Giving custom terminals string IDs instead of number IDs in config works as well, but kinda defeats the purpose of having an id at all as it can't be accessed by count. |
fixed by #490 |
Is there an existing issue for this?
Current Behavior
When creating multiple custom terminals with
Terminal:new()
, ids are assigned automatically if they're not provided.However, the
next_id
function only checks existing terminals, not ones that have been newly created (not yet spawned).This leads to terminals having identical IDs, and therefore toggleterm losing track of one of them when the other is opened.
Both will remain open, but the previous is removed from the
terminals
dict and therefore is inaccessible to API functions such asget_all
,get
, etc.Expected Behavior
Created terminals should never overwrite each other; Id conflicts should be handled properly.
Steps To Reproduce
Environment
Anything else?
Happy to contribute a PR for this, but I think it needs some discussion first. I know that the way the
next_id
function works is done that way to keep id numbers low, for ease of use. This is good and should be kept, something like a counter that increments for each new terminal is out of the question.So, my idea is using an additional cache set, liketerminals
, but forreserved
terminals that have been initialized but not spawned. This set would be checked anywhereterminals
is, to ensure that id collisions never occur.Another option could be only assigning terminal ids to custom terminals when they're spawned.
See #488, assigning terminal ids on spawn was a very simple change and does not affect terminals created with a specific id.
Would appreciate some input :)
The text was updated successfully, but these errors were encountered: