@@ -2303,6 +2303,11 @@ RID RichTextLabel::get_focused_accessibility_element() const {
23032303 return get_accessibility_element ();
23042304}
23052305
2306+ void RichTextLabel::_prepare_scroll_anchor () {
2307+ scroll_w = vscroll->get_combined_minimum_size ().width ;
2308+ vscroll->set_anchor_and_offset (SIDE_LEFT, ANCHOR_END, -scroll_w);
2309+ }
2310+
23062311void RichTextLabel::_notification (int p_what) {
23072312 switch (p_what) {
23082313 case NOTIFICATION_ACCESSIBILITY_INVALIDATE: {
@@ -2417,6 +2422,10 @@ void RichTextLabel::_notification(int p_what) {
24172422 queue_redraw ();
24182423 } break ;
24192424
2425+ case NOTIFICATION_READY: {
2426+ _prepare_scroll_anchor ();
2427+ } break ;
2428+
24202429 case NOTIFICATION_THEME_CHANGED: {
24212430 _stop_thread ();
24222431 main->first_invalid_font_line .store (0 ); // Invalidate all lines.
@@ -2588,6 +2597,7 @@ void RichTextLabel::_notification(int p_what) {
25882597 from_line++;
25892598 }
25902599 if (scroll_follow_visible_characters && scroll_active) {
2600+ scroll_visible = follow_vc_pos > 0 ;
25912601 vscroll->set_visible (follow_vc_pos > 0 );
25922602 }
25932603 if (has_focus () && get_tree ()->is_accessibility_enabled ()) {
@@ -3726,9 +3736,8 @@ _FORCE_INLINE_ float RichTextLabel::_update_scroll_exceeds(float p_total_height,
37263736 if (exceeds != scroll_visible) {
37273737 if (exceeds) {
37283738 scroll_visible = true ;
3729- scroll_w = vscroll-> get_combined_minimum_size (). width ;
3739+ _prepare_scroll_anchor () ;
37303740 vscroll->show ();
3731- vscroll->set_anchor_and_offset (SIDE_LEFT, ANCHOR_END, -scroll_w);
37323741 } else {
37333742 scroll_visible = false ;
37343743 scroll_w = 0 ;
0 commit comments