From 8661667dde73dd1ebc6d270c7a04c15e87e7c530 Mon Sep 17 00:00:00 2001 From: Sofox Date: Wed, 3 Jan 2024 00:28:42 +0000 Subject: [PATCH] Make LineEdit scrolling show as much text as possible --- scene/gui/line_edit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5cca09bcf68..7d40a2252a8 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1713,6 +1713,12 @@ void LineEdit::set_caret_column(int p_column) { } else if (MAX(primary_caret_offset.x, primary_caret_offset.y) >= ofs_max) { scroll_offset += ofs_max - MAX(primary_caret_offset.x, primary_caret_offset.y); } + + // Scroll to show as much text as possible + if (text_width + scroll_offset + x_ofs < ofs_max) { + scroll_offset = ofs_max - x_ofs - text_width; + } + scroll_offset = MIN(0, scroll_offset); queue_redraw();