[RTL] Fix character line index for non-visual characters and characters on the line edge.
This commit is contained in:
parent
6da4ad1662
commit
2273509721
1 changed files with 12 additions and 4 deletions
|
@ -5875,13 +5875,21 @@ int RichTextLabel::get_character_line(int p_char) {
|
|||
int char_offset = main->lines[i].char_offset;
|
||||
int char_count = main->lines[i].char_count;
|
||||
if (char_offset <= p_char && p_char < char_offset + char_count) {
|
||||
for (int j = 0; j < main->lines[i].text_buf->get_line_count(); j++) {
|
||||
int lc = main->lines[i].text_buf->get_line_count();
|
||||
for (int j = 0; j < lc; j++) {
|
||||
Vector2i range = main->lines[i].text_buf->get_line_range(j);
|
||||
if (char_offset + range.x <= p_char && p_char <= char_offset + range.y) {
|
||||
return line_count;
|
||||
if (char_offset + range.x <= p_char && p_char < char_offset + range.y) {
|
||||
break;
|
||||
}
|
||||
if (char_offset + range.x > p_char && line_count > 0) {
|
||||
line_count--; // Character is not rendered and is between the lines (e.g., edge space).
|
||||
break;
|
||||
}
|
||||
if (j != lc - 1) {
|
||||
line_count++;
|
||||
}
|
||||
line_count++;
|
||||
}
|
||||
return line_count;
|
||||
} else {
|
||||
line_count += main->lines[i].text_buf->get_line_count();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue