PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Arrow-key nudges: a run of nudges is one History state, with Tools preferences (#2259) (#2764)
Sir Starchcd046f4a70c7
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex f3469ad72..d6b40178d 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -382,6 +382,13 @@ pub struct Tools {/// Pen pressure response: `[input, output]` control points in 0..1 that the pen's pressure/// passes through before it reaches any brush ([`PressureCurve`]). Linear by default.pub pressure_curve: Vec<[f32; 2]>,+ /// Arrow-key nudges of one thing (the selected layers, the selection outline, the Free+ /// Transform box) that follow each other within [`Tools::nudge_bundle_pause_ms`] are one+ /// History state (#2259). Off: every press is a state.+ pub bundle_nudges: bool,+ /// The longest pause, in milliseconds, between two nudges that still bundle into one state.+ /// Longer than a key's auto-repeat delay (about half a second), so a held key is one state.+ pub nudge_bundle_pause_ms: u32,}impl Default for Tools {@@ -400,6 +407,8 @@ impl Default for Tools {right_click_with_painting_tools: RightClickPaint::BrushPicker,use_tablet_pressure: true,pressure_curve: vec![[0.0, 0.0], [1.0, 1.0]],+ bundle_nudges: true,+ nudge_bundle_pause_ms: 1000,}}}@@ -1081,6 +1090,7 @@ pub fn range(path: &str) -> Option<(f64, f64)> {Some(match path {"fileHandling.autosaveMinutes" => (1.0, 240.0),"fileHandling.recentFileCount" => (0.0, 100.0),+ "tools.nudgeBundlePauseMs" => (100.0, 10_000.0),"fileHandling.rasterizeSvgGroupsDeeperThan" => (0.0, photocraft_doc::MAX_GROUP_DEPTH as f64),"interface.notificationDurationSeconds" => (1.0, 120.0),"export.jpegQuality" | "export.webpQuality" => (1.0, 100.0),diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rsindex 6bb4ff447..bf2fe52ef 100644--- a/crates/engine/src/prefs/tests.rs+++ b/crates/engine/src/prefs/tests.rs@@ -656,6 +656,37 @@ fn ruler_units_round_to_their_own_decimal_places() {assert_eq!(r.format(100.0, 300.0, 1500.0), "0.333");}+/// #2259: arrow-key nudges bundle into one History state by default, within a pause long enough+/// for a held key's auto-repeat delay; both are Tools preferences with a validated range.+#[test]+fn nudge_bundling_preferences() {+ let p = Preferences::default();+ assert!(p.tools.bundle_nudges);+ assert_eq!(p.tools.nudge_bundle_pause_ms, 1000);+ // Preferences saved before these existed load with the defaults.+ let old: Preferences = serde_json::from_value(json!({"tools": {"showTooltips": false}})).unwrap();+ assert!(old.tools.bundle_nudges && !old.tools.show_tooltips);+ assert_eq!(old.tools.nudge_bundle_pause_ms, 1000);++ let mut s = session();+ assert_eq!(s.execute("prefs.get", json!({"path": "tools.bundleNudges"})).unwrap(), json!(true));+ s.execute("prefs.set", json!({"values": {"tools.bundleNudges": false, "tools.nudgeBundlePauseMs": 250}})).unwrap();+ assert!(!s.prefs().tools.bundle_nudges);+ assert_eq!(s.prefs().tools.nudge_bundle_pause_ms, 250);+ for edge in [100, 10_000] {+ s.execute("prefs.set", json!({"path": "tools.nudgeBundlePauseMs", "value": edge})).unwrap();+ assert_eq!(s.prefs().tools.nudge_bundle_pause_ms, edge);+ }+ for bad in [json!(0), json!(99), json!(10_001), json!(-1), json!(1.5e300), json!("long"), json!(null)] {+ assert!(s.execute("prefs.set", json!({"path": "tools.nudgeBundlePauseMs", "value": bad.clone()})).is_err(), "{bad}");+ }+ assert!(s.execute("prefs.set", json!({"path": "tools.bundleNudges", "value": "yes"})).is_err());+ assert_eq!(s.prefs().tools.nudge_bundle_pause_ms, 10_000, "a rejected value changes nothing");+ s.execute("prefs.reset", json!({"path": "tools"})).unwrap();+ assert!(s.prefs().tools.bundle_nudges);+ assert_eq!(s.prefs().tools.nudge_bundle_pause_ms, 1000);+}+/// #3665: Photoshop's second default keys (F2/F3/F4, Shift+F7, Cmd++) are a command's/// alternates, beside the main key its menu shows.#[test]diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rsindex ee7dd3435..04063d307 100644--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@ -1155,6 +1155,47 @@ fn coalesced_edits_share_one_history_step() {assert!((l - 1.0).abs() < 1e-6, "{l}");}+/// #2259: the commands behind the arrow-key nudges take the `coalesce` key, so a run of them is+/// one step an agent can drive too, and one Undo takes the whole run back.+#[test]+fn translate_and_transform_selection_coalesce_into_one_step() {+ let mut s = Session::new();+ s.execute("file.new", json!({"width": 60, "height": 60})).unwrap();+ s.execute("layer.new.layer", json!({})).unwrap();+ s.execute("select.rect", json!({"x": 10, "y": 10, "width": 10, "height": 10})).unwrap();+ s.execute("edit.fill", json!({"color": "#ff0000"})).unwrap();+ let steps = |s: &Session| s.active().unwrap().history.past_len();+ let left = |s: &Session| {+ let st = s.active().unwrap();+ st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().content_bounds().x0+ };+ let sel = |s: &Session| s.active().unwrap().doc.selection.as_ref().unwrap().content_bounds().x0;++ let base = steps(&s);+ for _ in 0..5 {+ s.execute("layer.translate", json!({"dx": 1, "dy": 0, "coalesce": "nudge:1"})).unwrap();+ }+ assert_eq!((steps(&s), left(&s)), (base + 1, 15), "five nudges, one step");+ s.execute("layer.translate", json!({"dx": 1, "dy": 0, "coalesce": "nudge:2"})).unwrap();+ s.execute("layer.translate", json!({"dx": 1, "dy": 0})).unwrap();+ s.execute("layer.translate", json!({"dx": 1, "dy": 0, "coalesce": "nudge:2"})).unwrap();+ assert_eq!(steps(&s), base + 4, "another key, an uncoalesced move and a repeated key each start a step");+ for _ in 0..3 {+ assert!(s.undo());+ }+ assert_eq!(left(&s), 15);+ assert!(s.undo());+ assert_eq!(left(&s), 10, "Undo takes the run of five back at once");++ let base = steps(&s);+ for _ in 0..4 {+ s.execute("select.transformSelection", json!({"dx": 1, "dy": 0, "coalesce": "nudge:3"})).unwrap();+ }+ assert_eq!((steps(&s), sel(&s)), (base + 1, 14));+ assert!(s.undo());+ assert_eq!(sel(&s), 10);+}+#[test]fn type_edit_rerenders_cache_to_new_text() {let mut s = Session::new();diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 8c98e2a05..81d7dcb69 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -2506,6 +2506,8 @@ fontWeight Italic KurzívaColor Picker (Layer Style Color) Výběr barvy (barva stylu vrstvy)Auto Hide Notifications Automaticky skrývat oznámeníNotification Duration (seconds) Trvání oznámení (sekundy)+ Bundle Arrow-Key Nudges Slučovat posuny šipkami+ Nudge Bundle Pause (ms) Pauza slučování posunů (ms)Appearance Mode Režim vzhleduDark Theme Tmavý motivLight Theme Světlý motivdiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex c3a4f5354..f9830cbb7 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -2546,6 +2546,8 @@ fontWeight Italic KursivColor Picker (Layer Style Color) Farbwähler (Ebenenstilfarbe)Auto Hide Notifications Benachrichtigungen automatisch ausblendenNotification Duration (seconds) Dauer der Benachrichtigung (Sekunden)+ Bundle Arrow-Key Nudges Pfeiltasten-Verschiebungen bündeln+ Nudge Bundle Pause (ms) Pause für gebündelte Verschiebungen (ms)Appearance Mode ErscheinungsmodusDark Theme Dunkles DesignLight Theme Helles Designdiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex 13b5c219b..fed921ec9 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -3611,6 +3611,8 @@ fontWeight Thin Πολύ λεπτάColor Picker ({name}) Επιλογέας χρώματος ({name})Auto Hide Notifications Αυτόματη απόκρυψη ειδοποιήσεωνNotification Duration (seconds) Διάρκεια ειδοποίησης (δευτερόλεπτα)+ Bundle Arrow-Key Nudges Ομαδοποίηση μετατοπίσεων με βέλη+ Nudge Bundle Pause (ms) Παύση ομαδοποίησης μετατοπίσεων (ms)Appearance Mode Λειτουργία εμφάνισηςPro Medium Pro MediumStudio Light Studio Lightdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 4517fc6e2..83ff70923 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -2575,6 +2575,8 @@ fontWeight Italic CursivaColor Picker (Layer Style Color) Selector de color (color del estilo de capa)Auto Hide Notifications Ocultar notificaciones automáticamenteNotification Duration (seconds) Duración de la notificación (segundos)+ Bundle Arrow-Key Nudges Agrupar desplazamientos con las flechas+ Nudge Bundle Pause (ms) Pausa para agrupar desplazamientos (ms)Appearance Mode Modo de aparienciaDark Theme Tema oscuroLight Theme Tema clarodiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex a2a9190d1..14aaf6da6 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2923,6 +2923,8 @@ fontWeight Italic ItaliqueColor Picker (Layer Style Color) Sélecteur de couleurs (couleur du style de calque)Auto Hide Notifications Masquer automatiquement les notificationsNotification Duration (seconds) Durée de la notification (secondes)+ Bundle Arrow-Key Nudges Regrouper les déplacements aux flèches+ Nudge Bundle Pause (ms) Pause de regroupement des déplacements (ms)Appearance Mode Mode d’apparenceDark Theme Thème sombreLight Theme Thème clairdiff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsvindex 7387f6d7c..12fa86cd8 100644--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@ -2856,6 +2856,8 @@ cameraRaw Yellow SárgaNo saved presets yet. Még nincs mentett előbeállítás.Not a web colour: click for the nearest web colour Nem webes szín: kattints a legközelebbi webes színértNotification Duration (seconds) Értesítés időtartama (másodperc)+ Bundle Arrow-Key Nudges Nyílbillentyűs mozgatások összevonása+ Nudge Bundle Pause (ms) Összevonási szünet (ms)Number SzámOK OKOnly Web Colors Csak webes színekdiff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 50bbd522a..302e3cbf2 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2910,6 +2910,8 @@ fontWeight Italic MiringColor Picker (Layer Style Color) Pemilih Warna (Warna Gaya Lapisan)Auto Hide Notifications Sembunyikan notifikasi secara otomatisNotification Duration (seconds) Durasi notifikasi (detik)+ Bundle Arrow-Key Nudges Gabungkan pergeseran tombol panah+ Nudge Bundle Pause (ms) Jeda penggabungan pergeseran (ms)Appearance Mode Mode tampilanDark Theme Tema gelapLight Theme Tema terangdiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex baf638b3d..db1fc16a4 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -2576,6 +2576,8 @@ fontWeight Italic CorsivoColor Picker (Layer Style Color) Selettore colore (colore dello stile livello)Auto Hide Notifications Nascondi automaticamente le notificheNotification Duration (seconds) Durata della notifica (secondi)+ Bundle Arrow-Key Nudges Raggruppa gli spostamenti con le frecce+ Nudge Bundle Pause (ms) Pausa per raggruppare gli spostamenti (ms)Appearance Mode Modalità aspettoDark Theme Tema scuroLight Theme Tema chiarodiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 8ebbd44c4..9a6042b80 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -3520,6 +3520,8 @@ fontWeight Italic 斜体Color Picker (Layer Style Color) カラーピッカー (レイヤースタイルの色)Auto Hide Notifications 通知を自動的に隠すNotification Duration (seconds) 通知の表示時間 (秒)+ Bundle Arrow-Key Nudges 矢印キーの移動をまとめる+ Nudge Bundle Pause (ms) 移動をまとめる間隔(ms)Appearance Mode 外観モードDark Theme ダークテーマLight Theme ライトテーマdiff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex e37211cfc..b39003858 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -3085,6 +3085,8 @@ fontWeight Italic 기울임Color Picker (Layer Style Color) 색상 피커 (레이어 스타일 색상)Auto Hide Notifications 알림 자동 숨기기Notification Duration (seconds) 알림 지속 시간(초)+ Bundle Arrow-Key Nudges 방향키 이동을 하나로 묶기+ Nudge Bundle Pause (ms) 이동 묶음 대기 시간(ms)Appearance Mode 화면 모드Dark Theme 어두운 테마Light Theme 밝은 테마diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex d78ceac79..b9d064a2b 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -3677,6 +3677,8 @@ cameraRaw Whites WittenColor Picker (Layer Style Color) Kleurkiezer (kleur van laagstijl)Auto Hide Notifications Meldingen automatisch verbergenNotification Duration (seconds) Duur van melding (seconden)+ Bundle Arrow-Key Nudges Pijltjestoetsverschuivingen bundelen+ Nudge Bundle Pause (ms) Pauze voor bundelen van verschuivingen (ms)Appearance Mode WeergavemodusNext Appearance Mode Volgende weergavemodusSync with system Synchroniseren met systeemdiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 1c01293a4..d2f436041 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -3521,6 +3521,8 @@ cameraRaw Roughness ChropowatośćColor Picker (Layer Style Color) Próbnik kolorów (kolor stylu warstwy)Auto Hide Notifications Automatycznie ukrywaj powiadomieniaNotification Duration (seconds) Czas trwania powiadomienia (sekundy)+ Bundle Arrow-Key Nudges Grupuj przesunięcia strzałkami+ Nudge Bundle Pause (ms) Przerwa grupowania przesunięć (ms)Appearance Mode Tryb wygląduDark Theme Ciemny motywLight Theme Jasny motywdiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex fadb6a4e0..40e78664b 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2927,6 +2927,8 @@ fontWeight Italic ItálicoColor Picker (Layer Style Color) Seletor de cores (cor do estilo de camada)Auto Hide Notifications Ocultar notificações automaticamenteNotification Duration (seconds) Duração da notificação (segundos)+ Bundle Arrow-Key Nudges Agrupar deslocamentos com as setas+ Nudge Bundle Pause (ms) Pausa para agrupar deslocamentos (ms)Appearance Mode Modo de aparênciaDark Theme Tema escuroLight Theme Tema clarodiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex a465ecd14..ef8c350af 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2775,6 +2775,8 @@ fontWeight Italic КурсивColor Picker (Layer Style Color) Палитра цветов (цвет стиля слоя)Auto Hide Notifications Автоскрытие уведомленийNotification Duration (seconds) Длительность уведомления (секунды)+ Bundle Arrow-Key Nudges Объединять сдвиги стрелками+ Nudge Bundle Pause (ms) Пауза объединения сдвигов (мс)Appearance Mode Режим оформленияDark Theme Тёмная темаLight Theme Светлая темаdiff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsvindex 96d788d59..dc63af88d 100644--- a/crates/ui-egui/src/i18n/sr.tsv+++ b/crates/ui-egui/src/i18n/sr.tsv@@ -2898,6 +2898,8 @@ fontWeight Italic KurzivColor Picker (Layer Style Color) Birač boja (boja stila sloja)Auto Hide Notifications Automatski sakrij obaveštenjaNotification Duration (seconds) Trajanje obaveštenja (sekunde)+ Bundle Arrow-Key Nudges Objedini pomeranja strelicama+ Nudge Bundle Pause (ms) Pauza za objedinjavanje pomeranja (ms)Appearance Mode Režim izgledaPresentation PrikazDark Theme Tamna temadiff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsvindex 4dd69a2ad..48c4e5a48 100644--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@ -3645,6 +3645,8 @@ cameraRaw Whites BeyazlarColor Picker (Layer Style Color) Renk Seçici (Katman Stili Rengi)Auto Hide Notifications Bildirimleri Otomatik GizleNotification Duration (seconds) Bildirim Süresi (saniye)+ Bundle Arrow-Key Nudges Ok tuşlarıyla kaydırmaları birleştir+ Nudge Bundle Pause (ms) Kaydırma birleştirme duraklaması (ms)Appearance Mode Görünüm ModuPresentation SunumNext Appearance Mode Sonraki Görünüm Modudiff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex 8cbf0fef2..f31ed9857 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -3607,6 +3607,8 @@ cameraRaw Masking МаскуванняColor Picker (Layer Style Color) Палітра кольорів (колір стилю шару)Auto Hide Notifications Автоматично приховувати сповіщенняNotification Duration (seconds) Тривалість сповіщення (секунди)+ Bundle Arrow-Key Nudges Поєднувати зсуви стрілками+ Nudge Bundle Pause (ms) Пауза поєднання зсувів (мс)Appearance Mode Режим виглядуDark Theme Темна темаLight Theme Світла темаdiff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsvindex 0b10fe048..cf71b0e48 100644--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@ -2804,6 +2804,8 @@ fontWeight Italic NghiêngNever Show Overlay Không bao giờ hiện lớp phủAuto Hide Notifications Tự động ẩn thông báoNotification Duration (seconds) Thời lượng thông báo (giây)+ Bundle Arrow-Key Nudges Gộp dịch chuyển bằng phím mũi tên+ Nudge Bundle Pause (ms) Thời gian chờ gộp dịch chuyển (ms)Dark Theme Giao diện tốiLight Theme Giao diện sángPro Medium Pro trung bìnhdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex ee9c1cc7a..c33095fef 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -2517,6 +2517,8 @@ fontWeight Italic 斜体Color Picker (Layer Style Color) 拾色器(图层样式颜色)Auto Hide Notifications 自动隐藏通知Notification Duration (seconds) 通知持续时间(秒)+ Bundle Arrow-Key Nudges 合并方向键微移+ Nudge Bundle Pause (ms) 微移合并间隔(毫秒)Appearance Mode 外观模式Dark Theme 深色主题Light Theme 浅色主题diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex ca44e69b7..565560d36 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -2487,6 +2487,8 @@ fontWeight Italic 斜體Color Picker (Layer Style Color) 檢色器(圖層樣式顏色)Auto Hide Notifications 自動隱藏通知Notification Duration (seconds) 通知持續時間(秒)+ Bundle Arrow-Key Nudges 合併方向鍵微移+ Nudge Bundle Pause (ms) 微移合併間隔(毫秒)Appearance Mode 外觀模式Dark Theme 深色主題Light Theme 淺色主題diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 9e0ecaaf8..d8d091314 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -142,6 +142,7 @@ pub mod new_doc_ui;pub mod new_guide_ui;pub mod new_layer_ui;pub mod notices;+pub mod nudge_bundle;mod numeric_expression;pub mod object_finder;mod opacity_keys;@@ -701,6 +702,8 @@ pub struct PhotocraftApp {pub(crate) move_mods: move_mods::MoveDrag,/// Cached document for a modal text Style Options color preview.pub(crate) text_style_preview: Option<type_panels_ui::color_picker::Preview>,+ /// The run of arrow-key nudges that share one History state (nudge_bundle).+ pub(crate) nudge_bundle: nudge_bundle::NudgeBundle,/// Live Layer Style dialog preview: (key over revision + style fields, preview or validation error).pub(crate) style_preview: Option<(u64, Result<std::sync::Arc<Document>, String>)>,pub(crate) solid_fill_preview: Option<solid_fill_ui::Preview>,@@ -901,6 +904,7 @@ impl PhotocraftApp {clip_read_for_paste: false,transform_preview: None,move_mods: Default::default(),+ nudge_bundle: Default::default(),style_preview: None,text_style_preview: None,solid_fill_preview: None,@@ -2677,6 +2681,9 @@ mod marquee_tests;#[cfg(test)]mod canvas_menu_tests;+#[cfg(test)]+mod nudge_bundle_tests;+#[cfg(test)]mod caps_lock_tests;diff --git a/crates/ui-egui/src/marquee_tests.rs b/crates/ui-egui/src/marquee_tests.rsindex cf4832904..51b16916e 100644--- a/crates/ui-egui/src/marquee_tests.rs+++ b/crates/ui-egui/src/marquee_tests.rs@@ -545,12 +545,14 @@ fn hovering_inside_the_selection_shows_the_move_cursor() {}/// #1428: with a marquee, the arrow keys nudge the selection outline 1 px, ⇧ 10 px (Photoshop);-/// each press is one undoable step.+/// each press is one undoable step with Bundle Arrow-Key Nudges off, a run of them one step with+/// it on (#2259, the default).#[test]fn arrow_keys_nudge_the_selection_outline() {use egui::Key;- for tool in [Tool::RectMarquee, Tool::EllipseMarquee] {+ for (tool, bundle) in [(Tool::RectMarquee, false), (Tool::EllipseMarquee, false), (Tool::RectMarquee, true), (Tool::EllipseMarquee, true)] {let mut h = harness(tool);+ h.state_mut().session.edit_prefs(|p| p.tools.bundle_nudges = bundle);press_at(&mut h, 100.0, 80.0, Modifiers::NONE);release_at(&mut h, 200.0, 160.0, Modifiers::NONE);let drawn = selection(&h);@@ -569,9 +571,15 @@ fn arrow_keys_nudge_the_selection_outline() {h.key_press_modifiers(Modifiers::SHIFT, Key::ArrowLeft);h.run_steps(1);assert_eq!(selection(&h), shifted(-9, 9), "{tool:?} shift-left 10 px");- assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 4, "one step per press");+ let nudges = h.state().session.active().unwrap().history.past_len() - steps;h.state_mut().session.undo();- assert_eq!(selection(&h), shifted(1, 9), "{tool:?} undo takes back one nudge");+ if bundle {+ assert_eq!(nudges, 1, "{tool:?} four quick presses, one step");+ assert_eq!(selection(&h), drawn, "{tool:?} undo takes back the run");+ } else {+ assert_eq!(nudges, 4, "{tool:?} one step per press");+ assert_eq!(selection(&h), shifted(1, 9), "{tool:?} undo takes back one nudge");+ }}}diff --git a/crates/ui-egui/src/move_mods.rs b/crates/ui-egui/src/move_mods.rsindex a9e5eeb78..64b3a6560 100644--- a/crates/ui-egui/src/move_mods.rs+++ b/crates/ui-egui/src/move_mods.rs@@ -8,7 +8,8 @@//! pointer actually moves, and the drag then moves the copies. Duplicate and move land as one//! history step ("Duplicate + Move"). ⇧⌥ combines both.//! - Arrow keys nudge the selected layers 1 px (⇧: 10 px); ⌥ duplicates first. While Free-//! Transform is active they nudge the box instead.+//! Transform is active they nudge the box instead. A run of nudges is one History state+//! (`nudge_bundle`, #2259).//! - With a selection the drag and the arrow keys move the selected pixels (`move_ui`): ⇧ locks//! the drag to multiples of 45° and ⌥ copies the pixels instead of duplicating the layer.//!@@ -185,6 +186,7 @@ pub fn arrow_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {for mods in [Modifiers::SHIFT | Modifiers::ALT, Modifiers::SHIFT, Modifiers::ALT, Modifiers::NONE] {if ctx.input_mut(|i| i.consume_key(base | mods, key)) {let k = if mods.shift { 10.0 } else { 1.0 };+ app.nudge_bundle.now = ctx.input(|i| i.time);nudge(app, ux * k, uy * k, mods.alt);return true;}@@ -218,13 +220,12 @@ fn brush_arrow_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {}/// Moves the selected layers (or the Free Transform box, or the selected pixels) by `(dx, dy)`-/// pixels, as the Move tool (also when ⌘ makes it the temporary Move tool).+/// pixels, as the Move tool (also when ⌘ makes it the temporary Move tool). Nudges that follow+/// each other are one History state, or one Undo step of the box (`nudge_bundle`); the selected+/// pixels float until dropped, which is one state already.pub fn nudge(app: &mut PhotocraftApp, dx: f64, dy: f64, duplicate_first: bool) {- if let Some(t) = app.ui.transform.as_mut() {- if t.warp.is_none() {- t.quad = t.quad.map(|q| [q[0] + dx, q[1] + dy]);- t.pivot = [t.pivot[0] + dx, t.pivot[1] + dy];- }+ if app.ui.transform.is_some() {+ crate::transform_tool::nudge(app, dx, dy);return;}if app.drag.is_some() {@@ -235,7 +236,14 @@ pub fn nudge(app: &mut PhotocraftApp, dx: f64, dy: f64, duplicate_first: bool) {return;}let from = if duplicate_first { duplicate(app) } else { None };- if let Err(e) = app.run("layer.translate", json!({"dx": dx, "dy": dy})) {+ let moved = if duplicate_first {+ // A copy is a state of its own, folded with its move below.+ app.nudge_bundle.reset();+ app.run("layer.translate", json!({"dx": dx, "dy": dy}))+ } else {+ crate::nudge_bundle::run(app, "layers", "layer.translate", json!({"dx": dx, "dy": dy}))+ };+ if let Err(e) = moved {app.ui.status = e;}if let Some(from) = from {@@ -244,9 +252,10 @@ pub fn nudge(app: &mut PhotocraftApp, dx: f64, dy: f64, duplicate_first: bool) {}/// Arrow keys with a selection tool (#1428), as in Photoshop: nudge the selection outline 1 px-/// (⇧ 10 px) through `select.transformSelection`, one history step per press; the pixels stay-/// put. A floating piece (⌘-dragged pixels) moves instead, like a plain drag on it. Not while a-/// drag, a polygon or a Magnetic Lasso border is in progress. Returns true when a key was used.+/// (⇧ 10 px) through `select.transformSelection`, a run of presses being one history step+/// (`nudge_bundle`); the pixels stay put. A floating piece (⌘-dragged pixels) moves instead, like+/// a plain drag on it. Not while a drag, a polygon or a Magnetic Lasso border is in progress.+/// Returns true when a key was used.fn selection_arrow_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {if !crate::tool_feedback::is_selection_tool(app.ui.tool) || app.drag.is_some() || !app.ui.polygon.is_empty() || app.ui.magnetic.active() {return false;@@ -263,8 +272,14 @@ fn selection_arrow_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {if ctx.input_mut(|i| i.consume_key(mods, key)) {let k = if mods.shift { 10.0 } else { 1.0 };let (dx, dy) = (ux * k, uy * k);- let id = if floating { "select.float" } else { "select.transformSelection" };- if let Err(e) = app.run(id, json!({"dx": dx, "dy": dy})) {+ app.nudge_bundle.now = ctx.input(|i| i.time);+ // A floating piece is no state until dropped; the outline's nudges bundle.+ let result = if floating {+ app.run("select.float", json!({"dx": dx, "dy": dy}))+ } else {+ crate::nudge_bundle::run(app, "selection", "select.transformSelection", json!({"dx": dx, "dy": dy}))+ };+ if let Err(e) = result {app.ui.status = e;app.ui.status_error = true;}@@ -420,8 +435,14 @@ mod tests {/// One key press through `arrow_keys`, as egui delivers it.fn press(app: &mut PhotocraftApp, key: egui::Key, mods: egui::Modifiers) -> bool {+ press_at(app, key, mods, 0.0)+ }++ /// [`press`] at egui time `time` (seconds).+ fn press_at(app: &mut PhotocraftApp, key: egui::Key, mods: egui::Modifiers, time: f64) -> bool {let ctx = egui::Context::default();ctx.input_mut(|i| {+ i.time = time;i.modifiers = mods;i.events.push(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: mods });});@@ -540,11 +561,13 @@ mod tests {assert!(!press(&mut app, egui::Key::ArrowRight, CTRL));}- /// #1428: with a selection tool the arrows nudge the selection outline (⇧ 10 px), one step- /// each; the layer stays put. Without a selection they are left alone.+ /// #1428: with a selection tool the arrows nudge the selection outline (⇧ 10 px); the layer+ /// stays put. Without a selection they are left alone. One step each with Bundle Arrow-Key+ /// Nudges off (#2259).#[test]fn arrow_keys_nudge_the_selection_with_a_selection_tool() {let mut app = app_with_layer();+ app.session.edit_prefs(|p| p.tools.bundle_nudges = false);let id = app.session.active().unwrap().active_layer.unwrap();app.ui.tool = Tool::Lasso;assert!(!press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE), "no selection: not used");@@ -561,4 +584,197 @@ mod tests {app.ui.polygon = vec![[1.0, 1.0]];assert!(!press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE));}+ fn history(app: &PhotocraftApp) -> usize {+ app.session.active().unwrap().history.past_len()+ }++ fn left_edge(app: &PhotocraftApp, id: photocraft_doc::LayerId) -> i32 {+ bounds(app, id).x0+ }++ /// #2259: tapping or holding an arrow key is one History state, so one Undo takes the whole+ /// run back (Photoshop folds a run of nudges into one "Move").+ #[test]+ fn a_run_of_arrow_nudges_is_one_history_step() {+ let mut app = app_with_layer();+ let id = app.session.active().unwrap().active_layer.unwrap();+ let h0 = history(&app);+ // Twelve taps, 0.2 s apart, then ⇧ for ten more px: still the same run.+ for i in 0..12 {+ assert!(press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 5.0 + 0.2 * f64::from(i)));+ }+ assert!(press_at(&mut app, egui::Key::ArrowDown, egui::Modifiers::SHIFT, 7.6));+ assert_eq!(bounds(&app, id), photocraft_geom::Rect::new(20, 18, 36, 34));+ assert_eq!(history(&app), h0 + 1, "thirteen presses, one state");+ assert_eq!(app.session.active().unwrap().history.undo_label(), Some("Move"));+ assert!(app.session.undo());+ assert_eq!(bounds(&app, id), photocraft_geom::Rect::new(8, 8, 24, 24), "one Undo takes back the run");+ assert!(app.session.redo());+ assert_eq!(bounds(&app, id), photocraft_geom::Rect::new(20, 18, 36, 34), "and one Redo does it again");+ }++ /// A pause longer than Nudge Bundle Pause starts a new run; a longer pause setting keeps it.+ #[test]+ fn a_pause_ends_the_run() {+ let mut app = app_with_layer();+ let id = app.session.active().unwrap().active_layer.unwrap();+ let h0 = history(&app);+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 1.0);+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 1.9);+ assert_eq!(history(&app), h0 + 1, "0.9 s: the same run");+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 3.0);+ assert_eq!(history(&app), h0 + 2, "1.1 s of quiet: a new run");+ app.session.edit_prefs(|p| p.tools.nudge_bundle_pause_ms = 5000);+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 7.0);+ assert_eq!(history(&app), h0 + 2, "4 s with a 5 s pause: the same run");+ assert_eq!(left_edge(&app, id), 12);+ assert!(app.session.undo());+ assert_eq!(left_edge(&app, id), 10, "Undo takes back the second run only");+ }++ /// With Bundle Arrow-Key Nudges off every press is a state, as before (#2259).+ #[test]+ fn every_press_is_a_step_with_bundling_off() {+ let mut app = app_with_layer();+ let id = app.session.active().unwrap().active_layer.unwrap();+ app.session.edit_prefs(|p| p.tools.bundle_nudges = false);+ let h0 = history(&app);+ for _ in 0..5 {+ assert!(press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE));+ }+ assert_eq!(history(&app), h0 + 5);+ assert!(app.session.undo());+ assert_eq!(left_edge(&app, id), 12, "one pixel back");+ // Turning it back on bundles the next run, which doesn't swallow the earlier steps.+ app.session.edit_prefs(|p| p.tools.bundle_nudges = true);+ for _ in 0..3 {+ press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE);+ }+ assert_eq!(history(&app), h0 + 5);+ assert_eq!(left_edge(&app, id), 15);+ }++ /// Any other change to the document ends the run: another edit, Undo, a different layer+ /// selected, a save.+ #[test]+ fn other_changes_end_the_run() {+ let mut app = app_with_layer();+ let a = app.session.active().unwrap().active_layer.unwrap();+ let tap = |app: &mut PhotocraftApp| assert!(press(app, egui::Key::ArrowRight, egui::Modifiers::NONE));+ let h0 = history(&app);+ tap(&mut app);+ tap(&mut app);+ assert_eq!(history(&app), h0 + 1);+ // An edit of another kind between two nudges.+ app.session.execute("layer.setProps", json!({"opacity": 0.5})).unwrap();+ tap(&mut app);+ tap(&mut app);+ assert_eq!(history(&app), h0 + 3, "nudges, the edit, nudges");+ // Undo ends it too: the next nudge is a state of its own, not folded into the one before.+ assert!(app.session.undo());+ tap(&mut app);+ assert_eq!(history(&app), h0 + 3);+ assert!(app.session.undo());+ assert_eq!(left_edge(&app, a), 10, "the new run was undone alone");+ // Saving keeps the saved state a step of its own.+ tap(&mut app);+ tap(&mut app);+ let before = history(&app);+ let st = app.session.active_mut().unwrap();+ st.saved_revision = st.revision;+ tap(&mut app);+ assert_eq!(history(&app), before + 1, "a save between two nudges ends the run");+ // Selecting another layer: the same keys now move that one, in a run of its own.+ let b = {+ app.session.execute("layer.new.layer", json!({})).unwrap();+ app.session.active().unwrap().active_layer.unwrap()+ };+ assert_ne!(a, b);+ let before = history(&app);+ app.session+ .edit("paint", |doc, active| {+ doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap().fill_rect(photocraft_geom::Rect::new(0, 0, 4, 4), &[0.0, 1.0, 0.0, 1.0]);+ Ok(())+ })+ .unwrap();+ tap(&mut app);+ app.session.select_layer(a).unwrap();+ tap(&mut app);+ assert_eq!(history(&app), before + 3, "paint, a nudge of the new layer, a nudge of the first");+ }++ /// ⌥ copies, so ⌥-nudges are never folded into a run (the copy is part of each step).+ #[test]+ fn alt_nudges_do_not_join_a_run() {+ let mut app = app_with_layer();+ let h0 = history(&app);+ press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE);+ press(&mut app, egui::Key::ArrowRight, egui::Modifiers::ALT);+ press(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE);+ assert_eq!(history(&app), h0 + 3);+ assert_eq!(app.session.active().unwrap().history.undo_label(), Some("Move"), "the run after the copy is a state of its own");+ }++ /// #2259: nudges of the selection outline bundle the same way.+ #[test]+ fn selection_outline_nudges_bundle_into_one_step() {+ let mut app = app_with_layer();+ app.ui.tool = Tool::Lasso;+ app.session.execute("select.rect", json!({"x": 4, "y": 4, "width": 10, "height": 10})).unwrap();+ let sel = |app: &PhotocraftApp| app.session.active().unwrap().doc.selection.as_ref().unwrap().content_bounds();+ let h0 = history(&app);+ for i in 0..5 {+ assert!(press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 2.0 + 0.1 * f64::from(i)));+ }+ assert!(press_at(&mut app, egui::Key::ArrowDown, egui::Modifiers::SHIFT, 2.6));+ assert_eq!(sel(&app), photocraft_geom::Rect::new(9, 14, 19, 24));+ assert_eq!(history(&app), h0 + 1);+ assert!(app.session.undo());+ assert_eq!(sel(&app), photocraft_geom::Rect::new(4, 4, 14, 14), "Undo takes the outline back where it was drawn");+ // The layer nudge and the outline nudge are different runs even back to back.+ app.session.execute("select.deselect", json!({})).unwrap();+ app.ui.tool = Tool::Move;+ let h1 = history(&app);+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 3.0);+ assert_eq!(history(&app), h1 + 1);+ }++ /// Free Transform: nudges of the box that follow each other are one Undo step of the session+ /// (it has its own history); a drag or a pause starts another.+ #[test]+ fn free_transform_nudges_bundle_into_one_undo_step() {+ let mut app = app_with_layer();+ let ctx = egui::Context::default();+ crate::transform_tool::begin(&mut app, &ctx).unwrap();+ let quad = |app: &PhotocraftApp| app.ui.transform.as_ref().unwrap().quad;+ let q0 = quad(&app);+ let moved = |dx: f64, dy: f64| q0.map(|q| [q[0] + dx, q[1] + dy]);+ let settle = |app: &mut PhotocraftApp| crate::transform_tool::track_steps(app, &ctx);+ for i in 0..6 {+ assert!(press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 4.0 + 0.1 * f64::from(i)));+ settle(&mut app);+ }+ assert_eq!(quad(&app), moved(6.0, 0.0));+ // A pause, and the next nudge is a step of its own.+ assert!(press_at(&mut app, egui::Key::ArrowDown, egui::Modifiers::NONE, 9.0));+ settle(&mut app);+ assert_eq!(+ quad(&app),+ [[q0[0][0] + 6.0, q0[0][1] + 1.0], [q0[1][0] + 6.0, q0[1][1] + 1.0], [q0[2][0] + 6.0, q0[2][1] + 1.0], [q0[3][0] + 6.0, q0[3][1] + 1.0]]+ );+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(quad(&app), moved(6.0, 0.0), "Undo takes back the late nudge only");+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(quad(&app), q0, "and the next one the six that were bundled");+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(quad(&app), q0, "nothing is left of the session to undo");+ // With bundling off every nudge is a step.+ app.session.edit_prefs(|p| p.tools.bundle_nudges = false);+ for i in 0..3 {+ press_at(&mut app, egui::Key::ArrowRight, egui::Modifiers::NONE, 20.0 + 0.1 * f64::from(i));+ settle(&mut app);+ }+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(quad(&app), moved(2.0, 0.0));+ }}diff --git a/crates/ui-egui/src/nudge_bundle.rs b/crates/ui-egui/src/nudge_bundle.rsnew file mode 100644index 000000000..87746c716--- /dev/null+++ b/crates/ui-egui/src/nudge_bundle.rs@@ -0,0 +1,167 @@+//! Arrow-key nudges that follow each other are one History state (#2259).+//!+//! Tapping or holding an arrow key nudges the selected layers (or the selection outline) one+//! pixel at a time. One state per pixel buries the History panel and makes one Undo take back a+//! single pixel, so a run of nudges of the same thing shares one `coalesce` key (the engine folds+//! edits with the same key into one step, see `Session::execute`) and Undo takes back the run.+//!+//! A run lasts while each nudge comes within the Tools › Nudge Bundle Pause of the one before it+//! (longer than a key's auto-repeat delay, so a held key is one run) and nothing else happened+//! to the document in between: another edit, an Undo or Redo, a different layer selected or a+//! save each end it. Tools › Bundle Arrow-Key Nudges off gives every press its own state.+//!+//! [`NudgeBundle`] only decides which run a nudge belongs to; it reads the clock from the key+//! handlers ([`NudgeBundle::now`]) and the document from the caller, so it is tested without egui.++use serde_json::{Value, json};++use crate::PhotocraftApp;+use photocraft_doc::DocId;+use photocraft_engine::DocState;++/// What a run of nudges needs to find unchanged to go on: the document, and its revisions (every+/// edit, Undo, Redo and layer selection moves `revision`, a save moves `saved_revision`).+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) struct Seen {+ doc: DocId,+ revision: u64,+ saved_revision: u64,+}++impl Seen {+ pub(crate) fn of(st: &DocState) -> Self {+ Self { doc: st.doc.id, revision: st.revision, saved_revision: st.saved_revision }+ }+}++/// The latest nudge: the run it belongs to, what it nudged, when, and the document it left.+#[derive(Clone, Debug)]+struct Last {+ run: u64,+ what: String,+ at: f64,+ left: Seen,+}++/// The run the arrow-key nudges belong to (one per app; a nudge always goes to the active+/// document, whose state it checks).+#[derive(Clone, Debug, Default)]+pub struct NudgeBundle {+ /// egui time (seconds) of the key press being handled; the arrow-key handlers set it.+ pub(crate) now: f64,+ /// Runs started so far; a run's number is part of its `coalesce` key.+ started: u64,+ last: Option<Last>,+}++impl NudgeBundle {+ /// The run a nudge of `what` now joins: the latest one when it was `what` too, came at most+ /// `pause` seconds ago and left the document as `seen`; else a new run.+ pub(crate) fn join(&mut self, what: &str, seen: Seen, pause: f64) -> u64 {+ if let Some(l) = &self.last+ && l.what == what+ && l.left == seen+ && self.now >= l.at+ && self.now - l.at <= pause+ {+ return l.run;+ }+ self.started += 1;+ self.started+ }++ /// The nudge of `run` ran and left the document as `left`.+ pub(crate) fn record(&mut self, run: u64, what: &str, left: Seen) {+ self.last = Some(Last { run, what: what.to_string(), at: self.now, left });+ }++ /// The next nudge starts a new run.+ pub(crate) fn reset(&mut self) {+ self.last = None;+ }+}++/// The longest pause (seconds) between two nudges of one run, or `None` when nudges aren't+/// bundled (Tools › Bundle Arrow-Key Nudges).+pub(crate) fn pause(app: &PhotocraftApp) -> Option<f64> {+ let tools = &app.session.prefs().tools;+ tools.bundle_nudges.then(|| f64::from(tools.nudge_bundle_pause_ms) / 1000.0)+}++/// Run the nudge command `id` (`what` names the thing it nudges: "layers", "selection") as part+/// of the current run of nudges, or on its own when nudges aren't bundled.+pub(crate) fn run(app: &mut PhotocraftApp, what: &str, id: &str, mut params: Value) -> Result<Value, String> {+ let Some(pause) = pause(app) else {+ app.nudge_bundle.reset();+ return app.run(id, params);+ };+ let Some(st) = app.session.active() else { return app.run(id, params) };+ // The same keys nudge whatever is selected: another selection is another run.+ let what = format!("{what}:{:?}:{:?}", st.active_layer, st.selected_layers);+ let run = app.nudge_bundle.join(&what, Seen::of(st), pause);+ if let Some(object) = params.as_object_mut() {+ object.insert("coalesce".into(), json!(format!("nudge:{run}")));+ }+ let result = app.run(id, params);+ match (&result, app.session.active()) {+ (Ok(_), Some(st)) => app.nudge_bundle.record(run, &what, Seen::of(st)),+ _ => app.nudge_bundle.reset(),+ }+ result+}++#[cfg(test)]+mod tests {+ use super::*;++ fn seen(revision: u64) -> Seen {+ Seen { doc: DocId(1), revision, saved_revision: 0 }+ }++ fn at(b: &mut NudgeBundle, t: f64) {+ b.now = t;+ }++ #[test]+ fn nudges_within_the_pause_share_a_run() {+ let mut b = NudgeBundle::default();+ at(&mut b, 10.0);+ let first = b.join("layers", seen(1), 1.0);+ b.record(first, "layers", seen(2));+ at(&mut b, 10.9);+ assert_eq!(b.join("layers", seen(2), 1.0), first, "0.9 s later is the same run");+ b.record(first, "layers", seen(3));+ // The pause counts from the latest nudge, so a long run goes on while the keys do.+ at(&mut b, 11.8);+ assert_eq!(b.join("layers", seen(3), 1.0), first);+ b.record(first, "layers", seen(4));+ at(&mut b, 12.9);+ assert_ne!(b.join("layers", seen(4), 1.0), first, "1.1 s of quiet ends the run");+ }++ #[test]+ fn anything_else_ends_the_run() {+ let mut b = NudgeBundle::default();+ at(&mut b, 1.0);+ let run = b.join("layers", seen(1), 1.0);+ b.record(run, "layers", seen(2));+ let new = |b: &mut NudgeBundle, what: &str, s: Seen| b.join(what, s, 1.0) != run;+ assert!(new(&mut b, "layers", seen(3)), "an edit, Undo or Redo moved the revision");+ assert!(new(&mut b, "selection", seen(2)), "another thing is nudged");+ assert!(new(&mut b, "layers", Seen { doc: DocId(2), ..seen(2) }), "another document");+ assert!(new(&mut b, "layers", Seen { saved_revision: 2, ..seen(2) }), "a save keeps the saved state a step of its own");+ assert!(!new(&mut b, "layers", seen(2)), "nothing happened: the same run");+ // The clock never runs backwards in a real session; if it did, that is not a run.+ at(&mut b, 0.5);+ assert!(new(&mut b, "layers", seen(2)));+ }++ #[test]+ fn reset_ends_the_run() {+ let mut b = NudgeBundle::default();+ let run = b.join("layers", seen(1), 1.0);+ b.record(run, "layers", seen(2));+ b.reset();+ assert_ne!(b.join("layers", seen(2), 1.0), run);+ }+}diff --git a/crates/ui-egui/src/nudge_bundle_tests.rs b/crates/ui-egui/src/nudge_bundle_tests.rsnew file mode 100644index 000000000..d18bbddaf--- /dev/null+++ b/crates/ui-egui/src/nudge_bundle_tests.rs@@ -0,0 +1,123 @@+//! #2259: arrow-key nudges through the whole app (panels, shortcuts, the real frame loop and its+//! clock) are one History state per run, and Undo takes the run back.++use egui_kittest::Harness;+use photocraft_geom::Rect;+use serde_json::json;++use crate::PhotocraftApp;+use crate::state::Tool;++fn harness() -> Harness<'static, PhotocraftApp> {+ let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_max_steps(64).build_eframe(|cc| {+ PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({"width": 200, "height": 200})).unwrap();+ app.run("layer.new.layer", json!({})).unwrap();+ app.run("select.rect", json!({"x": 40, "y": 40, "width": 20, "height": 20})).unwrap();+ app.run("edit.fill", json!({"color": "#ff0000"})).unwrap();+ app.run("select.deselect", json!({})).unwrap();+ app.ui.tool = Tool::Move;+ app+ });+ h.run_steps(6);+ h+}++fn bounds(h: &Harness<'_, PhotocraftApp>) -> Rect {+ let st = h.state().session.active().unwrap();+ st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().content_bounds()+}++fn steps(h: &Harness<'_, PhotocraftApp>) -> usize {+ h.state().session.active().unwrap().history.past_len()+}++fn nudge(h: &mut Harness<'_, PhotocraftApp>, key: egui::Key, frames: usize) {+ h.key_press(key);+ h.run_steps(frames);+}++#[test]+fn tapping_an_arrow_key_ten_times_is_one_history_step() {+ let mut h = harness();+ let (start, n0) = (bounds(&h), steps(&h));+ for _ in 0..10 {+ nudge(&mut h, egui::Key::ArrowRight, 1);+ }+ assert_eq!(bounds(&h).x0, start.x0 + 10);+ assert_eq!(steps(&h), n0 + 1, "ten taps, one state");+ let entries = h.state().session.active().unwrap().history.entries();+ assert_eq!(entries.last().map(String::as_str), Some("Move"));+ assert_eq!(entries.iter().filter(|e| *e == "Move").count(), 1);+ h.state_mut().session.undo();+ assert_eq!(bounds(&h), start, "one Undo takes all ten pixels back");+}++#[test]+fn a_held_key_is_one_history_step() {+ let mut h = harness();+ let (start, n0) = (bounds(&h), steps(&h));+ nudge(&mut h, egui::Key::ArrowDown, 1);+ // The key stays down: the OS repeats it after a pause of about half a second.+ h.run_steps(2);+ for _ in 0..15 {+ h.event(egui::Event::Key { key: egui::Key::ArrowDown, physical_key: None, pressed: true, repeat: true, modifiers: egui::Modifiers::NONE });+ h.run_steps(1);+ }+ h.event(egui::Event::Key { key: egui::Key::ArrowDown, physical_key: None, pressed: false, repeat: false, modifiers: egui::Modifiers::NONE });+ h.run_steps(1);+ assert_eq!(bounds(&h).y0, start.y0 + 16);+ assert_eq!(steps(&h), n0 + 1);+ h.state_mut().session.undo();+ assert_eq!(bounds(&h), start);+}++#[test]+fn a_pause_starts_a_new_step_and_the_preference_sets_how_long() {+ let mut h = harness();+ let n0 = steps(&h);+ nudge(&mut h, egui::Key::ArrowRight, 1);+ nudge(&mut h, egui::Key::ArrowRight, 1);+ // The test clock runs a quarter of a second per frame: eight frames is two seconds of quiet.+ h.run_steps(8);+ nudge(&mut h, egui::Key::ArrowRight, 1);+ assert_eq!(steps(&h), n0 + 2, "two seconds of quiet end the run");+ h.state_mut().run("prefs.set", json!({"path": "tools.nudgeBundlePauseMs", "value": 5000})).unwrap();+ h.run_steps(8);+ nudge(&mut h, egui::Key::ArrowRight, 1);+ assert_eq!(steps(&h), n0 + 2, "with a five second pause, two seconds of quiet go on with the run");+ h.run_steps(24);+ nudge(&mut h, egui::Key::ArrowRight, 1);+ assert_eq!(steps(&h), n0 + 3, "six seconds of quiet end it");+}++#[test]+fn the_preference_turns_bundling_off_and_on_again() {+ let mut h = harness();+ let (start, n0) = (bounds(&h), steps(&h));+ h.state_mut().run("prefs.set", json!({"path": "tools.bundleNudges", "value": false})).unwrap();+ for _ in 0..4 {+ nudge(&mut h, egui::Key::ArrowRight, 1);+ }+ assert_eq!(steps(&h), n0 + 4, "a state per press");+ h.state_mut().session.undo();+ assert_eq!(bounds(&h).x0, start.x0 + 3);+ h.state_mut().run("prefs.set", json!({"path": "tools.bundleNudges", "value": true})).unwrap();+ for _ in 0..4 {+ nudge(&mut h, egui::Key::ArrowRight, 1);+ }+ assert_eq!(steps(&h), n0 + 4, "the next four bundle: 3 earlier states and one run");+ assert_eq!(bounds(&h).x0, start.x0 + 7);+}++/// Bad values are rejected, not stored (the control channel and the Preferences dialog share the+/// same ranges).+#[test]+fn the_pause_preference_stays_within_its_range() {+ let mut h = harness();+ for bad in [json!(0), json!(99), json!(10_001), json!("long"), json!(-5)] {+ assert!(h.state_mut().run("prefs.set", json!({"path": "tools.nudgeBundlePauseMs", "value": bad.clone()})).is_err(), "{bad}");+ }+ assert_eq!(h.state().session.prefs().tools.nudge_bundle_pause_ms, 1000);+}diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rsindex 1e8572c60..808a18147 100644--- a/crates/ui-egui/src/prefs_ui.rs+++ b/crates/ui-egui/src/prefs_ui.rs@@ -1070,6 +1070,13 @@ fn humanize(key: &str) -> String {if key == "notificationDurationSeconds" {return "Notification Duration (seconds)".into();}+ // Tools: arrow-key nudges bundle into one History state (#2259).+ if key == "bundleNudges" {+ return "Bundle Arrow-Key Nudges".into();+ }+ if key == "nudgeBundlePauseMs" {+ return "Nudge Bundle Pause (ms)".into();+ }let mut s = String::new();for (i, ch) in key.chars().enumerate() {if i == 0 {@@ -1317,6 +1324,11 @@ fn export_field_visible(obj: &Map<String, Value>, key: &str) -> bool {}}+/// The pause that bundles arrow-key nudges means nothing with Bundle Arrow-Key Nudges off (#2259).+fn tools_field_visible(obj: &Map<String, Value>, key: &str) -> bool {+ key != "nudgeBundlePauseMs" || obj.get("bundleNudges").and_then(Value::as_bool) != Some(false)+}+/// One theme as a Color Theme swatch: its panel colour under a chrome strip with an accent dot,/// outlined when chosen. The name is the tooltip and the accessible label. A star badge on its/// corner adds the theme to (or removes it from) the favourites listed by the appearance@@ -1501,7 +1513,8 @@ fn field_visible(section: &str, obj: &Map<String, Value>, k: &str, query: &str)// View › Rulers (⌘R) sets it, as in Photoshop.|| path == "unitsAndRulers.showRulers"|| (section == "performance" && matches!(k, "useGpu" | "gpuBackend" | "renderingMode"))- || (section == "export" && !export_field_visible(obj, k));+ || (section == "export" && !export_field_visible(obj, k))+ || (section == "tools" && !tools_field_visible(obj, k));(query.is_empty() || preference_matches(section, k, query))&& !drawn_elsewhere&& !prefs::is_hidden(&path)@@ -2213,6 +2226,21 @@ mod tests {assert_eq!(humanize("webpQuality"), "Quality");}+ #[test]+ fn the_nudge_pause_is_hidden_while_nudges_are_not_bundled() {+ let mut tools = Map::new();+ tools.insert("bundleNudges".into(), json!(true));+ assert!(tools_field_visible(&tools, "nudgeBundlePauseMs"));+ assert!(tools_field_visible(&tools, "bundleNudges"));+ tools.insert("bundleNudges".into(), json!(false));+ assert!(!tools_field_visible(&tools, "nudgeBundlePauseMs"));+ assert!(tools_field_visible(&tools, "bundleNudges") && tools_field_visible(&tools, "showTooltips"));+ // A section without the flag (an older preferences object) shows the field.+ assert!(tools_field_visible(&Map::new(), "nudgeBundlePauseMs"));+ assert_eq!(humanize("bundleNudges"), "Bundle Arrow-Key Nudges");+ assert_eq!(humanize("nudgeBundlePauseMs"), "Nudge Bundle Pause (ms)");+ }+#[test]fn rendering_mode_display_respects_explicit_mode_and_legacy_disable() {let legacy = serde_json::json!({"useGpu": false, "gpuBackend": "auto"});diff --git a/crates/ui-egui/src/transform_tool.rs b/crates/ui-egui/src/transform_tool.rsindex 69ad33cbc..d35aac904 100644--- a/crates/ui-egui/src/transform_tool.rs+++ b/crates/ui-egui/src/transform_tool.rs@@ -145,14 +145,32 @@ struct Steps {settled: Option<Step>,undo: Vec<Step>,redo: Vec<Step>,+ /// When the latest arrow-key nudge came (egui time) and the box it left.+ nudged: Option<(f64, Step)>,+ /// The nudge that moved the box since it last came to rest follows another one closely: it+ /// joins that one's step instead of adding its own (#2259).+ fold: bool,}impl Steps {+ /// An arrow-key nudge at `now` moved the box from `before` to `after`. With `pause` (seconds,+ /// `None`: nudges aren't bundled) it folds into the previous nudge's step when it came within+ /// that time of it and found the box as that nudge left it, so a drag, an option edit, Undo+ /// or Redo in between start a step of their own.+ fn nudged(&mut self, before: &Step, after: Step, now: f64, pause: Option<f64>) {+ self.fold = pause.is_some_and(|w| self.nudged.as_ref().is_some_and(|(at, left)| left == before && now >= *at && now - at <= w));+ self.nudged = pause.map(|_| (now, after));+ }+/// Record a step if the box changed since it last came to rest.fn settle(&mut self, now: Step) {if self.settled.as_ref() == Some(&now) {return;}+ if std::mem::take(&mut self.fold) && self.settled.is_some() {+ self.settled = Some(now);+ return;+ }if let Some(prev) = self.settled.replace(now) {self.undo.push(prev);self.redo.clear();@@ -1191,11 +1209,26 @@ fn start_steps(app: &mut PhotocraftApp) {pub fn track_steps(app: &mut PhotocraftApp, ctx: &egui::Context) {let (Some(t), Some(pv)) = (&app.ui.transform, app.transform_preview.as_mut()) else { return };if pv.gesture.is_some() || pv.warp_drag.is_some() || ctx.input(|i| i.pointer.any_down()) || ctx.text_edit_focused() {+ // Whatever comes to rest after this is more than the nudge.+ pv.steps.fold = false;return;}pv.steps.settle(Step::of(t));}+/// Arrow keys while Free Transform is active: move the box (and its pivot) by `(dx, dy)`.+/// Nudges that follow each other closely are one Undo step of the session (`nudge_bundle`).+pub(crate) fn nudge(app: &mut PhotocraftApp, dx: f64, dy: f64) {+ let (pause, now) = (crate::nudge_bundle::pause(app), app.nudge_bundle.now);+ let Some(t) = app.ui.transform.as_mut().filter(|t| t.warp.is_none()) else { return };+ let before = Step::of(t);+ t.quad = t.quad.map(|q| [q[0] + dx, q[1] + dy]);+ t.pivot = [t.pivot[0] + dx, t.pivot[1] + dy];+ if let Some(pv) = app.transform_preview.as_mut() {+ pv.steps.nudged(&before, Step::of(t), now, pause);+ }+}+/// While transforming, Undo and Redo apply to the box: `Some(enabled)` for those commands (and/// Toggle Last State, which would change the document under the box), `None` for the rest.pub fn is_enabled(app: &PhotocraftApp, id: &str) -> Option<bool> {diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 582a9aa9a..3ad389200 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -235,8 +235,11 @@ Values the app honours live: history states (every open document), effect-cachetheme, canvas colour and border, checkerboard size and colours (CPU and GPU canvas), gamut warningcolour and opacity, guide/grid/smart-guide colours and styles, grid spacing and subdivisions, rulerunits (rulers, Info panel, Image Size default unit), image interpolation (Image Size default),-painting and other cursors, zoom with scroll wheel, Use Shift Key for Tool Switch, keyboard-shortcuts, hidden and coloured menu items, autosave interval and crash recovery, and the history+painting and other cursors, zoom with scroll wheel, Use Shift Key for Tool Switch, Bundle Arrow-Key+Nudges and Nudge Bundle Pause (arrow keys sent with `ui.key` that follow each other within the pause+nudge the layers, selection outline or Free Transform box as one history step; an agent calling+`layer.translate` or `select.transformSelection` itself gets the same with a shared `coalesce` key),+keyboard shortcuts, hidden and coloured menu items, autosave interval and crash recovery, and the historylog text file. GPU on/off and the GPU tile size apply at the next launch.The desktop app stores them in `preferences.json` in the platform config directory (macOSdiff --git a/docs/scorecard.md b/docs/scorecard.mdindex cac2b640f..fe9c144ba 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -8,8 +8,8 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js|---|---:|---:|---:|---|| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 185/256, round trip ≥ 258/256 |-| [Tools](#tools) | 32 | 11 | 0 | |-| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 162 (target 0) |+| [Tools](#tools) | 33 | 11 | 0 | |+| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 164 (target 0) || [Type](#type) | 4 | 3 | 2 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -172,11 +172,12 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t| TOOL-214-23 | Crop: Photoshop's default mode (the image turns and moves behind an upright box, Auto Center Preview keeps a resized box's centre in place and centres a drawn one) and Use Classic Mode (P) in the gear menu | done | [#1919](https://github.com/storytold/photocraft/issues/1919) | crop_mode.rs: the crop model (crop_rect + crop_angle) and image.crop are shared by both modes; default mode sets the view's rotation to -crop_angle while the tool shows a frame (picking the tool, in either mode, turns a Rotate View turn upright about the view centre, not restored after Enter/Esc or by P; Classic Mode keeps the camera upright with the frame drawn turned; as Photoshop 25.1), pivoting so the box stays put, moves view and frame together for drags inside and arrow keys, keeps a resized box's centre in place live (Auto Center Preview; a drawn box is centred on release, a moved one never), readout = the image's turn; gear menu order and Classic Mode greying as Photoshop 25.1; CropShield classic_mode / auto_center_preview (ui.set cropShield), P ahead of the Pen key || TOOL-1053-1 | Shape stroke controls: solid/dashed/dotted, custom dash/gap/offset, caps, joins, alignment, miter limit and opacity | done | [#1053](https://github.com/storytold/photocraft/issues/1053) | shape_stroke_ui.rs: shared staged editor, renderer samples, cached Properties canvas preview; existing shape.create/edit/info; serde tool defaults, ui.set shapeStroke; pcraft and vstk style round trips. Gradient fill UI and saved stroke libraries remain open; Line retains filled-bar geometry || TOOL-213-19 | Remove tool: paint over an object (or circle it) and it is filled from its surroundings | partial | [#213](https://github.com/storytold/photocraft/issues/213) | paint.remove (retouch_cmds/remove.rs, background job) + Tool::Remove in the J flyout; loops close over what they enclose; fill by non-local patch completion with texture features, onion-peel start, best-patch copy and gradient-domain seam hiding (algo/nonlocal.rs, Newson et al. IPOL 2017); sparse holes in tiles (algo/remove.rs). remove_quality on 20 holes in public-domain photos: the fill keeps 0.89 of the texture it replaces (0.54 with Content-Aware Fill's completion), edge gradient 1.03 of the original's; remove_bench 24 MP: 100 px ring 120 ms, 1000 px ring 2.5 s, 3000 px line 1.7 s. Options bar: Sample All Layers, Create a new layer (the fill on a new layer above, `newLayer`), Remove after each stroke off (strokes collect as a tint and ↩ applies them as one `strokes` job, Esc drops them). Missing: generative AI mode, live preview of the result |+| TOOL-2259-1 | Arrow-key nudges of one thing (layers, the selection outline, the Free Transform box) that follow each other are one History state, with a preference to turn it off | done | [#2259](https://github.com/storytold/photocraft/issues/2259) | nudge_bundle.rs: a run shares one `coalesce` key while each nudge comes within Tools > Nudge Bundle Pause (1 s) and nothing else touched the document (an edit, Undo/Redo, a layer selection, a save end it); move_mods.rs runs layer.translate and select.transformSelection through it, transform_tool.rs folds box nudges into one session step. Tools > Bundle Arrow-Key Nudges off gives every press its own state. Selected pixels float until dropped, which is one state already; ⌥-nudges (a copy each) never join a run || TOOL-1045-1 | Color Replacement tool on the toolbar | done | [#1045](https://github.com/storytold/photocraft/issues/1045) | Tool::ColorReplacement in the Brush (B) flyout after the Mixer Brush; Mode/Sampling/Limits/Tolerance/Anti-alias options drive paint.colorReplacement with the foreground colour; live preview (LiveDab with the stroke's finishing dab), one History step; color_replacement_tests.rs |## Workspace and UI-**Settings that do nothing: 26 of 162** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.+**Settings that do nothing: 26 of 164** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.diff --git a/scorecard/tools.toml b/scorecard/tools.tomlindex ac7b43368..51f6b1cf3 100644--- a/scorecard/tools.toml+++ b/scorecard/tools.toml@@ -299,6 +299,13 @@ status = "partial"issue = 213note = "paint.remove (retouch_cmds/remove.rs, background job) + Tool::Remove in the J flyout; loops close over what they enclose; fill by non-local patch completion with texture features, onion-peel start, best-patch copy and gradient-domain seam hiding (algo/nonlocal.rs, Newson et al. IPOL 2017); sparse holes in tiles (algo/remove.rs). remove_quality on 20 holes in public-domain photos: the fill keeps 0.89 of the texture it replaces (0.54 with Content-Aware Fill's completion), edge gradient 1.03 of the original's; remove_bench 24 MP: 100 px ring 120 ms, 1000 px ring 2.5 s, 3000 px line 1.7 s. Options bar: Sample All Layers, Create a new layer (the fill on a new layer above, `newLayer`), Remove after each stroke off (strokes collect as a tint and ↩ applies them as one `strokes` job, Esc drops them). Missing: generative AI mode, live preview of the result"+[[item]]+id = "TOOL-2259-1"+target = "Arrow-key nudges of one thing (layers, the selection outline, the Free Transform box) that follow each other are one History state, with a preference to turn it off"+status = "done"+issue = 2259+note = "nudge_bundle.rs: a run shares one `coalesce` key while each nudge comes within Tools > Nudge Bundle Pause (1 s) and nothing else touched the document (an edit, Undo/Redo, a layer selection, a save end it); move_mods.rs runs layer.translate and select.transformSelection through it, transform_tool.rs folds box nudges into one session step. Tools > Bundle Arrow-Key Nudges off gives every press its own state. Selected pixels float until dropped, which is one state already; ⌥-nudges (a copy each) never join a run"+[[item]]id = "TOOL-1045-1"target = "Color Replacement tool on the toolbar"