VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Tabs: Delete Tab and Repeat Tab are off while an indent marker is selected
dotCooCooedbcc5a88c4f
diff --git a/crates/ui-egui/src/panels/tabs.rs b/crates/ui-egui/src/panels/tabs.rsindex 81bb00743..040ff676c 100644--- a/crates/ui-egui/src/panels/tabs.rs+++ b/crates/ui-egui/src/panels/tabs.rs@@ -533,6 +533,7 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {return;};let mut stops = para.tabs;+ let selected_marker: Option<IndentMarker> = pstate(ui.ctx(), "tabs-marker-sel");// Clamp the selection to the last stop, as `show` does for the ruler.let mut sel: usize = pstate(ui.ctx(), "tabs-sel");if sel >= stops.len() {@@ -543,13 +544,13 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {{app.status(e);}- if menu_item(ui, tl!("Delete Tab"), sel < stops.len(), false) {+ if menu_item(ui, tl!("Delete Tab"), sel < stops.len() && selected_marker.is_none(), false) {stops.remove(sel);apply(app, &stops);}// Repeat Tab: copies of the selected stop across the ruler, spaced by its distance from the// previous stop, or from the paragraph's left indent when it is the first stop.- if menu_item(ui, tl!("Repeat Tab"), sel < stops.len(), false) {+ if menu_item(ui, tl!("Repeat Tab"), sel < stops.len() && selected_marker.is_none(), false) {let step = match sel {0 => (stops[0].position - para.left_indent).abs(),_ => stops[sel].position - stops[sel - 1].position,diff --git a/crates/ui-egui/src/panels/tabs/tests.rs b/crates/ui-egui/src/panels/tabs/tests.rsindex 411848f66..ad8f86a52 100644--- a/crates/ui-egui/src/panels/tabs/tests.rs+++ b/crates/ui-egui/src/panels/tabs/tests.rs@@ -788,6 +788,22 @@ fn panel_menu_repeats_deletes_and_clears_tab_stops() {assert_eq!(positions(&app).len(), 21);}+#[test]+fn panel_menu_does_not_change_stops_while_an_indent_marker_is_selected() {+ let mut app = indent_app(24.0, 12.0);+ app.session.execute("text.tabs.set", &json!({"stops": [{"position": 50}, {"position": 70}]})).unwrap();+ let ctx = egui::Context::default();+ set_pstate(&ctx, "tabs-sel", 1usize);+ marker_event(&ctx, &mut app, 36.0, 36.0, true, false, false);+ assert_eq!(pstate::<Option<IndentMarker>>(&ctx, "tabs-marker-sel"), Some(IndentMarker::Upper));+ let before = current(&app).unwrap().1;++ choose(&ctx, &mut app, "Repeat Tab");+ assert_eq!(current(&app).unwrap().1, before);+ choose(&ctx, &mut app, "Delete Tab");+ assert_eq!(current(&app).unwrap().1, before);+}+/// Repeat Tab on the first stop spaces the copies by the stop's distance from the paragraph's/// left indent, from the paragraph the caret is in while the Type tool edits text.#[test]