History: Delete on a selected feature deletes the selection in both timelines (#8861) (#8867)

* claim: #8861

* History: Delete on a selected feature deletes the selection in both timelines (#8861)

With several features selected, Delete in a selected feature's menu deleted
the whole selection in the bottom timeline and only that feature in the
history beside the browser, which offered the selection as a separate
Delete Selected Features… entry.

Both menus now use one Delete entry: the selected features when the
right-clicked one is among them, labelled "Delete N Selected Features",
else that feature alone. The history beside the browser no longer adds its
own Delete Selected Features… to a selected feature's menu, since the entry
above covers it; folder menus keep it. The single-feature delete helper had
no callers left and is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* History: a feature's menu leaves out Delete Selected Features… by a flag (#8861)

A right-click on a feature outside the selection selects that feature
first, so in a feature's menu the clicked feature is always selected. A
flag that says the menu is a feature's says the same without the lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DanielandClaude Opus 5.5 authored and GitHub committed 2026-10-29 17:06:25 +00:00
1 parent 21366ec47e
commit 32c8b23199
2 files changed
+43 -39

No files matched your search

+35 -30
View File
@@ -257,11 +257,6 @@ fn slot_at(xs: &[f32], end: f32, x: f32) -> usize {
best.0
}
/// Ask before deleting a feature others depend on; delete right away otherwise.
pub(crate) fn delete_feature(app: &mut SolveApp, id: u64) {
delete_features(app, vec![id]);
}
/// Check what deleting `ids` takes with it or makes fail (off the window thread when that takes a
/// while, #2678), then delete them or ask first.
pub(crate) fn delete_features(app: &mut SolveApp, ids: Vec<u64>) {
@@ -329,6 +324,20 @@ pub(crate) fn menu_targets(app: &SolveApp, id: u64) -> Vec<u64> {
if selected.contains(&id) { selected } else { vec![id] }
}
/// Delete in a feature's menu, in both timelines: the selected features when the right-clicked
/// one is among them, labelled with how many, else that feature alone (#5005).
pub(crate) fn delete_button(app: &mut SolveApp, ui: &mut egui::Ui, id: u64) {
let targets = menu_targets(app, id);
let label = match targets.len() {
1 => crate::i18n::tr_label("Delete").to_string(),
n => crate::i18n::format("timeline.delete_many", &[("count", &n.to_string())]),
};
if crate::context_menu::button(ui, &label, "delete").clicked() {
delete_features(app, targets);
ui.close();
}
}
/// The features from timeline position `from` to the end.
fn features_from(app: &SolveApp, from: usize) -> Vec<u64> {
app.session.doc.features.iter().skip(from).map(|f| f.id).collect()
@@ -992,15 +1001,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
clipboard_buttons(app, ui, *id);
message_button(app, ui, *id);
ui.separator();
let targets = menu_targets(app, *id);
let label = match targets.len() {
1 => crate::i18n::tr_label("Delete").to_string(),
n => crate::i18n::format("timeline.delete_many", &[("count", &n.to_string())]),
};
if crate::context_menu::button(ui, &label, "delete").clicked() {
delete_features(app, targets);
ui.close();
}
delete_button(app, ui, *id);
delete_after_marker_button(app, ui, *id, i, marker);
});
x += 32.0;
@@ -1889,23 +1890,28 @@ mod tests {
}
/// Delete in the menu of a selected feature deletes the whole selection in one undo step,
/// and says how many; on a feature outside the selection it deletes that one (#5005).
/// and says how many; on a feature outside the selection it deletes that one (#5005). The
/// same in both timelines, and the history beside the browser no longer adds its own Delete
/// Selected Features… to a feature's menu (#8861).
#[test]
fn the_feature_menu_deletes_the_selected_features() {
let mut h = three_boxes(false);
h.step(&json!({"click": {"handle": "timeline:Third"}, "button": "right"})).unwrap();
assert!(h.widget("Delete").is_some());
h.step(&json!({"key": "Escape"})).unwrap();
for left in [false, true] {
let mut h = three_boxes(left);
h.step(&json!({"click": {"handle": "timeline:Third"}, "button": "right"})).unwrap();
assert!(h.widget("Delete").is_some(), "left: {left}");
h.step(&json!({"key": "Escape"})).unwrap();
h.step(&json!({"click": {"handle": "timeline:First"}})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Second"}, "ctrl": true})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Second"}, "button": "right"})).unwrap();
h.step(&json!({"widget": "Delete 2 Selected Features"})).unwrap();
h.settle();
assert!(h.app.dialog.is_none(), "nothing else depends on them");
assert_eq!(names(&h), ["Third"]);
h.app.run("edit.undo", json!({})).unwrap();
assert_eq!(names(&h), ["First", "Second", "Third"]);
h.step(&json!({"click": {"handle": "timeline:First"}})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Second"}, "ctrl": true})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Second"}, "button": "right"})).unwrap();
assert!(h.widget("Delete Selected Features…").is_none(), "left: {left}");
h.step(&json!({"widget": "Delete 2 Selected Features"})).unwrap();
h.settle();
assert!(h.app.dialog.is_none(), "nothing else depends on them");
assert_eq!(names(&h), ["Third"], "left: {left}");
h.app.run("edit.undo", json!({})).unwrap();
assert_eq!(names(&h), ["First", "Second", "Third"], "left: {left}");
}
}
/// The menu of a feature after the history marker deletes every feature after the marker,
@@ -1923,8 +1929,7 @@ mod tests {
h.step(&json!({"click": {"handle": "timeline:Second"}})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Third"}, "ctrl": true})).unwrap();
h.step(&json!({"click": {"handle": "timeline:Third"}, "button": "right"})).unwrap();
// (The history beside the browser has its own Delete Selected Features….)
assert!(left || h.widget("Delete 2 Selected Features").is_some());
assert!(h.widget("Delete 2 Selected Features").is_some(), "left: {left}");
assert!(h.widget("Delete 2 Features After History Marker").is_none(), "left: {left}");
h.step(&json!({"key": "Escape"})).unwrap();
h.app.run("select.clear", json!({})).unwrap();
+8 -9
View File
@@ -7,7 +7,7 @@ use serde_json::json;
use crate::history_rows::{HistoryFeature, HistoryRows};
use crate::theme::Tokens;
use crate::timeline::{
TimelineKind, clipboard_buttons, delete_after_marker_button, delete_feature, delete_features, icon_of, message_button, selected_feature_ids,
TimelineKind, clipboard_buttons, delete_after_marker_button, delete_button, delete_features, icon_of, message_button, selected_feature_ids,
};
use crate::{SolveApp, icons};
@@ -671,7 +671,7 @@ fn select_item(app: &mut SolveApp, ui: &egui::Ui, item: TimelineItem, order: &[T
}
}
fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft_engine::doc::TimelineGroup]) {
fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft_engine::doc::TimelineGroup], feature_menu: bool) {
let features = selected_feature_ids(app);
let selected_groups = app.tree.picked_timeline_groups.clone();
let has_selection = !features.is_empty() || !selected_groups.is_empty();
@@ -737,7 +737,9 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
ui.close();
}
}
if !features.is_empty() {
// A feature's menu has its own Delete, which deletes the selection ([`delete_button`]): a
// right-click on a feature outside the selection selects that feature first.
if !features.is_empty() && !feature_menu {
ui.separator();
if crate::context_menu::button(ui, "Delete Selected Features…", "delete").clicked() {
delete_features(app, features);
@@ -1125,7 +1127,7 @@ fn vertical_group_row(
ui.close();
}
ui.separator();
selection_actions(app, ui, groups);
selection_actions(app, ui, groups, false);
});
open
}
@@ -1570,12 +1572,9 @@ fn feature_row(app: &mut SolveApp, ui: &mut egui::Ui, rows: &mut Rows, index: us
clipboard_buttons(app, ui, id);
message_button(app, ui, id);
ui.separator();
selection_actions(app, ui, groups);
selection_actions(app, ui, groups, true);
ui.separator();
if crate::context_menu::button(ui, "Delete", "delete").clicked() {
delete_feature(app, id);
ui.close();
}
delete_button(app, ui, id);
delete_after_marker_button(app, ui, id, index, marker);
});
if edit {