-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
[Bug] First hidden terminal is re-opened using {count}ToggleTerm command #322
Comments
@uloco I'm unable to reproduce this behaviour I use a similar setup but using |
I am using |
OK this still happens for me on the latest version too. I have set the lazygit terminal to hidden as you can see above. neovims hidden setting is on by default also. How I reproduce:
|
It does not happen when I run the keymap with toggleterm (without a number) |
@uloco I can now reproduce it, seems specifically to happen when toggle is used to close the float as opposed to closing the window. Not sure what the difference is, but for my own part I close the float window with a I'm going to mark this as low priority and welcome any contributions as there are workarounds and I haven't got much time to look at it at the moment. |
I'm happy to contribute, but I have no clue where to start :D |
@uloco so probably a good place to start is with toggleterm.nvim/lua/toggleterm.lua Lines 52 to 56 in 2a787c4
This part of the function to handle a command to open a terminal should check if a terminal with the number passed in exists and if so it should return it unless the terminal is hidden. This happens here, the terminal should not be returned since it's hidden it should instead return nothing and create a new terminal but isn't for whatever reason. toggleterm.nvim/lua/toggleterm/terminal.lua Lines 508 to 513 in 2a787c4
|
Ok thanks. I'll have a look when i got time! |
After investigating I found this: |
@uloco I suggest looking at the
so can't really suggest anything since I don't know what you mean. All terminal need an ID so there is some way to reference them so they don't get orphaned. |
A new terminal is created because you don't check if the passed id belongs to a hidden terminal. It just creates a new terminal. |
@uloco please have a look at the following block of code you could maybe pass the include hidden argument when get is called and see if that works. toggleterm.nvim/lua/toggleterm/terminal.lua Lines 526 to 540 in 43b75f4
I suggest seeing if always including hidden in get or create is the solution. You'll need to poke around locally and see if that produces the right outcome, this is about as much of an indication as I have short of just sorting it myself which I don't have the time to do. |
I was having a similar error, but it was happening on Changing to toggleterm.nvim/lua/toggleterm/terminal.lua Lines 497 to 504 in 43b75f4
toggleterm.nvim/lua/toggleterm/terminal.lua Lines 468 to 492 in 43b75f4
|
@ulyssesdotcodes I'm not sure I understand completely but hidden terminals should not be opened when using the |
When I open a vertical terminal with
And my lazygit:
Not sure, but I think this is because the hidden terminal is being opened without referencing self.dir / self.size, which is the fix above. |
I think I found the problem. It is in |
I worked around this issue by just giving my hidden terminals a very high id starting from 100 manually. Nobody will open 100 simultanous terminals so I guess it should be ok to do it like this. The question is, would it be ok to do it in your repo to? you could start ids at 1000 for example for hidden terminals. |
another alternative would be: if there is a count specified only open the terminals that have the count set and is exactly the same. do not use ids as count but just as identifiers of whatever terminals are present. |
Setting
This should solve the issue and give more control to the user, but there be a lot of work to implement this; the entire codebase only assumes number |
If the first terminal I open in toggleterm is a hidden one with Terminal:new (floating), then :1ToggleTerm opens the hidden terminal instead a new one. Is there a way to prevent this?
My config:
So basically I open lazygit with the mapping right after I open up vim and then put it in the background with the same command and then run
:1ToggleTerm
and it opens up again.The text was updated successfully, but these errors were encountered: