diff --git a/crates/horizon-client/src/clipboard.rs b/crates/horizon-client/src/clipboard.rs index 2f3d7b002..c21460cdb 100644 --- a/crates/horizon-client/src/clipboard.rs +++ b/crates/horizon-client/src/clipboard.rs @@ -223,6 +223,10 @@ impl AppendSelection { pub fn covers(&self, id: FieldId, value: &str) -> bool { self.0.as_ref().is_some_and(|(i, v)| *i == id && v == value) } + /// Select the whole `value` of field `id`, as Select All does. + pub fn select(&mut self, id: FieldId, value: &str) { + self.0 = Some((id, value.to_owned())); + } /// Before typing or a backspace: an all-selected value is cleared (true). pub fn take(&mut self, id: FieldId, value: &mut String) -> bool { let covered = self.covers(id, value); @@ -247,7 +251,7 @@ impl AppendSelection { let covered = self.covers(id, value); match shortcut { EditShortcut::SelectAll => { - self.0 = Some((id, value.clone())); + self.select(id, value); false } EditShortcut::Copy => { diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 256360d8f..5113ebdab 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4375,6 +4375,12 @@ impl Game<'_> { input: horizon_client::menu::Input, ) { use horizon_client::creative::{DisplayClick, click_display}; + if self.creative_screen.tab().search { + // CreativeModeInventoryScreen.slotClicked: moveCursorToEnd, then + // setHighlightPos(0), so typing replaces the whole query. + let search = &self.creative_screen.search; + self.text_selection.select(("creative.search", 0), search); + } let items = self.creative_screen.items(&self.res.names); let first = self.creative_screen.first_row(&self.res.names); let shown = items.get(first * 9 + slot - Creative::DISPLAY); diff --git a/crates/horizon-client/src/game/control.rs b/crates/horizon-client/src/game/control.rs index f604ca7d8..51e5379f1 100644 --- a/crates/horizon-client/src/game/control.rs +++ b/crates/horizon-client/src/game/control.rs @@ -425,8 +425,8 @@ impl Game<'_> { self.recipe_text(Some(text), false) } Screen::Creative if self.creative_screen.tab().search => { - self.creative_screen.search.push_str(text); - self.creative_screen.scroll = 0.0; + // As typed: replaces a selected query, keeps the length limit. + self.creative_search_edit(Some(text), false) } _ => { return Err(