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