From 8e48bf02a0aaed9555cad11140b6bdfeb60d64db Mon Sep 17 00:00:00 2001 From: Karim Jerbi Date: Thu, 18 Jun 2026 17:49:29 +0100 Subject: [PATCH] fix(annotate): correctly resolve Leader annotations in TEXTEDIT - Custom recursive resolver ensures Leader entities trace back to their editable Text/MText annotations. - Bypasses overly strict baseline field checks so TEXTEDIT can natively target and launch the inline editor on Leaders. --- src/app/cmd_result.rs | 7 +------ src/app/text_inline.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs index 35c079f7c..dfc9a8dd3 100644 --- a/src/app/cmd_result.rs +++ b/src/app/cmd_result.rs @@ -1618,12 +1618,7 @@ impl OpenCADStudio { return self.begin_text_edit(handle); } CmdResult::SuspendForTextEdit { handle } => { - let is_editable = self.tabs[i] - .scene - .document - .get_entity(handle) - .map(|e| crate::app::text_inline::read_text_field(e).is_some()) - .unwrap_or(false); + let is_editable = crate::app::text_inline::can_edit_text(handle, &self.tabs[i].scene.document); if !is_editable { self.command_line.push_error("TEXTEDIT: selected entity is not text."); let prompt = self.tabs[i].active_cmd.as_ref().map(|c| c.prompt()); diff --git a/src/app/text_inline.rs b/src/app/text_inline.rs index 949a0df2c..c9a1c5356 100644 --- a/src/app/text_inline.rs +++ b/src/app/text_inline.rs @@ -98,6 +98,25 @@ pub struct TextInlineState { /// Canvas-space anchor where the field is drawn (the insertion-point click). pub screen_anchor: iced::Point, } +pub(super) fn can_edit_text(mut handle: Handle, document: &acadrust::CadDocument) -> bool { + for _ in 0..8 { + match document.get_entity(handle) { + Some(acadrust::EntityType::Leader(l)) => { + let ann = l.annotation_handle; + if ann.is_null() || ann == handle { + return false; + } + handle = ann; + } + _ => break, + } + } + if let Some(entity) = document.get_entity(handle) { + read_text_field(entity).is_some() + } else { + false + } +} impl super::OpenCADStudio { /// Open the right in-place editor for `handle`: the plain box for single-