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

cargo watch -x run after some saves turns the terminal into a mess. #269

Open
h4rldev opened this issue May 9, 2023 · 8 comments
Open

Comments

@h4rldev
Copy link

h4rldev commented May 9, 2023

Issue

It sometimes essentially locks the entire terminal and throws the text everywhere on save.
Might it be a conflict with the "menu" or something?

Screenshot

image

@passcod
Copy link
Member

passcod commented May 9, 2023

yeah, that's your program not resetting the screen gracefully on restart. try doing

cargo watch -s 'reset; cargo run'

@h4rldev
Copy link
Author

h4rldev commented May 9, 2023

Any way for me to implement that in my code?

@passcod
Copy link
Member

passcod commented May 9, 2023

sure, hook to sigint/ctrlc and cleanup state, or as a last resort, forcibly reset the screen. you can use the clearscreen crate for this, or your terminal manipulation library may have a facility

@h4rldev
Copy link
Author

h4rldev commented May 10, 2023

After looking up on this I seem to not find a way to catch the termination signal of cargo-watch and reset the screen

@h4rldev
Copy link
Author

h4rldev commented May 10, 2023

And my program seems to start thinking I pressed enter twice

@passcod
Copy link
Member

passcod commented May 10, 2023

You're right, I keep getting confused between the current states of cargo watch and watchexec. There's no easy way to catch that signal at the moment. If you use watchexec directly instead (a bit less nice for cargo projects), you'll get a SIGTERM by default, and can customise that too, and you can use --clear=reset as a simpler pattern than using tput reset.

@h4rldev
Copy link
Author

h4rldev commented May 18, 2023

Any plans to implement that for cargo-watch?

@passcod
Copy link
Member

passcod commented May 19, 2023

definitely. currently waiting for/working on:

  • ignores to stabilise (ie for any more bugs to come out after the latest watchexec release)
  • a fix for the startup behaviour (next priority)
  • filter programs (pending a third party crate release)
  • proper multi-command support (currently in review)

once the first two are done in watchexec, i'll consider it stable enough to start porting cargo watch, at which point i'll aim for cli flags feature parity.

tl;dr: not immediately but it's in sight

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

No branches or pull requests

2 participants