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

get_visible_line_count() in RichTextLabel is wrong if text contains newlines #59359

Closed
KoBeWi opened this issue Mar 20, 2022 · 2 comments
Closed
Milestone

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Mar 20, 2022

Godot version

3.5 beta2

System information

Windows 10 x64

Issue description

When text contains newlines, get_visible_line_count() is off by the number of newlines. I use this code to automatically scroll the RTL:

func _process(delta: float) -> void:
	if visible_characters < text.length():
		visible_characters += 1
	
	if get_visible_line_count() > 6:
		get_v_scroll().value += 3

To the left is text with single, autowrapped line. To the right is text with one newline. The visible line count starts from 0 and is 1 too low.
godot_IFcfZc4Tvu

Does not happen on master.

Steps to reproduce

  1. Add RichTextLabel
  2. Write some text that wraps
  3. Animate visible_characters
  4. Check the results of get_visible_line_count()
  5. Do the same with text with line breaks

Minimal reproduction project

ReproductionProject.zip

@pfertyk
Copy link
Contributor

pfertyk commented Mar 31, 2022

Hi! I'd like to submit a solution.

I've removed the code that, if a newline was encountered, would treat the whole line as empty. Possibly there are other dependencies for that calculation that I'm not currently aware of, in which case I'll update my PR.

@akien-mga akien-mga modified the milestones: 3.5, 3.6 Dec 12, 2022
@akien-mga
Copy link
Member

Fixed by #59765.

akien-mga pushed a commit to akien-mga/godot that referenced this issue Dec 12, 2022
Deozaan pushed a commit to Deozaan/godot that referenced this issue Jan 6, 2023
Riordan-DC pushed a commit to Riordan-DC/godot that referenced this issue Jan 23, 2023
Riordan-DC pushed a commit to Riordan-DC/godot that referenced this issue Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants