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

remove_paragraph(0) in RichTextLabel only works once #85096

Closed
TheSofox opened this issue Nov 19, 2023 · 4 comments · Fixed by #90518
Closed

remove_paragraph(0) in RichTextLabel only works once #85096

TheSofox opened this issue Nov 19, 2023 · 4 comments · Fixed by #90518
Assignees
Milestone

Comments

@TheSofox
Copy link
Contributor

TheSofox commented Nov 19, 2023

Godot version

80de898

System information

Window 10 - 4.2.rc

Issue description

Calling "remove_paragraph(0)" on a RichTextLabel should remove the first line of text in the label. However, it doesn't seem to work more than once in a row. Even calling "remove_paragraph(1)" actually works better since it always removes the 2nd line even when called repeatedly.

Steps to reproduce

  1. Fill a RichTextLabel with several lines of text
  2. Call "remove_paragraph(0)" on it multiple times.

Expected:
Each time you call "remove_paragraph(0)", the first line should be deleted.

Actual:
The first line is deleted the first time you call "remove_paragraph(0)", but each subsequent time you do it, nothing happens.

Example project attached makes it easy to test. RichTextLabel has been set up already, along with buttons to call "remove_paragraph" when pressed.

Minimal reproduction project

RichTextRemoveParagraph.zip

@jsjtxietian
Copy link
Contributor

Confirmed. Related to

if (p_paragraph == 0 && current->subitems.size() > 0) {
main->lines[0].from = main;
}

Comment them and it works as expected. cc @bruvzg

@bruvzg bruvzg self-assigned this Nov 20, 2023
@nickyfoo
Copy link
Contributor

Not sure if this is possibly related, but I have a PR relating to crashes from RichTextLabel as well

@miv391
Copy link
Contributor

miv391 commented Nov 20, 2023

If the RichTextLabel's text property supposed to always return the current content? Now removing paragraphs (any paragraphs, with or without jsjtxietian's fix) doesn't change what text returns. The original content is always returned.

@bruvzg
Copy link
Member

bruvzg commented Nov 20, 2023

If the RichTextLabel's text property supposed to always return the current content? Now removing paragraphs (any paragraphs, with or without jsjtxietian's fix) doesn't change what text returns. The original content is always returned.

get_parsed_text() should return current text, get_text is source text in won't change and not intended to be used with remove_paragraph.

RTL have two ways to set its content:

  • bbcode (text property).
  • add_*, push_*, pop, remove_paragraph methods.

Mixing both is not supported (setting text will override everything else, and none of the other methods should affect text).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment