fix(editor): prevent empty text commit from advancing command edit_count

- Propagates commit status out of inline editors so commands know whether a real change occurred.

- Fixes TEXTEDIT's Undo step rolling back unrelated document actions when the user presses OK on empty/cleared existing MText.
This commit is contained in:
Karim Jerbi committed 2026-06-18 17:55:30 +01:00
1 parent 8e48bf02a0
commit 02f70ab0b3
3 files changed
+12 -10

No files matched your search

+4 -3
View File
@@ -628,15 +628,15 @@ impl super::OpenCADStudio {
}
/// Commit the editor — create a new MText or update the edited one.
pub(super) fn mtext_commit(&mut self) {
pub(super) fn mtext_commit(&mut self) -> bool {
let i = self.active_tab;
let Some(ed) = self.mtext_editor.take() else { return };
let Some(ed) = self.mtext_editor.take() else { return false };
let body_empty = ed.content.text().trim().is_empty();
let mt = ed.build_mtext();
if body_empty {
// Empty content: drop a new entity; leave an edited one untouched.
self.refresh_properties();
return;
return false;
}
if let Some(h) = ed.editing {
self.push_undo_snapshot(i, "MTEXT");
@@ -666,6 +666,7 @@ impl super::OpenCADStudio {
self.tabs[i].dirty = true;
}
self.refresh_properties();
true
}
/// Discard the editor without changing the drawing.