fix for issue #731: panic when resizing terminal windows #848
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for #731, which I also ran across the other day during my first time playing with
cursive(it's a really nice library btw). Upon resizing my terminal window, I consistently am able to getEditViewto panic with an assertion, with an example being:Digging around, I noticed that during a
refresh(), it would callscreen_size()twice -- once forlayout(), and once fordraw(), which means there is indeed a chance for a screen size mismatch to be observed byEditView.Now, someone did mention they observe this behavior with
Alacritty, and I'm observing this behavior withWezTerm(andTerminalas well, but it's not as "sensitive" as when I'm usingWezTerm). I have a feeling it might have to do with GPU-accelerated terminals and how they handle sendingSIGWINCHsignals during resize updates, but I'm not really an expert on that behavior.Included some tests, which took me longer than the actual fix, just to have a few use-cases for testing. I'm not sure if all of the test cases are even needed, but I'm tossing them in just incase.
Thanks for considering this change!