瀏覽代碼

Merge pull request #86732 from TheSofox/line-edit-delete-fix

Make `LineEdit` scrolling show as much text as possible
Rémi Verschelde 1 年之前
父節點
當前提交
50a073cb0e
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      scene/gui/line_edit.cpp

+ 6 - 0
scene/gui/line_edit.cpp

@@ -1718,6 +1718,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();