fix for issue #731: panic when resizing terminal windows#848
Merged
gyscos merged 1 commit intogyscos:mainfrom Nov 27, 2025
Merged
fix for issue #731: panic when resizing terminal windows#848gyscos merged 1 commit intogyscos:mainfrom
gyscos merged 1 commit intogyscos:mainfrom
Conversation
This is a fix for gyscos#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 get `EditView` to panic with an assertion, with an example being: ``` Application panicked! Panic message: assertion `left == right` failed: Was promised 162, received 159 ``` Digging around, I noticed that during a `refresh()`, it would call `screen_size()` twice -- once for `layout()`, and once for `draw()`, which means there is indeed a chance for a screen size mismatch to be observed by `EditView`. Now, someone did mention they observe this behavior with `Alacritty`, and I'm observing this behavior with `WezTerm` (and `Terminal` as well, but it's not as "sensitive" as when I'm using `WezTerm`). I have a feeling it might have to do with GPU-accelerated terminals and how they handle sending `SIGWINCH` signals 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!
Contributor
Author
Owner
|
Thanks for the work! |
Contributor
Author
|
@gyscos Any time! Thanks for maintaining it! Happy Thanksgiving! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!