Tabs: Delete Tab and Repeat Tab are off while an indent marker is selected

This commit is contained in:
dotCooCoo
2026-10-31 07:17:04 +07:00
committed by bflatastic
parent 830cbbcecb
commit edbcc5a88c
2 changed files with 19 additions and 2 deletions
+3 -2
View File
@@ -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,
+16
View File
@@ -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]