Merge pull request #7908 from dotCooCoo/feat/palette-recent-commands

Command Palette: a Recent Commands list beside the search field runs the last five picks again
This commit is contained in:
BFlat
2026-11-16 09:32:53 +07:00
committed by GitHub
32 changed files with 435 additions and 13 deletions
+2
View File
@@ -3176,6 +3176,8 @@ digits Malayalam Малаялам
Search All Търсене във всички
Search commands and tools Търсене на команди и инструменти
Search commands and tools… Търсене на команди и инструменти…
Recent Commands Последни команди
No recent commands Няма последни команди
Search Commands… Търсене на команди…
Secondary Вторичен
Section Symbol Символ за раздел
Can't render this file because it is too large.
+2
View File
@@ -4370,6 +4370,8 @@ font-technology Variable Varijabilni
Saving Čuvanje
Saving {} Čuvanje {}
Search commands and tools… Pretraži naredbe i alate…
Recent Commands Nedavne naredbe
No recent commands Nema nedavnih naredbi
Dashed Line Isprekidana linija
Panel menu Meni panela
Unembed… Poništi ugrađivanje…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -4103,6 +4103,8 @@ digits Malayalam Malaiàlam
Search All Cerca a tot
Search commands and tools Cerca ordres i eines
Search commands and tools… Cerca ordres i eines…
Recent Commands Ordres recents
No recent commands No hi ha ordres recents
Search Commands… Cerca ordres…
Search Fonts Folder Cerca a la carpeta de tipus de lletra
Searching… Cercant…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -4475,6 +4475,8 @@ font-technology Variable Variabilní
Saving Ukládání
Saving {} Ukládání {}
Search commands and tools… Hledat příkazy a nástroje…
Recent Commands Nedávné příkazy
No recent commands Žádné nedávné příkazy
Dashed Line Čárkovaná čára
Panel menu Nabídka panelu
Unembed… Zrušit vložení…
Can't render this file because it is too large.
+2
View File
@@ -6809,6 +6809,8 @@ font-technology Variable Variable
Saving Gemmer
Saving {} Gemmer {}
Search commands and tools… Søg i kommandoer og værktøjer…
Recent Commands Seneste kommandoer
No recent commands Ingen seneste kommandoer
Dashed Line Stiplet linje
Panel menu Panelmenu
Unembed… Ophæv integrering…
Can't render this file because it is too large.
+2
View File
@@ -3240,6 +3240,8 @@ digits Malayalam Malayalam
@msg `{key}` must be an array of these names: {_1} `{key}` muss ein Array mit diesen Namen sein: {_1}
Search commands and tools Befehle und Werkzeuge suchen
Search commands and tools… Befehle und Werkzeuge suchen…
Recent Commands Zuletzt verwendete Befehle
No recent commands Keine zuletzt verwendeten Befehle
Search Commands… Befehle suchen…
Secondary Sekundär
Section Symbol Paragrafenzeichen
Can't render this file because it is too large.
+2
View File
@@ -3903,6 +3903,8 @@ digits Malayalam Μαλαγιάλαμ
Search All Αναζήτηση όλων
Search commands and tools Αναζήτηση εντολών και εργαλείων
Search commands and tools… Αναζήτηση εντολών και εργαλείων…
Recent Commands Πρόσφατες εντολές
No recent commands Δεν υπάρχουν πρόσφατες εντολές
Search Commands… Αναζήτηση εντολών…
Secondary Δευτερεύον
Section Symbol Σύμβολο ενότητας
Can't render this file because it is too large.
+2
View File
@@ -3274,6 +3274,8 @@ digits Malayalam Malayálam
@msg `{key}` must be an array of these names: {_1} `{key}` debe ser una lista de estos nombres: {_1}
Search commands and tools Buscar comandos y herramientas
Search commands and tools… Buscar comandos y herramientas…
Recent Commands Comandos recientes
No recent commands No hay comandos recientes
Search Commands… Buscar comandos…
Secondary Secundario
Section Symbol Símbolo de sección
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -4394,6 +4394,8 @@ font-technology Variable Muuttuvat
Saving Tallennetaan
Saving {} Tallennetaan {}
Search commands and tools… Hae komentoja ja työkaluja…
Recent Commands Viimeisimmät komennot
No recent commands Ei viimeisimpiä komentoja
Dashed Line Katkoviiva
Panel menu Paneelivalikko
Unembed… Poista upotus…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -3266,6 +3266,8 @@ digits Malayalam Malayalam
@msg `{key}` must be an array of these names: {_1} `{key}` doit être un tableau de noms parmi {_1}
Search commands and tools Chercher commandes et outils
Search commands and tools… Chercher commandes et outils…
Recent Commands Commandes récentes
No recent commands Aucune commande récente
Search Commands… Rechercher des commandes…
Secondary Secondaire
Section Symbol Symbole de section
Can't render this file because it is too large.
+2
View File
@@ -3364,6 +3364,8 @@
Search Preferences પસંદગીઓ શોધો
Search commands and tools આદેશો અને ટૂલ્સ શોધો
Search commands and tools… આદેશો અને ટૂલ્સ શોધો…
Recent Commands તાજેતરના આદેશો
No recent commands કોઈ તાજેતરના આદેશો નથી
Search images છબીઓ શોધો
Searching… શોધી રહ્યા છીએ…
Secondary ગૌણ
Can't render this file because it contains an unexpected character in line 72 and column 5.
+2
View File
@@ -4454,6 +4454,8 @@ antiAlias Sharp शार्प
Search artboards खोज आर्टबोर्ड
Search commands and tools खोज आदेश और टूल
Search commands and tools… आदेश और टूल खोजें…
Recent Commands हाल के आदेश
No recent commands कोई हाल का आदेश नहीं
Search Commands… कमांड खोजें…
Search Fonts Folder खोज फ़ॉन्ट फ़ोल्डर
Search images इमेज खोजना
Can't render this file because it is too large.
+2
View File
@@ -3894,6 +3894,8 @@ mark-style Japanese Japán
@msg `{key}` must be an array of these names: {_1} `{key}`: ezen nevek tömbje kell: {_1}
Search commands and tools Parancsok és eszközök keresése
Search commands and tools… Parancsok és eszközök keresése…
Recent Commands Legutóbbi parancsok
No recent commands Nincsenek legutóbbi parancsok
Search Commands… Parancsok keresése…
Search Fonts Folder Keresés betűtípusmappában
Searching… Keresés…
Can't render this file because it is too large.
+2
View File
@@ -4126,6 +4126,8 @@ font-technology Variable Variabel
Saving Menyimpan
Saving {} Menyimpan {}
Search commands and tools… Cari perintah dan alat…
Recent Commands Perintah terbaru
No recent commands Tidak ada perintah terbaru
Dashed Line Garis putus-putus
Panel menu Menu panel
Unembed… Lepaskan sematan…
Can't render this file because it contains an unexpected character in line 2484 and column 5.
+2
View File
@@ -3317,6 +3317,8 @@ digits Malayalam Malayalam
@msg `{key}` must be an array of these names: {_1} `{key}` deve essere un array di questi nomi: {_1}
Search commands and tools Cerca comandi e strumenti
Search commands and tools… Cerca comandi e strumenti…
Recent Commands Comandi recenti
No recent commands Nessun comando recente
Search Commands… Cerca comandi…
Secondary Secondario
Section Symbol Simbolo di sezione
Can't render this file because it is too large.
+2
View File
@@ -3195,6 +3195,8 @@ mark-style Japanese 日本式
@msg `{key}` must be an array of these names: {_1} `{key}` には {_1} の中の名前の配列を指定してください
Search commands and tools コマンドとツールを検索
Search commands and tools… コマンドとツールを検索…
Recent Commands 最近使ったコマンド
No recent commands 最近使ったコマンドはありません
Secondary セカンダリ
Select All Art on Layer レイヤー上のすべてのアートを選択
Select All Assets すべてのアセットを選択
Can't render this file because it is too large.
+2
View File
@@ -6078,6 +6078,8 @@ font-technology Variable ცვლადი
Saving შენახვა
Saving {} ინახება: {}
Search commands and tools… ბრძანებებისა და ხელსაწყოების ძიება…
Recent Commands ბოლო ბრძანებები
No recent commands ბოლო ბრძანებები არ არის
Dashed Line ტირეებიანი ხაზი
Panel menu პანელის მენიუ
Unembed… ჩაშენების მოხსნა…
Can't render this file because it is too large.
+2
View File
@@ -3184,6 +3184,8 @@ mark-style Japanese 일본식
@msg `{key}` must be an array of these names: {_1} `{key}`은(는) 다음 이름의 배열이어야 합니다: {_1}
Search commands and tools 명령 및 도구 검색
Search commands and tools… 명령 및 도구 검색…
Recent Commands 최근 명령
No recent commands 최근 명령 없음
Secondary 보조
Select All Art on Layer 레이어의 모든 아트웍 선택
Select All Assets 모든 에셋 선택
Can't render this file because it is too large.
+2
View File
@@ -4716,6 +4716,8 @@ font-technology Variable Variabel
Saving Bezig met opslaan
Saving {} {} wordt opgeslagen
Search commands and tools… Opdrachten en gereedschappen zoeken…
Recent Commands Recente opdrachten
No recent commands Geen recente opdrachten
Dashed Line Streepjeslijn
Panel menu Paneelmenu
Unembed… Insluiten ongedaan maken…
Can't render this file because it is too large.
+2
View File
@@ -4316,6 +4316,8 @@ font-technology Variable Zmienne
Saving Zapisywanie
Saving {} Zapisywanie {}
Search commands and tools… Szukaj poleceń i narzędzi…
Recent Commands Ostatnie polecenia
No recent commands Brak ostatnich poleceń
Dashed Line Linia przerywana
Panel menu Menu panelu
Unembed… Wyodrębnij…
Can't render this file because it is too large.
+2
View File
@@ -2733,6 +2733,8 @@ digits Malayalam Malaiala
Search Commands… Pesquisar Comandos…
Search commands and tools Pesquisar comandos e ferramentas
Search commands and tools… Pesquisar comandos e ferramentas…
Recent Commands Comandos recentes
No recent commands Nenhum comando recente
Secondary Secundária
Section Symbol Símbolo de Seção
Select Selecionar
Can't render this file because it is too large.
+2
View File
@@ -3306,6 +3306,8 @@ digits Malayalam Малаялам
@msg `{key}` must be an array of these names: {_1} `{key}` должно быть массивом из этих имён: {_1}
Search commands and tools Поиск команд и инструментов
Search commands and tools… Поиск команд и инструментов…
Recent Commands Недавние команды
No recent commands Нет недавних команд
Search Commands… Поиск команд…
Secondary Вторичный
Section Symbol Символ параграфа
Can't render this file because it is too large.
+2
View File
@@ -3196,6 +3196,8 @@ digits Malayalam Malayalam
Search All Sök i alla
Search commands and tools Sök kommandon och verktyg
Search commands and tools… Sök kommandon och verktyg…
Recent Commands Senaste kommandon
No recent commands Inga senaste kommandon
Search Commands… Sök kommandon…
Secondary Sekundär
Section Symbol Paragraftecken
Can't render this file because it is too large.
+2
View File
@@ -3067,6 +3067,8 @@ digits Malayalam Malayalam
@msg `{key}` must be an array of these names: {_1} `{key}` şu adlardan oluşan bir dizi olmalıdır: {_1}
Search commands and tools Komutları ve araçları arayın
Search commands and tools… Komutları ve araçları arayın…
Recent Commands Son komutlar
No recent commands Son komut yok
Search Commands… Arama Komutları…
Secondary İkincil
Section Symbol Bölüm Sembolü
Can't render this file because it is too large.
+2
View File
@@ -3309,6 +3309,8 @@ digits Malayalam Малаялам
@msg `{key}` must be an array of these names: {_1} `{key}` має бути масивом цих назв: {_1}
Search commands and tools Пошук команд та інструментів
Search commands and tools… Пошук команд та інструментів…
Recent Commands Нещодавні команди
No recent commands Немає нещодавніх команд
Search Commands… Пошук команд…
Secondary Вторинний
Section Symbol Символ параграфа
Can't render this file because it is too large.
+2
View File
@@ -3651,6 +3651,8 @@ mark-style Japanese Kiểu Nhật
@msg `{key}` must be an array of these names: {_1} `{key}` phải là một mảng gồm các tên sau: {_1}
Search commands and tools Tìm kiếm lệnh và công cụ
Search commands and tools… Tìm kiếm lệnh và công cụ…
Recent Commands Lệnh gần đây
No recent commands Không có lệnh gần đây
Search Commands… Tìm kiếm lệnh…
Search Fonts Folder Tìm kiếm thư mục phông chữ
Searching… Đang tìm kiếm…
Can't render this file because it contains an unexpected character in line 205 and column 5.
+2
View File
@@ -3136,6 +3136,8 @@ digits Malayalam 马拉雅拉姆数字
Filter Layers Panel Rows 筛选图层面板行
Search commands and tools 搜索命令和工具
Search commands and tools… 搜索命令和工具…
Recent Commands 最近使用的命令
No recent commands 没有最近使用的命令
Search Commands… 搜索命令…
Secondary 次要
Section Symbol 章节符号
Can't render this file because it is too large.
+2
View File
@@ -4416,6 +4416,8 @@ digits Malayalam 馬來亞拉姆數字
Filter Layers Panel Rows 篩選圖層面板列
Search commands and tools 搜尋指令與工具
Search commands and tools… 搜尋指令與工具…
Recent Commands 最近使用的指令
No recent commands 沒有最近使用的指令
Search Commands… 搜尋指令…
Secondary 次要
Section Symbol 章節符號
Can't render this file because it is too large.
+371 -10
View File
@@ -136,6 +136,45 @@ pub(crate) fn run_pick(app: &mut VectorcraftApp, id: &str) {
}
}
/// How many picks the Recent Commands list beside the search field holds.
pub(crate) const MAX_RECENT_COMMANDS: usize = 5;
/// How many ids the saved Recent Commands list holds at most, unavailable ones included.
const MAX_SAVED_RECENT_COMMANDS: usize = 4 * MAX_RECENT_COMMANDS;
/// Puts `id` first in the Recent Commands ids `list`, removing its earlier place, and keeps the
/// newest [`MAX_RECENT_COMMANDS`] ids that are `known`. An id that is not `known` now (a plug-in
/// that is disabled or not loaded yet) keeps its place among them, so it shows again when its
/// command comes back. The list never holds more than [`MAX_SAVED_RECENT_COMMANDS`] ids.
fn remember(list: &mut Vec<String>, id: &str, known: impl Fn(&str) -> bool) {
list.retain(|c| c != id);
list.insert(0, id.to_string());
let mut kept = 0;
let end = list.iter().position(|c| {
if known(c) {
kept += 1;
}
kept > MAX_RECENT_COMMANDS
});
list.truncate(end.unwrap_or(list.len()).min(MAX_SAVED_RECENT_COMMANDS));
}
/// The entries the Recent Commands list shows for the ids `ids`, most recent first. An id with no
/// entry (a removed plug-in) is skipped.
fn recent<'a>(entries: &'a [Entry], ids: &[String]) -> Vec<&'a Entry> {
ids.iter().take(MAX_SAVED_RECENT_COMMANDS).filter_map(|id| entries.iter().find(|e| e.id == *id)).take(MAX_RECENT_COMMANDS).collect()
}
/// The id of the Recent Commands list's popup.
fn recent_list_id() -> egui::Id {
egui::Id::unique("palette-recent-commands")
}
/// Is the palette's Recent Commands list open?
pub(crate) fn recent_list_open(ctx: &egui::Context) -> bool {
egui::Popup::is_id_open(ctx, recent_list_id())
}
pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
if !app.ui.palette_open {
return;
@@ -145,7 +184,12 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
let q = app.ui.palette_query.to_lowercase();
let entries = entries(ctx, crate::i18n::current());
let matches: Vec<&Entry> = entries.iter().filter(|e| q.split_whitespace().all(|w| e.haystack.contains(w))).take(14).collect();
let recent = recent(&entries, &app.ui.recent_commands);
// While the Recent Commands list is open, the arrow keys and Enter go to its rows, and the
// search field leaves them the keyboard.
let list_open = recent_list_open(ctx);
let mut run: Option<String> = None;
let mut history_focused = false;
// The highlighted result (#1757): Up and Down move it (wrapping), the pointer over a result
// takes it, and a new query starts again from the first.
let sel_id = egui::Id::unique("palette-selected");
@@ -153,8 +197,32 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
if last_q != q {
sel = 0;
}
// The Recent Commands row with the keyboard: Up and Down move it, wrapping at the ends, so the
// keys never leave the list for the results below it.
let rsel_id = egui::Id::unique("palette-recent-selected");
let mut rsel = if list_open { ctx.data(|d| d.get_temp::<usize>(rsel_id)).unwrap_or(0) } else { 0 };
if list_open && !recent.is_empty() {
let rn = recent.len();
let (down, up) =
ctx.input_mut(|i| (i.consume_key(egui::Modifiers::NONE, egui::Key::ArrowDown), i.consume_key(egui::Modifiers::NONE, egui::Key::ArrowUp)));
if down {
rsel = (rsel + 1) % rn;
}
if up {
rsel = (rsel + rn - 1) % rn;
}
rsel = rsel.min(rn - 1);
}
// Enter or Space runs the row the arrow keys of this frame moved to. The keys are taken here,
// since a row's button turns them into a click of the row that had the keyboard last frame.
if list_open
&& ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Enter) | i.consume_key(egui::Modifiers::NONE, egui::Key::Space))
&& let Some(e) = recent.get(rsel)
{
run = Some(e.id.clone());
}
let n = matches.len();
if n > 0 {
if n > 0 && !list_open {
let (down, up) =
ctx.input_mut(|i| (i.consume_key(egui::Modifiers::NONE, egui::Key::ArrowDown), i.consume_key(egui::Modifiers::NONE, egui::Key::ArrowUp)));
if down {
@@ -168,13 +236,38 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
egui::Area::new(egui::Id::unique("palette")).order(egui::Order::Foreground).anchor(egui::Align2::CENTER_TOP, [0.0, 90.0]).show(ctx, |ui| {
egui::Frame::popup(ui.style()).fill(t.panel).inner_margin(egui::Margin::same(10)).show(ui, |ui| {
ui.set_width(520.0);
let r = ui.add(
egui::TextEdit::singleline(&mut app.ui.palette_query)
.align(egui::Align2::LEFT_CENTER)
.hint_text(tl!("Search commands and tools…"))
.desired_width(500.0),
);
r.request_focus();
ui.horizontal(|ui| {
let r = ui.add(
egui::TextEdit::singleline(&mut app.ui.palette_query)
.align(egui::Align2::LEFT_CENTER)
.hint_text(tl!("Search commands and tools…"))
.desired_width(470.0),
);
// Recent Commands: the last picks, most recent first. A choice runs as a pick of
// the same result does. The first row takes the keyboard when the list opens, and
// the row with the keyboard keeps it while the list is open.
let button = crate::widgets::icon_button(ui, "history", tl!("Recent Commands"), false, 24.0);
// The search field keeps the keyboard, except while the list is open or Tab has
// moved it to the list's button, where Enter or Space opens the list.
history_focused = button.has_focus();
if !list_open && !history_focused {
r.request_focus();
}
egui::Popup::menu(&button).id(recent_list_id()).show(|ui| {
if recent.is_empty() {
ui.add_enabled(false, egui::Button::new(tl!("No recent commands")));
}
for (i, e) in recent.iter().enumerate() {
let row = ui.add(egui::Button::new(e.shown.as_str()).shortcut_text(menus::shown_shortcut(&e.shortcut)));
if i == rsel {
row.request_focus();
}
if row.clicked() {
run = Some(e.id.clone());
}
}
});
});
ui.add_space(6.0);
for (i, e) in matches.iter().enumerate() {
let resp = ui.add(
@@ -190,16 +283,22 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
run = Some(e.id.clone());
}
}
if ui.input(|i| i.key_pressed(egui::Key::Enter))
if !list_open
&& !history_focused
&& ui.input(|i| i.key_pressed(egui::Key::Enter))
&& let Some(e) = matches.get(sel)
{
run = Some(e.id.clone());
}
});
});
ctx.data_mut(|d| d.insert_temp(sel_id, (sel, q)));
ctx.data_mut(|d| {
d.insert_temp(sel_id, (sel, q));
d.insert_temp(rsel_id, rsel);
});
if let Some(id) = run {
app.ui.palette_open = false;
remember(&mut app.ui.recent_commands, &id, |c| entries.iter().any(|e| e.id == c));
run_pick(app, &id);
}
}
@@ -512,6 +611,268 @@ mod tests {
}
}
/// #6376: a pick goes first in Recent Commands, and a pick of a command already listed moves it
/// to the top, so each command takes one place. The list is saved with the UI state.
#[test]
fn recent_commands_put_the_latest_pick_first_and_list_each_command_once() {
let mut list = vec![];
for id in ["object.group", "paint.swap", "object.group"] {
remember(&mut list, id, |_| true);
}
assert_eq!(list, ["object.group", "paint.swap"]);
// A pick with Enter in the open palette is remembered.
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
app.ui.recent_commands = list;
app.ui.palette_open = true;
app.ui.palette_query = "paint.swap".into();
let first = build(crate::i18n::current()).into_iter().find(|e| e.haystack.contains("paint.swap")).unwrap().id;
let ctx = egui::Context::default();
let enter = egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
ctx.run_ui(egui::RawInput { events: vec![enter], ..Default::default() }, |ui| show(&mut app, ui.ctx())).textures_delta.clear();
assert!(!app.ui.palette_open);
assert_eq!(app.ui.recent_commands.first(), Some(&first));
assert_eq!(app.ui.recent_commands.iter().filter(|c| **c == first).count(), 1, "{:?}", app.ui.recent_commands);
let restored: crate::state::UiState = serde_json::from_str(&serde_json::to_string(&app.ui).unwrap()).unwrap();
assert_eq!(restored.recent_commands, app.ui.recent_commands);
}
/// #6376: Recent Commands keeps the last five picks.
#[test]
fn recent_commands_keep_the_last_five_picks() {
let mut list = vec![];
let ids = ["a", "b", "c", "d", "e", "f", "g"];
for id in ids {
remember(&mut list, id, |_| true);
}
assert_eq!(list, ["g", "f", "e", "d", "c"]);
let entries = build(Lang::EN);
let many: Vec<String> = entries.iter().take(MAX_RECENT_COMMANDS + 2).map(|e| e.id.clone()).collect();
assert_eq!(recent(&entries, &many).len(), MAX_RECENT_COMMANDS);
}
/// #6376: a command that does not exist now, such as a plug-in's filter while the plug-in is
/// not loaded, is left out of Recent Commands. A pick keeps it in the saved list, so it shows
/// again when the command comes back; five other commands picked after it push it out.
#[test]
fn recent_commands_skip_ids_that_no_longer_exist() {
let entries = build(Lang::EN);
let known = |c: &str| entries.iter().any(|e| e.id == c);
let saved: Vec<String> = ["plugin:test.UI.palette_removed", "object.group", "tool:no-such-tool"].map(str::to_string).into();
let shown: Vec<&str> = recent(&entries, &saved).iter().map(|e| e.id.as_str()).collect();
assert_eq!(shown, ["object.group"]);
let mut list = saved;
remember(&mut list, "paint.swap", known);
assert_eq!(list, ["paint.swap", "plugin:test.UI.palette_removed", "object.group", "tool:no-such-tool"]);
let four: Vec<String> = entries.iter().filter(|e| e.id != "paint.swap" && e.id != "object.group").take(4).map(|e| e.id.clone()).collect();
for id in &four {
remember(&mut list, id, known);
}
let expected: Vec<String> =
four.iter().rev().cloned().chain(["paint.swap".to_string(), "plugin:test.UI.palette_removed".to_string()]).collect();
assert_eq!(list, expected, "object.group, the sixth known id, and the ids after it go");
// Unavailable ids are capped too.
let mut list: Vec<String> = (0..50).map(|i| format!("plugin:test.UI.gone{i}")).collect();
remember(&mut list, "paint.swap", known);
assert_eq!(list.len(), MAX_SAVED_RECENT_COMMANDS);
assert_eq!(list.first().map(String::as_str), Some("paint.swap"));
}
/// The open palette drawn over `app`, after the frame's keys go to the shortcuts as in the app,
/// with a query no result matches, so the only command buttons are the Recent Commands list's.
fn palette_harness(mut app: VectorcraftApp) -> egui_kittest::Harness<'static, VectorcraftApp> {
app.ui.palette_open = true;
app.ui.palette_query = "zzqqxxjj".into();
let mut fonts = false;
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(800.0, 700.0)).with_accessibility_check(false).build_ui_state(
move |ui, app: &mut VectorcraftApp| {
if !std::mem::replace(&mut fonts, true) {
crate::theme::install_fonts(ui.ctx());
return;
}
crate::shortcuts::handle(app, ui.ctx());
show(app, ui.ctx());
},
app,
);
h.run_steps(3);
h
}
/// #6376: the open Recent Commands list has the keyboard: its first row takes it, Down moves to
/// the next row and Enter runs that row, not the highlighted search result.
#[test]
fn the_keyboard_moves_through_recent_commands_and_enter_runs_a_row() {
use egui_kittest::kittest::Queryable;
let mut app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Multi.session(), crate::Services::default());
app.ui.recent_commands = vec!["object.group".into(), "paint.swap".into()];
let mut h = palette_harness(app);
h.state_mut().ui.palette_query = "zoom".into();
h.run_steps(1);
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
h.key_press(egui::Key::ArrowDown);
h.run_steps(2);
h.key_press(egui::Key::Enter);
h.run_steps(2);
assert!(!h.state().ui.palette_open, "the palette closes");
assert_eq!(h.state().ui.recent_commands, ["paint.swap", "object.group"]);
}
/// #6376: Down on the last Recent Commands row wraps to the first row, and Up on the first
/// wraps to the last, so the keys never reach the search results below the list.
#[test]
fn the_keys_wrap_within_recent_commands() {
use egui_kittest::kittest::Queryable;
// (keys pressed after the list opens, the command Enter then runs)
let cases = [(vec![egui::Key::ArrowDown, egui::Key::ArrowDown], "object.group"), (vec![egui::Key::ArrowUp], "paint.swap")];
for (keys, ran) in cases {
let mut app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Multi.session(), crate::Services::default());
app.ui.recent_commands = vec!["object.group".into(), "paint.swap".into()];
let mut h = palette_harness(app);
h.state_mut().ui.palette_query = "zoom".into();
h.run_steps(1);
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
for key in &keys {
h.key_press(*key);
h.run_steps(2);
}
h.key_press(egui::Key::Enter);
h.run_steps(2);
assert!(!h.state().ui.palette_open, "{keys:?}: the palette closes");
assert_eq!(h.state().ui.recent_commands.first().map(String::as_str), Some(ran), "{keys:?}: {:?}", h.state().ui.recent_commands);
assert_eq!(h.state().ui.recent_commands.len(), 2, "{keys:?}: no search result ran");
}
}
/// #6376: Down and Enter that arrive in the same frame run the row Down moved to, not the row
/// that had the keyboard before.
#[test]
fn down_and_enter_in_one_frame_run_the_row_down_moved_to() {
use egui_kittest::kittest::Queryable;
let mut app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Multi.session(), crate::Services::default());
app.ui.recent_commands = vec!["object.group".into(), "paint.swap".into()];
let mut h = palette_harness(app);
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
// `key_press` runs a frame for each event, so both keys go into the next frame's input.
for key in [egui::Key::ArrowDown, egui::Key::Enter] {
h.input_mut().events.push(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE });
}
h.run_steps(2);
assert!(!h.state().ui.palette_open, "the palette closes");
assert_eq!(h.state().ui.recent_commands, ["paint.swap", "object.group"]);
}
/// #6376: Tab moves the keyboard from the search field to the Recent Commands button and it
/// stays there; Enter then opens the list instead of running the highlighted result.
#[test]
fn tab_reaches_the_recent_commands_button_and_enter_opens_the_list() {
use egui_kittest::kittest::Queryable;
let mut app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Multi.session(), crate::Services::default());
app.ui.recent_commands = vec!["object.group".into()];
let mut h = palette_harness(app);
h.state_mut().ui.palette_query = "zoom".into();
h.run_steps(2);
h.key_press(egui::Key::Tab);
h.run_steps(3);
assert!(h.get_by_label(tl!("Recent Commands")).is_focused(), "the button keeps the keyboard");
h.key_press(egui::Key::Enter);
h.run_steps(2);
assert!(h.state().ui.palette_open, "no search result ran");
let shown = build(crate::i18n::current()).into_iter().find(|e| e.id == "object.group").unwrap().shown;
assert!(h.query_by(|n| n.label().is_some_and(|l| l.starts_with(&shown))).is_some(), "the list is open");
assert_eq!(h.state().ui.recent_commands, ["object.group"]);
}
/// #6376: another open popup leaves the palette's keys alone: Enter still runs the highlighted
/// result. Only the Recent Commands list takes them.
#[test]
fn another_popup_leaves_enter_to_the_palette() {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
app.ui.palette_open = true;
app.ui.palette_query = "paint.swap".into();
let first = build(crate::i18n::current()).into_iter().find(|e| e.haystack.contains("paint.swap")).unwrap().id;
let ctx = egui::Context::default();
let other = egui::Id::unique("another popup");
let enter = egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
for events in [vec![], vec![enter]] {
ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| {
egui::Popup::open_id(ui.ctx(), other);
show(&mut app, ui.ctx());
})
.textures_delta
.clear();
}
assert!(egui::Popup::is_id_open(&ctx, other) && !recent_list_open(&ctx));
assert!(!app.ui.palette_open, "Enter runs the highlighted result");
assert_eq!(app.ui.recent_commands, [first]);
}
/// #6376: Escape with the Recent Commands list open closes the list and leaves the palette
/// open; the next Escape closes the palette.
#[test]
fn escape_closes_recent_commands_before_the_palette() {
use egui_kittest::kittest::Queryable;
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
app.ui.recent_commands = vec!["object.group".into()];
let mut h = palette_harness(app);
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
let shown = build(crate::i18n::current()).into_iter().find(|e| e.id == "object.group").unwrap().shown;
let row = |h: &egui_kittest::Harness<'_, VectorcraftApp>| h.query_by(|n| n.label().is_some_and(|l| l.starts_with(&shown))).is_some();
assert!(row(&h), "the list is open");
h.key_press(egui::Key::Escape);
h.run_steps(2);
assert!(!row(&h), "the list closes");
assert!(h.state().ui.palette_open, "the palette stays open");
h.key_press(egui::Key::Escape);
h.run_steps(2);
assert!(!h.state().ui.palette_open, "the next Escape closes the palette");
}
/// #6376: a choice in Recent Commands closes the palette and runs what a pick of the same
/// result runs (here Clean Up… opens its dialog), and moves the command to the top.
#[test]
fn a_recent_command_runs_what_its_pick_runs() {
use egui_kittest::kittest::Queryable;
let id = "object.path.cleanUp";
let session = || vectorcraft_testkit::fixtures::Fixture::Single.session();
let mut picked = VectorcraftApp::new(session(), crate::Services::default());
picked.ui.status.clear();
run_pick(&mut picked, id);
assert!(picked.ui.dialog.is_some(), "{}", picked.ui.status);
let mut app = VectorcraftApp::new(session(), crate::Services::default());
app.ui.status.clear();
app.ui.recent_commands = vec!["object.group".into(), id.into()];
// A result's button is named by its label and its shortcut.
let e = build(crate::i18n::current()).into_iter().find(|e| e.id == id).unwrap();
let name = format!("{} {}", e.shown, menus::shown_shortcut(&e.shortcut));
let mut h = palette_harness(app);
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
h.get_by_label(&name).click();
h.run_steps(2);
let app = h.state();
assert!(!app.ui.palette_open, "the palette closes");
assert_eq!(outcome(app), outcome(&picked));
assert_eq!(app.ui.recent_commands, [id, "object.group"]);
}
/// #6376: with nothing picked yet, Recent Commands shows a dimmed No recent commands row.
#[test]
fn recent_commands_without_picks_show_a_dimmed_row() {
use egui_kittest::kittest::{NodeT, Queryable};
let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
let mut h = palette_harness(app);
assert!(h.query_by_label(tl!("No recent commands")).is_none(), "the list opens on a click");
h.get_by_label(tl!("Recent Commands")).click();
h.run_steps(2);
assert!(h.get_by_label(tl!("No recent commands")).accesskit_node().is_disabled());
assert!(h.state().ui.palette_open);
}
/// #1757: Up and Down move the highlighted result, wrapping at the ends; a new query starts
/// from the first again.
#[test]
+3 -3
View File
@@ -223,9 +223,9 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {
if crate::shortcut_editor::is_recording(app) {
return;
}
// Escape closes a dropdown list or popover open in the dialog (each closes itself on it) and
// leaves the dialog open.
let popup = app.ui.dialog.as_ref().is_some_and(|d| {
// Escape closes a dropdown list or popover open in the dialog, or the palette's Recent
// Commands list (each closes itself on it), and leaves the dialog or the palette open.
let popup = app.ui.dialog.as_ref().map_or(crate::palette::recent_list_open(ctx), |d| {
egui::Popup::is_any_open(ctx)
|| crate::dialogs::brush_options::tips_open(d)
|| crate::dialogs::new_document_popup_open(d)
+4
View File
@@ -692,6 +692,9 @@ pub struct UiState {
/// Type → Recent Fonts, most recent first.
#[serde(default)]
pub recent_fonts: Vec<String>,
/// Help › Search Commands' Recent Commands list: the ids of the last picks, most recent first.
#[serde(default)]
pub recent_commands: Vec<String>,
/// Families starred in the font menus (the ★ filter shows only these).
#[serde(default)]
pub favorite_fonts: Vec<String>,
@@ -1228,6 +1231,7 @@ impl Default for UiState {
workspace_changes: vec![],
recent_files: vec![],
recent_fonts: vec![],
recent_commands: vec![],
favorite_fonts: vec![],
engine_prefs: Value::Null,
color_guide: Default::default(),
+1
View File
@@ -1007,6 +1007,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Perspective Distort and Free Distort (`object.distort`) turn each warped object's bounding box as the warp turns the object at its own center, the objects inside groups, compound paths and clip groups and the art of linked opacity masks included, so the next Selection or Free Transform drag uses the tilted box; Object › Transform › Reset Bounding Box squares it again, and corners left where they are add no undo step (VectorCraft's own rule; `bboxrotate::distort_turns_an_upright_box_with_the_warp_at_its_center`, `distort_turns_each_member_and_linked_mask_by_its_own_warp`, `mirrored_and_collapsing_distorts_keep_valid_angles`, `distort_angles_undo_redo_and_reopen_together`, `xform::unchanged_distort_records_no_history`).
- The Free Transform widget's Constrain works in Free Distort as well as in Free Transform ([the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/free-transform-tool.html)). With Constrain on, or Shift held, a corner dragged in Free Distort moves only along the line through the opposite corner, in the box's own proportions, and the other three corners stay in place; on a turned box the line runs through the box's own corners. The line is VectorCraft's own rule. Cmd/Ctrl+Alt+Shift on a corner still drags in Perspective Distort, where Constrain stays unavailable (tools `xform::free::tests::free_distort_corner_keeps_to_its_diagonal_with_shift_or_constrain`, `shift_pressed_during_a_free_distort_drag_constrains_it`, `a_turned_box_is_constrained_along_its_own_diagonal`, `along_diagonal_of_a_degenerate_box`; engine `xform::free_transform_constrained_distort_keeps_the_corner_on_its_diagonal`; ui-egui `free_transform::tests::the_widget_sets_the_mode_and_a_corner_drag_then_distorts`).
- Native macOS menu bar, vector tool cursors, a command palette (Help › Search Commands…), middle-button panning with any tool. Native menus explicitly end tracking on command selection, outside window presses and Escape; menu updates wait until tracking ends, and a dismissing press never starts a canvas gesture (M14.8).
- A Recent Commands button beside the Help › Search Commands field lists the last five commands and tools picked from the palette, most recent first, with a command picked again moved to the top. Choosing a row closes the palette and runs it as a pick of the same result does; with no picks yet the list shows a dimmed No recent commands row, and a command that is not available now, such as a filter of a plug-in that is not loaded, is left out until it comes back. The ids are saved with the UI state. While the list is open, Up and Down move through its rows, wrapping at the ends, and Escape closes the list before the palette. This is VectorCraft's own addition and does not raise a score (#6376; `palette` tests `recent_commands_*`, `a_recent_command_runs_what_its_pick_runs`, `the_keys_wrap_within_recent_commands`, `escape_closes_recent_commands_before_the_palette`).
- The Learn panel (Window › Learn, or Explore tutorials beside the search icon on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their progress rings and counts of tutorials finished; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list`, `learn.tab {tab}`, `learn.skill {skill}`, `learn.show {tutorial}` and `learn.back` script it, and the tab buttons, the rows and Back run them ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`).
- A tool's name in a Learn tutorial step is a blue link that shows where the tool is without choosing it (`learn.locateTool {tool}`): its toolbar button is marked, a collapsed group's flyout opens with the tool's row marked, a torn-off strip comes to the front, and a tool no shown toolbar holds is marked in the All Tools drawer. The mark, its 3 seconds and the hidden-toolbar cases are VectorCraft's own rules ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`, the `a_learn_link_*` tests in `toolbar::tests`).
- Under a tutorial's steps, View more opens the tutorial's own practice sample as a new untitled document, and once the tutorial is finished, Next Up moves to the next tutorial in the same skill, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). The samples are VectorCraft's own drawings. A Finish tutorial button that shows once the sample is open, the untitled copy, Back to skills in place of Next Up after a skill's last tutorial, and Next Up showing the next tutorial without opening its sample are VectorCraft's own rules. `learn.openSample`, `learn.finish`, `learn.next` and `learn.skills` (Back to skills) script them. Not done: the help page's short video. Regression tests: `view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document`, `finishing_a_tutorial_offers_next_up_in_its_skill`, `the_practice_controls_work_from_the_keyboard`, `the_last_tutorial_of_a_skill_offers_back_to_skills`, `learn_finish_and_learn_next_follow_the_practice`, `learn_skills_shows_the_list_of_skills`, `the_practice_commands_reject_a_missing_or_unknown_tutorial`, `every_tutorial_has_its_own_readable_sample` and `the_next_tutorial_is_the_next_one_in_the_same_skill` in `crates/ui-egui/src/panels/learn/tests.rs`.