Skip to content
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

Fix: keep track of window id #313

Merged
merged 2 commits into from
Aug 17, 2024
Merged

Fix: keep track of window id #313

merged 2 commits into from
Aug 17, 2024

Conversation

costowell
Copy link
Contributor

When using toggle() on a terminal spawned using runner(), a new window ID is assigned, but is not tracked, and so an error is thrown for an unknown window ID when attempting to toggle() again.

Found out about this when trying to assign a keybind to toggling a "runner" terminal

map({ "n", "t" }, "<A-r>", function()
  require("nvchad.term").toggle { id = "runner", pos = "float" }
end, { desc = "terminal show runner term" })

Then I used desdic/greyjoy.nvim to spawn a build job into this runner using the following.

nvterm.runner {
  pos = "float",
  cmd = commandstr,
  id = "runner",
  clear_cmd = false
}

With this, I kept getting the aforementioned error.

@siduck
Copy link
Member

siduck commented Aug 2, 2024

will test this today

@costowell
Copy link
Contributor Author

Any progress on this?

@siduck
Copy link
Member

siduck commented Aug 17, 2024

yo, sorry i forgot about this.

When using toggle() on a terminal spawned using runner()

both are different functions, how will you use it together?

@costowell
Copy link
Contributor Author

both are different functions, how will you use it together?

I'm not sure what you mean. Are they not supposed to work together?

@siduck
Copy link
Member

siduck commented Aug 17, 2024

both are different functions, how will you use it together?

I'm not sure what you mean. Are they not supposed to work together?

yes

toggle function does this : opens a terminal and runs command only once, now when u call this func again, it'll hide that terminal i.e toggle

Runner () : this will open a terminal and run a command, calling this again will run that command in that opened terminal, if terminal isnt opened then it will open the terminal

@siduck
Copy link
Member

siduck commented Aug 17, 2024

you can dm me on discord, tg etc or talk in my discord , tg server, would get quick response than here!

@costowell
Copy link
Contributor Author

costowell commented Aug 17, 2024

Sorry, I don't have discord, and I'd rather handle this in one spot.

toggle function does this : opens a terminal and runs command only once, now when u call this func again, it'll hide that terminal i.e toggle

As I understand it, toggle() will create a new terminal, otherwise it will just show/hide one that already exists any number of times.

This PR fixes unexpected behavior when using toggle() on a Runner, by keeping track of window IDs better.

@siduck
Copy link
Member

siduck commented Aug 17, 2024

when using toggle() on a Runner,

i dont get this part, how toggle on runner?

@costowell
Copy link
Contributor Author

I left an example in the description of this PR, but the Runner uses the same code to manage the window which is all that really matters with toggling.

@siduck
Copy link
Member

siduck commented Aug 17, 2024

hmm so you want a runner() term toggleable by toggle function?

@costowell
Copy link
Contributor Author

Exactly.

@siduck
Copy link
Member

siduck commented Aug 17, 2024

Exactly.

oh i get it now 😁

@siduck siduck merged commit 8e21655 into NvChad:v2.5 Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants