File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5875,13 +5875,21 @@ int RichTextLabel::get_character_line(int p_char) {
58755875 int char_offset = main->lines [i].char_offset ;
58765876 int char_count = main->lines [i].char_count ;
58775877 if (char_offset <= p_char && p_char < char_offset + char_count) {
5878- for (int j = 0 ; j < main->lines [i].text_buf ->get_line_count (); j++) {
5878+ int lc = main->lines [i].text_buf ->get_line_count ();
5879+ for (int j = 0 ; j < lc; j++) {
58795880 Vector2i range = main->lines [i].text_buf ->get_line_range (j);
5880- if (char_offset + range.x <= p_char && p_char <= char_offset + range.y ) {
5881- return line_count;
5881+ if (char_offset + range.x <= p_char && p_char < char_offset + range.y ) {
5882+ break ;
5883+ }
5884+ if (char_offset + range.x > p_char && line_count > 0 ) {
5885+ line_count--; // Character is not rendered and is between the lines (e.g., edge space).
5886+ break ;
5887+ }
5888+ if (j != lc - 1 ) {
5889+ line_count++;
58825890 }
5883- line_count++;
58845891 }
5892+ return line_count;
58855893 } else {
58865894 line_count += main->lines [i].text_buf ->get_line_count ();
58875895 }
You can’t perform that action at this time.
0 commit comments