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.
+4 -3
View File
@@ -194,12 +194,12 @@ impl super::OpenCADStudio {
/// Commit the editor: create a new TEXT entity or update the edited slot.
/// Empty content drops a new entity and leaves an edited one untouched.
pub(super) fn text_inline_commit(&mut self) {
pub(super) fn text_inline_commit(&mut self) -> bool {
let i = self.active_tab;
let Some(ed) = self.text_inline.take() else { return };
let Some(ed) = self.text_inline.take() else { return false };
if ed.value.trim().is_empty() && ed.editing.is_none() {
self.refresh_properties();
return;
return false;
}
if let Some(h) = ed.editing {
self.push_undo_snapshot(i, "TEXT");
@@ -230,6 +230,7 @@ impl super::OpenCADStudio {
self.tabs[i].dirty = true;
}
self.refresh_properties();
true
}
/// Discard the editor without changing the drawing.
+4 -4
View File
@@ -4693,8 +4693,8 @@ impl OpenCADStudio {
Task::none()
}
Message::MTextOk => {
self.mtext_commit();
self.post_editor_closed(true)
let committed = self.mtext_commit();
self.post_editor_closed(committed)
}
Message::MTextCancel => {
self.mtext_cancel();
@@ -4708,8 +4708,8 @@ impl OpenCADStudio {
Task::none()
}
Message::TextInlineOk => {
self.text_inline_commit();
self.post_editor_closed(true)
let committed = self.text_inline_commit();
self.post_editor_closed(committed)
}
Message::DrawOrderSubmenuToggle => {