From cea38fd0b4c2ff6d4337bc7034111c645e07c8c3 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 14:05:42 +0000 Subject: [PATCH] owed by ribbon-w5: the pass-local editor record step 16 reads (note_editor_facts, S-L168) --- crates/ui-contract/src/contract/steps.rs | 2 +- .../ui-contract/src/contract/steps/report.rs | 19 ++++++++++++++++++- crates/ui-contract/src/runtime/pass_state.rs | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/ui-contract/src/contract/steps.rs b/crates/ui-contract/src/contract/steps.rs index 3d4f3551e..597268ea6 100644 --- a/crates/ui-contract/src/contract/steps.rs +++ b/crates/ui-contract/src/contract/steps.rs @@ -13,7 +13,7 @@ mod measure; mod paint; mod parts; mod place; -mod report; +pub(crate) mod report; pub(crate) mod scroll_owner; mod sense; mod settle; diff --git a/crates/ui-contract/src/contract/steps/report.rs b/crates/ui-contract/src/contract/steps/report.rs index 9e63e7f27..bbd220823 100644 --- a/crates/ui-contract/src/contract/steps/report.rs +++ b/crates/ui-contract/src/contract/steps/report.rs @@ -10,6 +10,7 @@ use crate::runtime::commands::{self, ResolvedCommand}; use crate::runtime::env::{Label, Message}; use crate::runtime::focus::{self}; use crate::runtime::keys; +use crate::runtime::pass_state; use crate::style::Flags; use craft_behavior::Sense; use egui::Id; @@ -174,7 +175,11 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_> if let Some(folded) = &folded { keys::register_node(ctx, id, folded.inner, None, focusable); } - if let Some(facts) = core.text_access.take() { + let editor_record = || { + let widget = core.editor.as_ref()?.widget; + pass_state::with::(ctx, |records| records.0.remove(&widget)) + }; + if let Some(facts) = core.text_access.take().or_else(editor_record) { crate::runtime::access::text::report_text(ctx, id, &facts); } if core.member_of.is_some() && flags.contains(Flags::FOCUSED) { @@ -280,3 +285,15 @@ pub(crate) fn report_inert(core: &CxCore<'_>, facts: &TypeFacts) { }, ); } + +/// The text facts an editor body reported through its `EditorHandle` in the running pass, by editor widget: the +/// owning component's report step reads its own (owed by ribbon-w5, S-L168). Pass-local, so nothing outlives the pass. +#[derive(Default)] +pub(crate) struct EditorRecords(std::collections::HashMap); + +/// Puts `facts` in the running pass's record for the editor part `widget`. +pub(crate) fn note_editor_facts(ctx: &egui::Context, widget: egui::Id, facts: crate::runtime::access::text::TextFacts) { + pass_state::with::(ctx, |records| { + records.0.insert(widget, facts); + }); +} diff --git a/crates/ui-contract/src/runtime/pass_state.rs b/crates/ui-contract/src/runtime/pass_state.rs index 269ef500b..9839be283 100644 --- a/crates/ui-contract/src/runtime/pass_state.rs +++ b/crates/ui-contract/src/runtime/pass_state.rs @@ -87,6 +87,7 @@ pass_state! { gestures: crate::runtime::edit::Gestures, reveals: crate::contract::steps::scroll_owner::Reveals, scroll_moves: crate::contract::steps::scroll_owner::ScrollMoves, + editor_records: crate::contract::steps::report::EditorRecords, jumps: crate::contract::body::scroll::Jumps, shrink_reports: crate::layout::body::ShrinkReports, least_reports: crate::layout::body::LeastReports,