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 TextEdit HScroll hiding after wrapping #92271

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

kitbdev
Copy link
Contributor

@kitbdev kitbdev commented May 23, 2024

Since it only happens in certain scenarios here is more information and reproduction steps:

godot te hscroll missing

Reproduction:

  1. Make a new default script.
  2. Change the TextEdit width such that the word previous will be wrapped but not the word time. from the comments on lines 9 and 4.
  3. Toggle word wrap on and off (alt+z).
  4. The hscrollbar doesn't reappear like it should.

When disabling word wrap, the longest line while wrapped (line 4) doesn't change size so TextEdit::Text::_calculate_line_height() exits early, even though there is a new longest line.

This happens because TextEdit::Text::_calculate_max_line_width() was assuming it was being called from TextEdit::Text::invalidate_cache() only and that lines had only shrunk, but this is not true since it can be called from TextEdit::Text::invalidate_all_lines() and other places.
This also applies to TextEdit::Text::_calculate_line_height() since it is the same situation.

@kitbdev kitbdev requested a review from a team as a code owner May 23, 2024 00:25
@KoBeWi KoBeWi added this to the 4.3 milestone May 23, 2024
@KoBeWi KoBeWi requested a review from Paulb23 May 23, 2024 18:00
@Paulb23
Copy link
Member

Paulb23 commented May 27, 2024

Rather then removing this optimisation for invalidate_cache would it be better to set the force-ably set the width/height to -1 under these specific scenarios?

@kitbdev kitbdev force-pushed the fix-max-line-size branch from 3cba560 to 66a8ee7 Compare May 27, 2024 19:00
@kitbdev
Copy link
Contributor Author

kitbdev commented May 27, 2024

I'll set it to -1 where it's called instead of removing the optimizations.
Not sure if its needed for line width since there is probably a low chance of another line being the same width, but it is good for line height.

@akien-mga akien-mga merged commit 1ee9530 into godotengine:master Jun 7, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@kitbdev kitbdev deleted the fix-max-line-size branch June 7, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Horizontal scroll disappears after toggling autowrap
4 participants