From 5d17c04c6c40f8aff3ded3e162b380ccdc144fa5 Mon Sep 17 00:00:00 2001 From: Anyone4551 <260066004+Anyone4551@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:47:58 +0100 Subject: [PATCH] [TextEdit] Fix right margin rounding clipping last character (cherry picked from commit 4c8b5f960f3d276c7e218b0830f2324915f8425e) --- scene/gui/text_edit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 618e62c9d0..465045f653 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -938,7 +938,7 @@ void TextEdit::_notification(int p_what) { int left_margin = Math::ceil(style->get_margin(SIDE_LEFT)); int xmargin_beg = left_margin + gutters_width + gutter_padding; - int xmargin_end = size.width - Math::ceil(style->get_margin(SIDE_RIGHT)); + int xmargin_end = size.width - Math::floor(style->get_margin(SIDE_RIGHT)); if (draw_minimap) { xmargin_end -= minimap_width; } @@ -3606,7 +3606,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { return CURSOR_ARROW; } - int xmargin_end = get_size().width - Math::ceil(style->get_margin(SIDE_RIGHT)); + int xmargin_end = get_size().width - Math::floor(style->get_margin(SIDE_RIGHT)); if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) { return CURSOR_ARROW; } @@ -8890,7 +8890,7 @@ void TextEdit::_adjust_viewport_to_caret_horizontally(int p_caret, bool p_maximi void TextEdit::_update_minimap_hover() { const Point2 mp = get_local_mouse_pos(); - const int xmargin_end = get_size().width - Math::ceil(_get_current_stylebox()->get_margin(SIDE_RIGHT)); + const int xmargin_end = get_size().width - Math::floor(_get_current_stylebox()->get_margin(SIDE_RIGHT)); bool hovering_sidebar = mp.x > xmargin_end - minimap_width && mp.x < xmargin_end; if (!hovering_sidebar) { @@ -8917,7 +8917,7 @@ void TextEdit::_update_minimap_hover() { void TextEdit::_update_minimap_click() { Point2 mp = get_local_mouse_pos(); - int xmargin_end = get_size().width - Math::ceil(_get_current_stylebox()->get_margin(SIDE_RIGHT)); + int xmargin_end = get_size().width - Math::floor(_get_current_stylebox()->get_margin(SIDE_RIGHT)); if (!dragging_minimap && (mp.x < xmargin_end - minimap_width || mp.x > xmargin_end)) { minimap_clicked = false; return;