Skip to content

Conversation

@chet
Copy link
Contributor

@chet chet commented Nov 22, 2025

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 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!

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!
@chet
Copy link
Contributor Author

chet commented Nov 22, 2025

cc @FriederHannenheim @deepakjacob

@gyscos
Copy link
Owner

gyscos commented Nov 27, 2025

Thanks for the work!

@chet
Copy link
Contributor Author

chet commented Nov 27, 2025

@gyscos Any time! Thanks for maintaining it! Happy Thanksgiving!

@gyscos gyscos closed this Nov 27, 2025
@gyscos gyscos reopened this Nov 27, 2025
@gyscos gyscos merged commit 9b19d04 into gyscos:main Nov 27, 2025
1 check passed
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