From 21b71e19d1780c11a489de6760d70f7e730e1fd9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 01:23:49 +0000 Subject: [PATCH] Completion list: a mark before each candidate and the highlighted one's description under the list; Enter accepts only where the field completes on Enter (ctl:72, ctl:73) - Completion carries a mark and a description; the unread detail line goes. - FocusPolicy::list_enter: a text opener of a KeepAnchor layer keeps Enter when its layer turns it off, and Tab alone takes the lead. TextField::complete_on_enter turns it on; the review composer's mentions use it, as before. --- crates/review/src/ui/thread/popover.rs | 1 + .../ui-contract/src/primitives/text_input.rs | 25 ++++++- .../ui-contract/src/runtime/focus/policy.rs | 12 ++++ .../src/runtime/focus/registration.rs | 13 ++-- crates/ui-contract/src/runtime/keys/route.rs | 15 ++-- crates/ui-widgets/src/text/completions.rs | 44 +++++++++--- crates/ui-widgets/src/text/text_field.rs | 10 ++- .../ui-widgets/src/text/text_field/stories.rs | 31 ++++++++ crates/ui-widgets/tests/it/text/fields.rs | 72 +++++++++++++++++++ 9 files changed, 196 insertions(+), 27 deletions(-) diff --git a/crates/review/src/ui/thread/popover.rs b/crates/review/src/ui/thread/popover.rs index faa5d169d1..5c8d8f1f0b 100644 --- a/crates/review/src/ui/thread/popover.rs +++ b/crates/review/src/ui/thread/popover.rs @@ -208,6 +208,7 @@ impl ThreadPopover<'_> { .lines(COMPOSER_ROWS) .placeholder(words.reply.clone()) .complete(MentionCompleter { people: people.to_vec(), me: me.to_owned() }) + .complete_on_enter() .submits() .default_stop() .show(ui); diff --git a/crates/ui-contract/src/primitives/text_input.rs b/crates/ui-contract/src/primitives/text_input.rs index 8d9fd3edce..1e25a2f463 100644 --- a/crates/ui-contract/src/primitives/text_input.rs +++ b/crates/ui-contract/src/primitives/text_input.rs @@ -59,6 +59,8 @@ pub struct TextOptions { pub tab_inserts: bool, /// Candidates for the text before the caret. pub complete: Option>, + /// Enter accepts the highlighted candidate, as Tab does; off, Enter stays the field's own (a cell commits on it). + pub complete_on_enter: bool, /// Text that replaces the selection in the pass it is set (the caret inserts it). pub replace_selection: Option, /// Typing one of these characters commits the draft, as Enter does without submitting; the character is not @@ -102,6 +104,7 @@ impl Default for TextOptions { ink: None, tab_inserts: false, complete: None, + complete_on_enter: false, replace_selection: None, commit_on: &[], enabled: true, @@ -152,14 +155,30 @@ pub struct Completion { pub label: Label, /// The text that replaces the range. pub insert: String, - /// A second line of the row. - pub detail: Option