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

total_visible_line_count decreases indefinitely when setting TextEdit's text with boundary wrap mode #102279

Closed
tracefree opened this issue Feb 1, 2025 · 2 comments · Fixed by #102296

Comments

@tracefree
Copy link
Contributor

tracefree commented Feb 1, 2025

Tested versions

Reproducible in: 4.4-dev2 and above, starting with commit 2fc5321

System information

Godot v4.4.beta (000dd0bdc) - Arch Linux # 1 SMP PREEMPT_DYNAMIC Sat, 18 Jan 2025 02:26:57 +0000 on Wayland - X11 display driver, Multi-window, 3 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (nvidia; 565.77) - AMD Ryzen 5 2600X Six-Core Processor (12 threads)

Issue description

I keep getting the following error when setting the text of a TextEdit:

E 0:00:02:0264   main.gd:7 @ update(): Condition "total_visible_line_count < 0" is true.
  <C++ Source>   scene/gui/text_edit.cpp:444 @ remove_range()
  <Stack Trace>  main.gd:7 @ update()

Steps to reproduce

  • Create a TextEdit
  • Set wrap mode to boundary
  • Set its text to something where the first line is long enough to lead to wrap over. The text also needs at least a second line, but it doesn't need to wrap to produce the error.
  • Repeatedly set the text property to the same string over and over.
  • Eventually you get the error Condition "total_visible_line_count < 0" is true.

For the MRP below, run the project and repeatedly press the button in the center of the screen. It also prints the current total_visible_line_count, and as you can see it decreases by three with every press of the button, and never increases.

Also, if you swap out the two lines so the first one does not wrap and the second line does, you get the opposite problem: the total_visible_line_count increases with every press of the button.

Minimal reproduction project (MRP)

visible_line_count_mrp.zip

@tracefree
Copy link
Contributor Author

I bisected the issue, it was first introduced in #92865.

@tracefree
Copy link
Contributor Author

My debugging efforts so far showed that there is some double accounting going on. total_visible_line_count is first being subtracted from in TextEdit::Text::remove_range, and then again in TextEdit::Text::invalidate_cache within the same call to TextEdit::set_text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Unassessed
Development

Successfully merging a pull request may close this issue.

2 participants