From a91e91dddfd2db19f6cd5e911c6b83c90b9372d9 Mon Sep 17 00:00:00 2001 From: Lilith Date: Tue, 18 Jun 2024 15:55:28 -0600 Subject: [PATCH] Put TextBox cursor back in bounds if the text changes (#168) (#169) --- crates/yakui-widgets/src/widgets/textbox.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/yakui-widgets/src/widgets/textbox.rs b/crates/yakui-widgets/src/widgets/textbox.rs index 5c2ab9b2..877eee8b 100644 --- a/crates/yakui-widgets/src/widgets/textbox.rs +++ b/crates/yakui-widgets/src/widgets/textbox.rs @@ -93,6 +93,9 @@ impl Widget for TextBoxWidget { text = &self.props.placeholder; } + // Make sure the cursor is within bounds if the text has changed + self.cursor = self.cursor.min(text.len()); + let mut render = RenderTextBox::new(text.clone()); render.style = self.props.style.clone(); render.selected = self.selected;