From ed16df1807ec6b0ba4d0ade99a101ebedcf244dd Mon Sep 17 00:00:00 2001 From: Bronson Holden Date: Fri, 13 Oct 2023 10:49:58 -0700 Subject: [PATCH 1/2] Remove vertical scrollbar padding from line width calc Visibility of the vertical scrollbar is already accounted for in `_update_wrap_at_column` which in turn affects max line width of the text area. --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 073f164bdd2..93905b8b395 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -7340,7 +7340,7 @@ void TextEdit::_update_scrollbars() { } int visible_width = size.width - theme_cache.style_normal->get_minimum_size().width; - int total_width = (draw_placeholder ? placeholder_max_width : text.get_max_width()) + vmin.x + gutters_width + gutter_padding; + int total_width = (draw_placeholder ? placeholder_max_width : text.get_max_width()) + gutters_width + gutter_padding; if (draw_minimap) { total_width += minimap_width; From b15dd3e14547aedefd4445e97a8dd1db56b9c1b0 Mon Sep 17 00:00:00 2001 From: Bronson Holden Date: Fri, 13 Oct 2023 12:22:50 -0700 Subject: [PATCH 2/2] Add test justifying change to expected horizontal scroll position --- tests/scene/test_text_edit.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index 840a04becf0..9c9ade44451 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -3913,7 +3913,8 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_h_scroll() == 0); text_edit->set_h_scroll(10000000); - CHECK(text_edit->get_h_scroll() == 314); + CHECK(text_edit->get_h_scroll() == 306); + CHECK(text_edit->get_h_scroll_bar()->get_combined_minimum_size().x == 8); text_edit->set_h_scroll(-100); CHECK(text_edit->get_h_scroll() == 0);