From 9266dfed4679bcfccc2048f09e037580b46975cd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 18 Nov 2026 09:35:13 -0500 Subject: [PATCH] red round 4 (fw-apps, Opus): fixes for fw-run-5 (runs/fw-run-5/fw-apps.md); committed by the lead Co-Authored-By: Claude Opus 5.5 --- crates/text/src/ui/find/bar.rs | 2 +- crates/ui-contract/src/contract/text.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/text/src/ui/find/bar.rs b/crates/text/src/ui/find/bar.rs index 6e965df9a..eee8c043c 100644 --- a/crates/text/src/ui/find/bar.rs +++ b/crates/text/src/ui/find/bar.rs @@ -239,7 +239,7 @@ impl<'a> FindBar<'a> { let edit = TextField::new(words.replace_with.clone(), Bind::given(with.clone())).submits().select_all(to_with).show(ui); if to_with { focus::request(ui.ctx(), FocusTarget::Id(edit.response.id)); - if edit.response.has_focus() + if focus::is_focused(ui.ctx(), edit.response.id) && let Some(state) = state.as_deref_mut() { state.served(); diff --git a/crates/ui-contract/src/contract/text.rs b/crates/ui-contract/src/contract/text.rs index ce04a2c07..10a360d9f 100644 --- a/crates/ui-contract/src/contract/text.rs +++ b/crates/ui-contract/src/contract/text.rs @@ -422,7 +422,8 @@ pub(crate) fn run( let ink = if enabled { ink } else { crate::style::rgba_color(crate::runtime::env::Env::of(ui).tokens.color.text.disabled) }; let held = cx.popup(EDIT_MENU).is_open_in(&mut cx.core); serve_access(cx, &mut state, widget, &decl.shown, read_only); - if std::mem::take(&mut state.select_all) { + let select_all = std::mem::take(&mut state.select_all); + if select_all { let len = state.draft.as_deref().unwrap_or(&decl.shown).chars().count(); adapter::select(&ctx, widget, 0, len); } @@ -465,12 +466,14 @@ pub(crate) fn run( let commit_now = (step.commit_now || (was_focused && left_for_part)) && !window_blur; // Focus back from the edit menu finds the selection the part held for it, which the adapter put back. let back_from_menu = menu_held && state.held_selection.is_none(); + // A select asked for in the pass that brings focus (`Cx::select_all_text`) is kept, as `select_on_focus` keeps it. if out.focused && !left_for_part && !was_focused && !back_from_menu { let len = decl.shown.chars().count(); eprintln!("DIAG text focus select: widget {widget:?} caret {:?} len {len} was_focused {was_focused}", decl.caret); - match decl.caret { - Caret::All => adapter::select(&ctx, widget, 0, len), - _ => adapter::select(&ctx, widget, len, len), + if select_all || matches!(decl.caret, Caret::All) { + adapter::select(&ctx, widget, 0, len); + } else { + adapter::select(&ctx, widget, len, len); } } if decl.options.complete.is_some() {