Merge pull request #8017 from dotCooCoo/feat/palette-search-index

Command Palette: a small search index ranks the best match first
This commit is contained in:
BFlat authored and GitHub committed 2026-11-16 23:54:23 +07:00
commit d3276cfc51
37 files changed
+2830 -219

No files matched your search

+2 -2
View File
@@ -133,8 +133,8 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
// Search → command palette (its shortcut opens it too).
if search {
let tip = match menus::shortcut_of("help.commandPalette") {
Some(sc) => format!("{} ({})", tl!("Search commands and tools"), menus::shown_shortcut(sc)),
None => tl!("Search commands and tools").to_string(),
Some(sc) => format!("{} ({})", tl!("Search commands, tools, panels and effects"), menus::shown_shortcut(sc)),
None => tl!("Search commands, tools, panels and effects").to_string(),
};
if widgets::icon_button(ui, "search", &tip, app.ui.palette_open, icon).clicked() {
app.ui.palette_open = !app.ui.palette_open;
+6 -2
View File
@@ -3188,8 +3188,12 @@ digits Malayalam Малаялам
Scripts Скриптове
Search Търсене
Search All Търсене във всички
Search commands and tools Търсене на команди и инструменти
Search commands and tools… Търсене на команди и инструменти…
Search commands, tools, panels and effects Търсене на команди, инструменти, панели и ефекти
Search commands, tools, panels and effects… Търсене на команди, инструменти, панели и ефекти…
No commands match Няма съвпадащи команди
{pos} of {total}: {name} {pos} от {total}: {name}
@plural {n} result|{n} results {n} резултат|{n} резултата
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} от {n} резултат. Продължете да пишете, за да ги стесните.|{shown} от {n} резултата. Продължете да пишете, за да ги стесните.
Recent Commands Последни команди
No recent commands Няма последни команди
Search Commands… Търсене на команди…
Can't render this file because it is too large.
+6 -2
View File
@@ -1301,7 +1301,7 @@ lighting Light Svjetlo
Name* @ 66.67% (RGB/Preview) Naziv* @ 66,67% (RGB/pregled)
No Document Nema dokumenta
Press Pritisnite
Search commands and tools Pretraži naredbe i alate
Search commands, tools, panels and effects Pretraži naredbe, alate, panele i efekte
Style: Stil:
Switch workspace Promijeni radni prostor
Show all open documents Prikaži sve otvorene dokumente
@@ -4388,7 +4388,11 @@ font-technology Variable Varijabilni
Saved {path} Sačuvano: {path}
Saving Čuvanje
Saving {} Čuvanje {}
Search commands and tools… Pretraži naredbe i alate…
Search commands, tools, panels and effects… Pretraži naredbe, alate, panele i efekte…
No commands match Nijedna naredba se ne podudara
{pos} of {total}: {name} {pos} od {total}: {name}
@plural {n} result|{n} results {n} rezultat|{n} rezultata|{n} rezultata
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} od {n} rezultata. Nastavite kucati da ih suzite.|{shown} od {n} rezultata. Nastavite kucati da ih suzite.|{shown} od {n} rezultata. Nastavite kucati da ih suzite.
Recent Commands Nedavne naredbe
No recent commands Nema nedavnih naredbi
Dashed Line Isprekidana linija
Can't render this file because it contains an unexpected character in line 2 and column 73.
+39 -35
View File
@@ -3983,42 +3983,42 @@ digits Malayalam Malaiàlam
Saved Desat
Saved recovery data for {title} S’han desat les dades de recuperació de {title}
Saved Selection 1 Selecció desada 1
Saved Selection 10 Selecció desada 2
Saved Selection 11 Selecció desada 3
Saved Selection 12 Selecció desada 4
Saved Selection 13 Selecció desada 5
Saved Selection 14 Selecció desada 6
Saved Selection 15 Selecció desada 7
Saved Selection 16 Selecció desada 8
Saved Selection 17 Selecció desada 9
Saved Selection 18 Selecció desada 10
Saved Selection 19 Selecció desada 11
Saved Selection 2 Selecció desada 12
Saved Selection 20 Selecció desada 13
Saved Selection 21 Selecció desada 14
Saved Selection 22 Selecció desada 15
Saved Selection 23 Selecció desada 16
Saved Selection 24 Selecció desada 17
Saved Selection 25 Selecció desada 18
Saved Selection 3 Selecció desada 19
Saved Selection 4 Selecció desada 20
Saved Selection 5 Selecció desada 21
Saved Selection 6 Selecció desada 22
Saved Selection 7 Selecció desada 23
Saved Selection 8 Selecció desada 24
Saved Selection 9 Selecció desada 25
Saved Selection 10 Selecció desada 10
Saved Selection 11 Selecció desada 11
Saved Selection 12 Selecció desada 12
Saved Selection 13 Selecció desada 13
Saved Selection 14 Selecció desada 14
Saved Selection 15 Selecció desada 15
Saved Selection 16 Selecció desada 16
Saved Selection 17 Selecció desada 17
Saved Selection 18 Selecció desada 18
Saved Selection 19 Selecció desada 19
Saved Selection 2 Selecció desada 2
Saved Selection 20 Selecció desada 20
Saved Selection 21 Selecció desada 21
Saved Selection 22 Selecció desada 22
Saved Selection 23 Selecció desada 23
Saved Selection 24 Selecció desada 24
Saved Selection 25 Selecció desada 25
Saved Selection 3 Selecció desada 3
Saved Selection 4 Selecció desada 4
Saved Selection 5 Selecció desada 5
Saved Selection 6 Selecció desada 6
Saved Selection 7 Selecció desada 7
Saved Selection 8 Selecció desada 8
Saved Selection 9 Selecció desada 9
Saved Selections Seleccions desades
Saved to User Defined: {} Desat a Definit per l’usuari: {}
Saved View 1 Vista desada 1
Saved View 10 Vista desada 2
Saved View 11 Vista desada 3
Saved View 12 Vista desada 4
Saved View 13 Vista desada 5
Saved View 14 Vista desada 6
Saved View 15 Vista desada 7
Saved View 16 Vista desada 8
Saved View 17 Vista desada 9
Saved View 18 Vista desada 10
Saved View 10 Vista desada 10
Saved View 11 Vista desada 11
Saved View 12 Vista desada 12
Saved View 13 Vista desada 13
Saved View 14 Vista desada 14
Saved View 15 Vista desada 15
Saved View 16 Vista desada 16
Saved View 17 Vista desada 17
Saved View 18 Vista desada 18
Saved View 19 Vista desada 19
Saved View 2 Vista desada 2
Saved View 20 Vista desada 20
@@ -4117,8 +4117,12 @@ digits Malayalam Malaiàlam
Scrub Numeric Fields by Dragging Canvia els camps numèrics arrossegant
Search Cerca
Search All Cerca a tot
Search commands and tools Cerca ordres i eines
Search commands and tools… Cerca ordres i eines…
Search commands, tools, panels and effects Cerca ordres, eines, panells i efectes
Search commands, tools, panels and effects… Cerca ordres, eines, panells i efectes…
No commands match Cap ordre coincideix
{pos} of {total}: {name} {pos} de {total}: {name}
@plural {n} result|{n} results {n} resultat|{n} resultats
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultat. Continueu escrivint per reduir-los.|{shown} de {n} resultats. Continueu escrivint per reduir-los.
Recent Commands Ordres recents
No recent commands No hi ha ordres recents
Search Commands… Cerca ordres…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+6 -2
View File
@@ -1325,7 +1325,7 @@ lighting Light Světlo
Name* @ 66.67% (RGB/Preview) Název* @ 66,67 % (RGB/náhled)
No Document Žádný dokument
Press Klávesou
Search commands and tools Hledat příkazy a nástroje
Search commands, tools, panels and effects Hledat příkazy, nástroje, panely a efekty
Style: Styl:
Switch workspace Přepnout pracovní prostor
Show all open documents Zobrazit všechny otevřené dokumenty
@@ -4493,7 +4493,11 @@ font-technology Variable Variabilní
Saved {path} Uloženo: {path}
Saving Ukládání
Saving {} Ukládání {}
Search commands and tools… Hledat příkazy a nástroje…
Search commands, tools, panels and effects… Hledat příkazy, nástroje, panely a efekty…
No commands match Žádný příkaz neodpovídá
{pos} of {total}: {name} {pos} z {total}: {name}
@plural {n} result|{n} results {n} výsledek|{n} výsledky|{n} výsledků
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} z {n} výsledku. Pište dál a výsledky se zúží.|{shown} z {n} výsledků. Pište dál a výsledky se zúží.|{shown} z {n} výsledků. Pište dál a výsledky se zúží.
Recent Commands Nedávné příkazy
No recent commands Žádné nedávné příkazy
Dashed Line Čárkovaná čára
Can't render this file because it is too large.
+6 -2
View File
@@ -3902,7 +3902,7 @@ lighting Light Lys
Name* @ 66.67% (RGB/Preview) Navn* @ 66.67% (RGB/forhåndsvisning)
No Document Intet dokument
Press Tryk på
Search commands and tools Søg i kommandoer og værktøjer
Search commands, tools, panels and effects Søg i kommandoer, værktøjer, paneler og effekter
Style: Typografi:
Switch workspace Skift arbejdsområde
Show all open documents Vis alle åbne dokumenter
@@ -6867,7 +6867,11 @@ font-technology Variable Variable
Saved {path} Gemte {path}
Saving Gemmer
Saving {} Gemmer {}
Search commands and tools… Søg i kommandoer og værktøjer…
Search commands, tools, panels and effects… Søg i kommandoer, værktøjer, paneler og effekter…
No commands match Ingen kommandoer passer
{pos} of {total}: {name} {pos} af {total}: {name}
@plural {n} result|{n} results {n} resultat|{n} resultater
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} af {n} resultat. Skriv videre for at indsnævre dem.|{shown} af {n} resultater. Skriv videre for at indsnævre dem.
Recent Commands Seneste kommandoer
No recent commands Ingen seneste kommandoer
Dashed Line Stiplet linje
Can't render this file because it is too large.
+6 -2
View File
@@ -3252,8 +3252,12 @@ digits Malayalam Malayalam
Filter Layers Panel Rows Zeilen im Ebenenbedienfeld filtern
@msg `Custom` stands for changed settings: save the preset under another name `Custom` steht für geänderte Einstellungen: Speichern Sie die Vorgabe unter einem anderen Namen
@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…
Search commands, tools, panels and effects Befehle, Werkzeuge, Bedienfelder und Effekte suchen
Search commands, tools, panels and effects… Befehle, Werkzeuge, Bedienfelder und Effekte suchen…
No commands match Keine passenden Befehle
{pos} of {total}: {name} {pos} von {total}: {name}
@plural {n} result|{n} results {n} Ergebnis|{n} Ergebnisse
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} von {n} Ergebnis. Tippen Sie weiter, um sie einzugrenzen.|{shown} von {n} Ergebnissen. Tippen Sie weiter, um sie einzugrenzen.
Recent Commands Zuletzt verwendete Befehle
No recent commands Keine zuletzt verwendeten Befehle
Search Commands… Befehle suchen…
Can't render this file because it is too large.
+6 -2
View File
@@ -3954,8 +3954,12 @@ digits Malayalam Μαλαγιάλαμ
Scribble… Μουτζούρωμα…
Script / Brush Σενάριο / Πινέλο
Search All Αναζήτηση όλων
Search commands and tools Αναζήτηση εντολών και εργαλείων
Search commands and tools… Αναζήτηση εντολών και εργαλείων…
Search commands, tools, panels and effects Αναζήτηση εντολών, εργαλείων, πλαισίων και εφέ
Search commands, tools, panels and effects… Αναζήτηση εντολών, εργαλείων, πλαισίων και εφέ…
No commands match Καμία εντολή δεν ταιριάζει
{pos} of {total}: {name} {pos} από {total}: {name}
@plural {n} result|{n} results {n} αποτέλεσμα|{n} αποτελέσματα
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} από {n} αποτέλεσμα. Συνεχίστε να πληκτρολογείτε για να τα περιορίσετε.|{shown} από {n} αποτελέσματα. Συνεχίστε να πληκτρολογείτε για να τα περιορίσετε.
Recent Commands Πρόσφατες εντολές
No recent commands Δεν υπάρχουν πρόσφατες εντολές
Search Commands… Αναζήτηση εντολών…
Can't render this file because it is too large.
+6 -2
View File
@@ -3290,8 +3290,12 @@ digits Malayalam Malayálam
Filter Layers Panel Rows Filtrar filas del panel Capas
@msg `Custom` stands for changed settings: save the preset under another name `Custom` representa ajustes modificados: guarda el preajuste con otro nombre
@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…
Search commands, tools, panels and effects Buscar comandos, herramientas, paneles y efectos
Search commands, tools, panels and effects… Buscar comandos, herramientas, paneles y efectos…
No commands match Ningún comando coincide
{pos} of {total}: {name} {pos} de {total}: {name}
@plural {n} result|{n} results {n} resultado|{n} resultados
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultado. Sigue escribiendo para acotarlos.|{shown} de {n} resultados. Sigue escribiendo para acotarlos.
Recent Commands Comandos recientes
No recent commands No hay comandos recientes
Search Commands… Buscar comandos…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+6 -2
View File
@@ -1303,7 +1303,7 @@ lighting Light Valo
Name* @ 66.67% (RGB/Preview) Nimi* @ 66.67% (RGB/esikatselu)
No Document Ei asiakirjaa
Press Paina
Search commands and tools Hae komentoja ja työkaluja
Search commands, tools, panels and effects Hae komentoja, työkaluja, paneeleita ja tehosteita
Style: Tyyli:
Switch workspace Vaihda työtilaa
Show all open documents Näytä kaikki avoimet asiakirjat
@@ -4412,7 +4412,11 @@ font-technology Variable Muuttuvat
Saved {path} Tallennettu {path}
Saving Tallennetaan
Saving {} Tallennetaan {}
Search commands and tools… Hae komentoja ja työkaluja…
Search commands, tools, panels and effects… Hae komentoja, työkaluja, paneeleita ja tehosteita…
No commands match Mikään komento ei vastaa hakua
{pos} of {total}: {name} {pos}/{total}: {name}
@plural {n} result|{n} results {n} tulos|{n} tulosta
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown}/{n} tulosta. Kirjoita lisää rajataksesi tuloksia.|{shown}/{n} tulosta. Kirjoita lisää rajataksesi tuloksia.
Recent Commands Viimeisimmät komennot
No recent commands Ei viimeisimpiä komentoja
Dashed Line Katkoviiva
Can't render this file because it contains an unexpected character in line 2 and column 73.
+6 -2
View File
@@ -3278,8 +3278,12 @@ digits Malayalam Malayalam
Filter Layers Panel Rows Filtrer les lignes du panneau Calques
@msg `Custom` stands for changed settings: save the preset under another name `Custom` désigne des réglages modifiés : enregistrez le paramètre prédéfini sous un autre nom
@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…
Search commands, tools, panels and effects Chercher commandes, outils, panneaux et effets
Search commands, tools, panels and effects… Chercher commandes, outils, panneaux et effets…
No commands match Aucune commande ne correspond
{pos} of {total}: {name} {pos} sur {total} : {name}
@plural {n} result|{n} results {n} résultat|{n} résultats
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} sur {n} résultat. Continuez à taper pour les affiner.|{shown} sur {n} résultats. Continuez à taper pour les affiner.
Recent Commands Commandes récentes
No recent commands Aucune commande récente
Search Commands… Rechercher des commandes…
Can't render this file because it is too large.
+6 -2
View File
@@ -3393,8 +3393,12 @@
Search Commands… આદેશો શોધો…
Search Fonts Folder ફોન્ટ ફોલ્ડર શોધો
Search Preferences પસંદગીઓ શોધો
Search commands and tools આદેશો અને ટૂલ્સ શોધો
Search commands and tools… આદેશો અને ટૂલ્સ શોધો…
Search commands, tools, panels and effects આદેશો, ટૂલ્સ, પેનલ્સ અને ઇફેક્ટ્સ શોધો
Search commands, tools, panels and effects… આદેશો, ટૂલ્સ, પેનલ્સ અને ઇફેક્ટ્સ શોધો…
No commands match કોઈ આદેશ મેળ ખાતો નથી
{pos} of {total}: {name} {total} માંથી {pos}: {name}
@plural {n} result|{n} results {n} પરિણામ|{n} પરિણામો
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} માંથી {shown} પરિણામ. તેમને સંકુચિત કરવા લખતા રહો.|{n} માંથી {shown} પરિણામો. તેમને સંકુચિત કરવા લખતા રહો.
Recent Commands તાજેતરના આદેશો
No recent commands કોઈ તાજેતરના આદેશો નથી
Search images છબીઓ શોધો
Can't render this file because it contains an unexpected character in line 72 and column 5.
+6 -2
View File
@@ -4467,8 +4467,12 @@ antiAlias Sharp शार्प
Search खोजें
Search All सभी खोजें
Search artboards खोज आर्टबोर्ड
Search commands and tools खोज आदेश और टूल
Search commands and tools… आदेश और टूल खोजें…
Search commands, tools, panels and effects आदेश, टूल, पैनल्स और इफ़ेक्ट्स खोजें
Search commands, tools, panels and effects… आदेश, टूल, पैनल्स और इफ़ेक्ट्स खोजें…
No commands match कोई आदेश मेल नहीं खाता
{pos} of {total}: {name} {total} में से {pos}: {name}
@plural {n} result|{n} results {n} परिणाम|{n} परिणाम
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} में से {shown} परिणाम। इन्हें सीमित करने के लिए लिखते रहें।|{n} में से {shown} परिणाम। इन्हें सीमित करने के लिए लिखते रहें।
Recent Commands हाल के आदेश
No recent commands कोई हाल का आदेश नहीं
Search Commands… कमांड खोजें…
Can't render this file because it is too large.
+6 -2
View File
@@ -3911,8 +3911,12 @@ mark-style Japanese Japán
Filter Layers Panel Rows Rétegek panel sorainak szűrése
@msg `Custom` stands for changed settings: save the preset under another name a `Custom` a módosított beállításokat jelöli: mentsd az előbeállítást más néven
@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…
Search commands, tools, panels and effects Parancsok, eszközök, panelek és effektusok keresése
Search commands, tools, panels and effects… Parancsok, eszközök, panelek és effektusok keresése…
No commands match Nincs egyező parancs
{pos} of {total}: {name} {pos}/{total}: {name}
@plural {n} result|{n} results {n} találat
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} találatból {shown} látható. Gépeljen tovább a szűkítéshez.
Recent Commands Legutóbbi parancsok
No recent commands Nincsenek legutóbbi parancsok
Search Commands… Parancsok keresése…
Can't render this file because it is too large.
+6 -2
View File
@@ -1228,7 +1228,7 @@ lighting Light Cahaya
Name* @ 66.67% (RGB/Preview) Nama* @ 66.67% (RGB/Pratinjau)
No Document Tidak ada dokumen
Press Tekan
Search commands and tools Cari perintah dan alat
Search commands, tools, panels and effects Cari perintah, alat, panel, dan efek
Style: Gaya:
Switch workspace Ganti ruang kerja
Show all open documents Tampilkan semua dokumen terbuka
@@ -4144,7 +4144,11 @@ font-technology Variable Variabel
Saved {path} Berhasil menyimpan {path}
Saving Menyimpan
Saving {} Menyimpan {}
Search commands and tools… Cari perintah dan alat…
Search commands, tools, panels and effects… Cari perintah, alat, panel, dan efek…
No commands match Tidak ada perintah yang cocok
{pos} of {total}: {name} {pos} dari {total}: {name}
@plural {n} result|{n} results {n} hasil
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} dari {n} hasil. Terus ketik untuk mempersempitnya.
Recent Commands Perintah terbaru
No recent commands Tidak ada perintah terbaru
Dashed Line Garis putus-putus
Can't render this file because it contains an unexpected character in line 2495 and column 5.
+6 -2
View File
@@ -3333,8 +3333,12 @@ digits Malayalam Malayalam
Filter Layers Panel Rows Filtra righe del pannello Livelli
@msg `Custom` stands for changed settings: save the preset under another name `Custom` indica impostazioni modificate: salva il preset con un altro nome
@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…
Search commands, tools, panels and effects Cerca comandi, strumenti, pannelli ed effetti
Search commands, tools, panels and effects… Cerca comandi, strumenti, pannelli ed effetti…
No commands match Nessun comando corrisponde
{pos} of {total}: {name} {pos} di {total}: {name}
@plural {n} result|{n} results {n} risultato|{n} risultati
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} di {n} risultato. Continua a digitare per restringerli.|{shown} di {n} risultati. Continua a digitare per restringerli.
Recent Commands Comandi recenti
No recent commands Nessun comando recente
Search Commands… Cerca comandi…
Can't render this file because it is too large.
+6 -2
View File
@@ -3211,8 +3211,12 @@ mark-style Japanese 日本式
Filter Layers Panel Rows レイヤーパネルの行をフィルター
@msg `Custom` stands for changed settings: save the preset under another name `Custom` は変更した設定を表します: プリセットを別の名前で保存してください
@msg `{key}` must be an array of these names: {_1} `{key}` には {_1} の中の名前の配列を指定してください
Search commands and tools コマンドとツールを検索
Search commands and tools… コマンドとツールを検索…
Search commands, tools, panels and effects コマンド、ツール、パネル、効果を検索
Search commands, tools, panels and effects… コマンド、ツール、パネル、効果を検索…
No commands match 一致するコマンドはありません
{pos} of {total}: {name} {total} 件中 {pos} 件目: {name}
@plural {n} result|{n} results {n} 件
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} 件中 {shown} 件。続けて入力すると絞り込めます。
Recent Commands 最近使ったコマンド
No recent commands 最近使ったコマンドはありません
Secondary セカンダリ
Can't render this file because it is too large.
+6 -2
View File
@@ -3270,7 +3270,7 @@ lighting Light სინათლე
Name* @ 66.67% (RGB/Preview) სახელი* @ 66.67% (RGB/წინასწარი ნახვა)
No Document დოკუმენტი არ არის
Press დააჭირეთ
Search commands and tools ბრძანებებისა და ხელსაწყოების ძიება
Search commands, tools, panels and effects ბრძანებების, ხელსაწყოების, პანელებისა და ეფექტების ძიება
Style: სტილი:
Switch workspace სამუშაო სივრცის გადართვა
Show all open documents ყველა ღია დოკუმენტის ჩვენება
@@ -6096,7 +6096,11 @@ font-technology Variable ცვლადი
Saved {path} შენახულია: {path}
Saving შენახვა
Saving {} ინახება: {}
Search commands and tools… ბრძანებებისა და ხელსაწყოების ძიება…
Search commands, tools, panels and effects… ბრძანებების, ხელსაწყოების, პანელებისა და ეფექტების ძიება…
No commands match შესაბამისი ბრძანება არ არის
{pos} of {total}: {name} {pos} / {total}: {name}
@plural {n} result|{n} results {n} შედეგი
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} შედეგიდან {shown}. გააგრძელეთ აკრეფა მათ შესამცირებლად.
Recent Commands ბოლო ბრძანებები
No recent commands ბოლო ბრძანებები არ არის
Dashed Line ტირეებიანი ხაზი
Can't render this file because it is too large.
+6 -2
View File
@@ -3200,8 +3200,12 @@ mark-style Japanese 일본식
Filter Layers Panel Rows 레이어 패널 행 필터링
@msg `Custom` stands for changed settings: save the preset under another name `Custom`은 변경된 설정을 나타냅니다. 프리셋을 다른 이름으로 저장하세요
@msg `{key}` must be an array of these names: {_1} `{key}`은(는) 다음 이름의 배열이어야 합니다: {_1}
Search commands and tools 명령 및 도구 검색
Search commands and tools… 명령 및 도구 검색…
Search commands, tools, panels and effects 명령, 도구, 패널 및 효과 검색
Search commands, tools, panels and effects… 명령, 도구, 패널 및 효과 검색…
No commands match 일치하는 명령이 없습니다
{pos} of {total}: {name} {total}개 중 {pos}번째: {name}
@plural {n} result|{n} results 결과 {n}개
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. 결과 {n}개 중 {shown}개. 계속 입력하여 범위를 좁히세요.
Recent Commands 최근 명령
No recent commands 최근 명령 없음
Secondary 보조
Can't render this file because it is too large.
+6 -2
View File
@@ -1796,7 +1796,7 @@ lighting Light Licht
Name* @ 66.67% (RGB/Preview) Naam* @ 66.67% (RGB/Voorbeeld)
No Document Geen document
Press Druk op
Search commands and tools Opdrachten en gereedschappen zoeken
Search commands, tools, panels and effects Opdrachten, gereedschappen, panelen en effecten zoeken
Style: Stijl:
Switch workspace Werkruimte wisselen
Show all open documents Alle geopende documenten tonen
@@ -4761,7 +4761,11 @@ font-technology Variable Variabel
Saved {path} {path} opgeslagen
Saving Bezig met opslaan
Saving {} {} wordt opgeslagen
Search commands and tools… Opdrachten en gereedschappen zoeken…
Search commands, tools, panels and effects… Opdrachten, gereedschappen, panelen en effecten zoeken…
No commands match Geen opdrachten gevonden
{pos} of {total}: {name} {pos} van {total}: {name}
@plural {n} result|{n} results {n} resultaat|{n} resultaten
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} van {n} resultaat. Typ verder om ze te beperken.|{shown} van {n} resultaten. Typ verder om ze te beperken.
Recent Commands Recente opdrachten
No recent commands Geen recente opdrachten
Dashed Line Streepjeslijn
Can't render this file because it is too large.
+6 -2
View File
@@ -1255,7 +1255,7 @@ lighting Light Światło
Name* @ 66.67% (RGB/Preview) Nazwa* @ 66,67% (RGB/Podgląd)
No Document Brak dokumentu
Press Naciśnij
Search commands and tools Szukaj poleceń i narzędzi
Search commands, tools, panels and effects Szukaj poleceń, narzędzi, paneli i efektów
Style: Styl:
Switch workspace Przełącz obszar roboczy
Show all open documents Pokaż wszystkie otwarte dokumenty
@@ -4334,7 +4334,11 @@ font-technology Variable Zmienne
Saved {path} Zapisano {path}
Saving Zapisywanie
Saving {} Zapisywanie {}
Search commands and tools… Szukaj poleceń i narzędzi…
Search commands, tools, panels and effects… Szukaj poleceń, narzędzi, paneli i efektów…
No commands match Żadne polecenie nie pasuje
{pos} of {total}: {name} {pos} z {total}: {name}
@plural {n} result|{n} results {n} wynik|{n} wyniki|{n} wyników
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} z {n} wyniku. Pisz dalej, aby je zawęzić.|{shown} z {n} wyników. Pisz dalej, aby je zawęzić.|{shown} z {n} wyników. Pisz dalej, aby je zawęzić.
Recent Commands Ostatnie polecenia
No recent commands Brak ostatnich poleceń
Dashed Line Linia przerywana
Can't render this file because it is too large.
+6 -2
View File
@@ -2749,8 +2749,12 @@ digits Malayalam Malaiala
@msg `Custom` stands for changed settings: save the preset under another name `Custom` representa configurações alteradas: salve a predefinição com outro nome
@msg `{key}` must be an array of these names: {_1} `{key}` deve ser uma matriz destes nomes: {_1}
Search Commands… Pesquisar Comandos…
Search commands and tools Pesquisar comandos e ferramentas
Search commands and tools… Pesquisar comandos e ferramentas…
Search commands, tools, panels and effects Pesquisar comandos, ferramentas, painéis e efeitos
Search commands, tools, panels and effects… Pesquisar comandos, ferramentas, painéis e efeitos…
No commands match Nenhum comando corresponde
{pos} of {total}: {name} {pos} de {total}: {name}
@plural {n} result|{n} results {n} resultado|{n} resultados
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultado. Continue digitando para filtrá-los.|{shown} de {n} resultados. Continue digitando para filtrá-los.
Recent Commands Comandos recentes
No recent commands Nenhum comando recente
Secondary Secundária
Can't render this file because it is too large.
+6 -2
View File
@@ -3322,8 +3322,12 @@ digits Malayalam Малаялам
Filter Layers Panel Rows Фильтровать строки панели «Слои»
@msg `Custom` stands for changed settings: save the preset under another name `Custom` обозначает изменённые параметры: сохраните набор под другим именем
@msg `{key}` must be an array of these names: {_1} `{key}` должно быть массивом из этих имён: {_1}
Search commands and tools Поиск команд и инструментов
Search commands and tools… Поиск команд и инструментов…
Search commands, tools, panels and effects Поиск команд, инструментов, панелей и эффектов
Search commands, tools, panels and effects… Поиск команд, инструментов, панелей и эффектов…
No commands match Нет подходящих команд
{pos} of {total}: {name} {pos} из {total}: {name}
@plural {n} result|{n} results {n} результат|{n} результата|{n} результатов
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} из {n} результата. Продолжайте вводить, чтобы сузить их.|{shown} из {n} результатов. Продолжайте вводить, чтобы сузить их.|{shown} из {n} результатов. Продолжайте вводить, чтобы сузить их.
Recent Commands Недавние команды
No recent commands Нет недавних команд
Search Commands… Поиск команд…
Can't render this file because it is too large.
+6 -2
View File
@@ -3208,8 +3208,12 @@ digits Malayalam Malayalam
Scripts Skript
Search Sök
Search All Sök i alla
Search commands and tools Sök kommandon och verktyg
Search commands and tools… Sök kommandon och verktyg…
Search commands, tools, panels and effects Sök kommandon, verktyg, paneler och effekter
Search commands, tools, panels and effects… Sök kommandon, verktyg, paneler och effekter…
No commands match Inga kommandon matchar
{pos} of {total}: {name} {pos} av {total}: {name}
@plural {n} result|{n} results {n} resultat|{n} resultat
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} av {n} resultat. Fortsätt skriva för att begränsa dem.|{shown} av {n} resultat. Fortsätt skriva för att begränsa dem.
Recent Commands Senaste kommandon
No recent commands Inga senaste kommandon
Search Commands… Sök kommandon…
Can't render this file because it is too large.
+24
View File
@@ -434,6 +434,30 @@ fn font_height_reference_labels_are_in_complete_catalogs() {
}
}
/// Each catalog's Saved View N and Saved Selection N rows carry the number N, and no two of a
/// catalog's saved views or saved selections show one name, whatever digits the language uses.
#[test]
fn numbered_saved_views_and_selections_keep_their_number() {
let mut bad = vec![];
for lang in LANGUAGES.iter().filter(|lang| !lang.source.is_empty()) {
for kind in ["Saved View", "Saved Selection"] {
let mut seen = std::collections::HashMap::new();
for n in 1..=25 {
let source = format!("{kind} {n}");
let Some(row) = lang.catalog().plain(&source) else { continue };
let numbers: Vec<&str> = row.split(|c: char| !c.is_ascii_digit()).filter(|s| !s.is_empty()).collect();
if !numbers.is_empty() && numbers != [n.to_string().as_str()] {
bad.push(format!("{}: {source} -> {row}", lang.code));
}
if let Some(earlier) = seen.insert(row, source.clone()) {
bad.push(format!("{}: {earlier} and {source} both show {row}", lang.code));
}
}
}
}
assert!(bad.is_empty(), "{}", bad.join("\n"));
}
/// The Objects on Path Options section's Detach button, its undo step and the message for a
/// Detach with no object chosen.
#[test]
+6 -2
View File
@@ -3080,8 +3080,12 @@ digits Malayalam Malayalam
Redefine {name} “{name}” Stilini Yeniden Tanımla
@msg `Custom` stands for changed settings: save the preset under another name `Custom` değiştirilmiş ayarları ifade eder: ön ayarı başka bir adla kaydedin
@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…
Search commands, tools, panels and effects Komutları, araçları, panelleri ve efektleri arayın
Search commands, tools, panels and effects… Komutları, araçları, panelleri ve efektleri arayın…
No commands match Eşleşen komut yok
{pos} of {total}: {name} {pos}/{total}: {name}
@plural {n} result|{n} results {n} sonuç
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} sonuçtan {shown} tanesi. Daraltmak için yazmaya devam edin.
Recent Commands Son komutlar
No recent commands Son komut yok
Search Commands… Arama Komutları…
Can't render this file because it is too large.
+6 -2
View File
@@ -3325,8 +3325,12 @@ digits Malayalam Малаялам
Filter Layers Panel Rows Фільтрувати рядки панелі «Шари»
@msg `Custom` stands for changed settings: save the preset under another name `Custom` позначає змінені параметри: збережіть набір під іншим ім’ям
@msg `{key}` must be an array of these names: {_1} `{key}` має бути масивом цих назв: {_1}
Search commands and tools Пошук команд та інструментів
Search commands and tools… Пошук команд та інструментів…
Search commands, tools, panels and effects Пошук команд, інструментів, панелей та ефектів
Search commands, tools, panels and effects… Пошук команд, інструментів, панелей та ефектів…
No commands match Немає відповідних команд
{pos} of {total}: {name} {pos} з {total}: {name}
@plural {n} result|{n} results {n} результат|{n} результати|{n} результатів
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} з {n} результату. Продовжуйте вводити, щоб звузити їх.|{shown} з {n} результатів. Продовжуйте вводити, щоб звузити їх.|{shown} з {n} результатів. Продовжуйте вводити, щоб звузити їх.
Recent Commands Нещодавні команди
No recent commands Немає нещодавніх команд
Search Commands… Пошук команд…
Can't render this file because it is too large.
+6 -2
View File
@@ -3668,8 +3668,12 @@ mark-style Japanese Kiểu Nhật
Filter Layers Panel Rows Lọc hàng bảng Lớp
@msg `Custom` stands for changed settings: save the preset under another name `Custom` biểu thị các cài đặt đã thay đổi: hãy lưu thiết lập sẵn với tên khác
@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ụ…
Search commands, tools, panels and effects Tìm kiếm lệnh, công cụ, bảng và hiệu ứng
Search commands, tools, panels and effects… Tìm kiếm lệnh, công cụ, bảng và hiệu ứng…
No commands match Không có lệnh nào khớp
{pos} of {total}: {name} {pos} trên {total}: {name}
@plural {n} result|{n} results {n} kết quả
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} trên {n} kết quả. Tiếp tục gõ để thu hẹp.
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…
Can't render this file because it contains an unexpected character in line 205 and column 5.
+6 -2
View File
@@ -3152,8 +3152,12 @@ digits Malayalam 马拉雅拉姆数字
Locked 已锁定
Hidden 已隐藏
Filter Layers Panel Rows 筛选图层面板行
Search commands and tools 搜索命令和工具
Search commands and tools… 搜索命令和工具…
Search commands, tools, panels and effects 搜索命令、工具、面板和效果
Search commands, tools, panels and effects… 搜索命令、工具、面板和效果…
No commands match 没有匹配的命令
{pos} of {total}: {name} 第 {pos} 个,共 {total} 个:{name}
@plural {n} result|{n} results {n} 个结果
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. 共 {n} 个结果,显示 {shown} 个。继续输入以缩小范围。
Recent Commands 最近使用的命令
No recent commands 没有最近使用的命令
Search Commands… 搜索命令…
Can't render this file because it is too large.
+6 -2
View File
@@ -4458,8 +4458,12 @@ digits Malayalam 馬來亞拉姆數字
Locked 已鎖定
Hidden 已隱藏
Filter Layers Panel Rows 篩選圖層面板列
Search commands and tools 搜尋指令與工具
Search commands and tools… 搜尋指令與工具…
Search commands, tools, panels and effects 搜尋指令、工具、面板與效果
Search commands, tools, panels and effects… 搜尋指令、工具、面板與效果…
No commands match 沒有符合的指令
{pos} of {total}: {name} 第 {pos} 個,共 {total} 個:{name}
@plural {n} result|{n} results {n} 個結果
@plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. 共 {n} 個結果,顯示 {shown} 個。繼續輸入以縮小範圍。
Recent Commands 最近使用的指令
No recent commands 沒有最近使用的指令
Search Commands… 搜尋指令…
Can't render this file because it is too large.
File diff suppressed because it is too large. Load diff
+764
View File
@@ -0,0 +1,764 @@
//! The command palette's search: a small index of the words in each result's label, menu path and
//! id, the menu bar's home of each result, and the ranking of the results a query matches.
use std::collections::HashMap;
use super::{Entry, WRAPPED};
use crate::menus;
/// The most characters of a query the index reads (VectorCraft's own limit). The substring rule
/// and the exact tiers read the whole query.
const INDEX_CHARS: usize = 200;
/// The field of a result a word comes from, best first.
const LABEL: u8 = 0;
const PATH: u8 = 1;
const ID: u8 = 2;
/// A word's grade in a result, best first: a whole word of the label, a word of the label it
/// starts, a word of the menu path it is or starts, a word of the id it is or starts, or text
/// inside a word of any field ([`super::matching`]'s substring rule).
const LABEL_WORD: u8 = 1;
const LABEL_PREFIX: u8 = 2;
const PATH_WORD: u8 = 3;
const ID_WORD: u8 = 4;
const SUBSTRING: u8 = 5;
const NONE: u8 = u8::MAX;
/// How a whole query matches a result, best first: it is the result's id, it is a label, a label
/// starts with it, or it is the initials of a label.
const EXACT_ID: u8 = 0;
const EXACT_LABEL: u8 = 1;
const PREFIX: u8 = 2;
const INITIALS: u8 = 3;
const NO_PHRASE: u8 = 4;
/// One result in the list of a term: the result's place in the catalog and the field the term is
/// a word of.
#[derive(Clone, Copy)]
struct Posting {
entry: u16,
field: u8,
}
/// The words of every result, each distinct word stored once.
#[derive(Default)]
pub(crate) struct Index {
/// Every distinct word, one after another.
term_text: String,
/// Each word's offset and length in `term_text`, sorted by the word's text.
terms: Vec<(u32, u32)>,
/// Each word's first posting and number of postings in `postings`, in the order of `terms`.
spans: Vec<(u32, u32)>,
postings: Vec<Posting>,
/// The initials of each result's labels, one line per label.
initials_text: String,
/// Each result's offset and length in `initials_text`.
initials: Vec<(u32, u16)>,
}
/// Splits `text` into lowercase words at whitespace and at `.`, `-`, `/`, `(`, `)`, `…`, `›`, `,`
/// and `:`.
fn words(text: &str) -> impl Iterator<Item = &str> {
text.split(|c: char| c.is_whitespace() || matches!(c, '.' | '-' | '/' | '(' | ')' | '…' | '›' | ',' | ':')).filter(|w| !w.is_empty())
}
/// The first letter of each word of `label`, words split at whitespace and at `-`, `/`, `(` and
/// `›`, lowercased.
fn initials_of(label: &str) -> String {
label
.split(|c: char| c.is_whitespace() || matches!(c, '-' | '/' | '(' | '›'))
.filter_map(|w| w.chars().find(|c| c.is_alphanumeric()))
.flat_map(char::to_lowercase)
.collect()
}
/// A name's last `›`-separated part (the label) and the parts before it (the menu path).
fn split_name(name: &str) -> (&str, &str) {
match name.rsplit_once(" › ") {
Some((path, label)) => (label, path),
None => (name, ""),
}
}
/// `name` without the id that follows it when the result shows its id.
fn without_id<'a>(name: &'a str, id: &str) -> &'a str {
name.strip_suffix(')').and_then(|n| n.strip_suffix(id)).and_then(|n| n.strip_suffix(" (")).unwrap_or(name)
}
/// The lowercased names a result is found by: the plain English name, the English name and the
/// shown name ([`super::build`]'s haystack lines).
fn names(e: &Entry) -> impl Iterator<Item = &str> {
e.haystack.lines().take(3)
}
/// The lowercased ids a result is found by: its own, and the engine command's a UI command wraps.
fn ids(e: &Entry) -> impl Iterator<Item = &str> {
e.haystack.lines().skip(3)
}
impl Index {
/// The index of `entries`, whose menu homes and menu items read `homes` in the UI language. The
/// words of a result's menu home and of its menu item's label count as menu path words. A
/// catalog with more results than a posting can name gets an empty index, and queries match by
/// the substring rule alone.
pub(crate) fn build(entries: &[Entry], homes: &[Option<String>]) -> Index {
if entries.len() > usize::from(u16::MAX) {
return Index::default();
}
let mut found: Vec<(String, u16, u8)> = vec![];
let mut initials_text = String::new();
let mut initials = Vec::with_capacity(entries.len());
for (i, e) in entries.iter().enumerate() {
let Ok(entry) = u16::try_from(i) else { break };
let id = ids(e).next().unwrap_or_default();
let start = initials_text.len();
let mut seen_initials: Vec<String> = vec![];
for name in names(e) {
let (label, path) = split_name(without_id(name, id));
found.extend(words(label).map(|w| (w.to_string(), entry, LABEL)));
found.extend(words(path).map(|w| (w.to_string(), entry, PATH)));
let ini = initials_of(label);
if ini.chars().count() >= 2 && !seen_initials.contains(&ini) {
if !seen_initials.is_empty() {
initials_text.push('\n');
}
initials_text.push_str(&ini);
seen_initials.push(ini);
}
}
for home in [e.home.as_deref(), Some(e.menu_item), homes.get(i).and_then(Option::as_deref)].into_iter().flatten() {
found.extend(words(&home.to_lowercase()).map(|w| (w.to_string(), entry, PATH)));
}
for id in ids(e) {
found.extend(words(id).map(|w| (w.to_string(), entry, ID)));
}
let len = u16::try_from(initials_text.len() - start).unwrap_or(0);
initials.push((u32::try_from(start).unwrap_or(0), len));
}
found.sort_unstable();
found.dedup();
let mut index = Index { initials_text, initials, ..Index::default() };
let mut last: Option<&str> = None;
for (word, entry, field) in &found {
if last != Some(word.as_str()) {
let (Ok(offset), Ok(len), Ok(start)) =
(u32::try_from(index.term_text.len()), u32::try_from(word.len()), u32::try_from(index.postings.len()))
else {
return Index::default();
};
index.term_text.push_str(word);
index.terms.push((offset, len));
index.spans.push((start, 0));
last = Some(word.as_str());
}
index.postings.push(Posting { entry: *entry, field: *field });
if let Some(span) = index.spans.last_mut() {
span.1 += 1;
}
}
index.term_text.shrink_to_fit();
index.terms.shrink_to_fit();
index.spans.shrink_to_fit();
index.postings.shrink_to_fit();
index.initials_text.shrink_to_fit();
index.initials.shrink_to_fit();
index
}
/// The bytes the index holds.
#[cfg(test)]
pub(crate) fn bytes(&self) -> usize {
self.term_text.capacity()
+ self.terms.capacity() * std::mem::size_of::<(u32, u32)>()
+ self.spans.capacity() * std::mem::size_of::<(u32, u32)>()
+ self.postings.capacity() * std::mem::size_of::<Posting>()
+ self.initials_text.capacity()
+ self.initials.capacity() * std::mem::size_of::<(u32, u16)>()
}
/// The text of the word at `(offset, len)` in `term_text`.
fn text(&self, &(offset, len): &(u32, u32)) -> &str {
let offset = offset as usize;
self.term_text.get(offset..offset + len as usize).unwrap_or_default()
}
/// The best grade (1 to 4) `word` gets in each result, [`NONE`] where it is no word and starts
/// no word of the result. The words it starts are found by a binary search of the sorted words.
fn grades(&self, word: &str, n: usize) -> Vec<u8> {
let mut out = vec![NONE; n];
let start = self.terms.partition_point(|t| self.text(t) < word);
for (t, at) in self.terms.iter().enumerate().skip(start) {
let term = self.text(at);
if !term.starts_with(word) {
break;
}
let whole = term == word;
let Some(&(begin, len)) = self.spans.get(t) else { continue };
let (begin, len) = (begin as usize, len as usize);
for p in self.postings.get(begin..begin + len).unwrap_or_default() {
let grade = match p.field {
LABEL if whole => LABEL_WORD,
LABEL => LABEL_PREFIX,
PATH => PATH_WORD,
_ => ID_WORD,
};
if let Some(g) = out.get_mut(usize::from(p.entry)) {
*g = (*g).min(grade);
}
}
}
out
}
/// Is `query` (no spaces) the initials of one of result `i`'s labels?
fn initials_are(&self, i: usize, query: &str) -> bool {
let Some(&(offset, len)) = self.initials.get(i) else { return false };
let (offset, len) = (offset as usize, usize::from(len));
self.initials_text.get(offset..offset + len).is_some_and(|text| text.lines().any(|l| l == query))
}
}
/// `query` trimmed, lowercased, with each run of whitespace made one space.
pub(crate) fn normalize(query: &str) -> String {
query.split_whitespace().collect::<Vec<_>>().join(" ").to_lowercase()
}
/// The order of a result's kind when everything else ties: a tool, a command of the menu bar, a
/// panel, an effect, a filter plug-in, then a command with no item in the menu bar.
pub(crate) fn kind(id: &str, home: Option<&str>) -> u8 {
match id.split_once(':').map(|(k, _)| k) {
Some("tool") => 0,
Some("panel") => 2,
Some("effect") => 3,
Some("plugin") => 4,
_ if home.is_some() => 1,
_ => 5,
}
}
/// How the whole lowercased `query` matches result `e` ([`EXACT_ID`] to [`NO_PHRASE`]), where
/// `initials` says whether the query is the initials of one of its labels. A query starts a name
/// when it starts the name's label, or, for a query that holds `›`, the name with its menu path.
fn phrase(e: &Entry, query: &str, initials: bool) -> u8 {
if ids(e).any(|id| id == query) {
return EXACT_ID;
}
let trimmed = query.trim_end_matches('…');
let labels = || names(e).flat_map(|n| [n, split_name(n).0]);
if labels().any(|l| l == query || l.trim_end_matches('…') == trimmed) {
return EXACT_LABEL;
}
// A menu's title alone does not put the items of that menu in this tier.
let with_path = query.contains('›');
if names(e).any(|n| split_name(n).0.starts_with(query) || (with_path && n.starts_with(query))) {
return PREFIX;
}
if initials {
return INITIALS;
}
NO_PHRASE
}
/// What results are ordered by, compared field by field: how the whole query matches, the worst
/// grade a word gets, the sum of the grades, the kind of result and the label's length.
type RankKey = (u8, u8, u32, u8, usize);
/// The results of `entries` that the lowercased `query` matches, best first, as places in
/// `entries`. A result matches when every word of the query is text in one of its names or ids
/// (the rule the palette always had, so nothing it found is lost), when every word of the query is
/// or starts a word of its label, menu path or id, or when the query is the initials of a label
/// ("ea" for Export As…). Results are ordered by how the whole query matches ([`phrase`]), then by
/// the worst grade a word gets, the sum of the grades, the kind of result ([`kind`]), the label's
/// length and the catalog order. An empty query lists every result in catalog order.
pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str) -> Vec<u32> {
let query = normalize(query);
if query.is_empty() {
return (0..entries.len()).filter_map(|i| u32::try_from(i).ok()).collect();
}
let spaced: Vec<&str> = query.split(' ').collect();
let head: String = query.chars().take(INDEX_CHARS).collect();
let tokens: Vec<&str> = words(&head).collect();
let n = entries.len();
let indexed: Vec<Vec<u8>> = tokens.iter().map(|t| index.grades(t, n)).collect();
// The index reads only the start of a longer query, so such a query matches by the substring
// rule, which reads all of it.
let fits = query.chars().count() <= INDEX_CHARS;
let packed: String = query.chars().filter(|c| !c.is_whitespace()).collect();
let packed = Some(packed).filter(|p| (2..=6).contains(&p.chars().count()) && p.chars().all(char::is_alphabetic));
let mut ranked: Vec<(RankKey, u32)> = vec![];
for (i, e) in entries.iter().enumerate() {
let Ok(place) = u32::try_from(i) else { break };
let substring = spaced.iter().all(|w| e.haystack.contains(w));
let initials = packed.as_deref().is_some_and(|p| index.initials_are(i, p));
// Each word's grade, the worst and their sum; with initials, every word counts as a word
// the label starts, as the initials stand for every word of the label.
let (mut all_indexed, mut worst, mut sum) = (fits && !tokens.is_empty(), 0u8, 0u32);
for (grades, token) in indexed.iter().zip(&tokens) {
let mut g = grades.get(i).copied().unwrap_or(NONE);
if g == NONE {
all_indexed = false;
if e.haystack.contains(token) {
g = SUBSTRING;
}
}
let g = if initials { g.min(LABEL_PREFIX) } else { g.min(SUBSTRING) };
worst = worst.max(g);
sum += u32::from(g);
}
if !(substring || all_indexed || initials) {
continue;
}
let tier = phrase(e, &query, initials);
let length = split_name(&e.shown).0.chars().count();
ranked.push(((tier, worst, sum, e.kind, length), place));
}
ranked.sort_by_key(|&(key, place)| (key, place));
ranked.into_iter().map(|(_, place)| place).collect()
}
/// The first place in the menu bar of each item a result runs, as an English `›`-separated path
/// of the menus that hold it: by command id, `panel:<id>` for a Window menu panel (Learn too),
/// `effect:<id>` for an Effect menu item and `plugin:<id>` for an Object › Plug-ins filter. With
/// the native Mac menu bar (`native`), About, Preferences (under Settings), Language, Appearance
/// and Quit are in the application menu, which comes first, as `native_menu::mac_layout` puts
/// them. The in-window menu bar shows no application menu. Each home comes with the English label
/// of its item (File › Exit for Quit VectorCraft), empty for the application menu's items.
pub(crate) fn menu_homes(native: bool) -> HashMap<String, (String, &'static str)> {
fn key(id: &str, p: &serde_json::Value) -> String {
let field = |k: &str| p.get(k).and_then(serde_json::Value::as_str);
match (id, field("panel"), field("effect"), field("id")) {
("window.panel", Some(panel), ..) => format!("panel:{panel}"),
("window.learn", ..) => format!("panel:{}", crate::panels::learn::ID),
("effect.dialog" | "effect.apply", _, Some(effect), _) => format!("effect:{effect}"),
("plugin.dialog", _, _, Some(filter)) => format!("plugin:{filter}"),
_ => WRAPPED.iter().find(|(engine, _)| *engine == id).map_or(id, |(_, ui)| ui).to_string(),
}
}
fn walk(items: &[menus::Item], path: &mut Vec<&'static str>, skip: &[&str], out: &mut HashMap<String, (String, &'static str)>) {
for it in items {
match it {
menus::Item::Cmd(label, id, p) if !skip.contains(id) => {
out.entry(key(id, p)).or_insert_with(|| (path.join(" › "), *label));
}
menus::Item::Sub(name, children) => {
path.push(name);
walk(children, path, skip, out);
path.pop();
}
_ => {}
}
}
}
let mut out = HashMap::new();
let app_menu: &[(&str, &str)] =
&[("help.about", ""), ("edit.preferences", "Settings"), ("app.language", "Language"), ("window.brightness", "Appearance"), ("app.quit", "")];
let skip: Vec<&str> = if native { app_menu.iter().map(|(id, _)| *id).collect() } else { vec![] };
if native {
for (id, sub) in app_menu {
let path = if sub.is_empty() { crate::native_menu::APP_NAME.to_string() } else { format!("{} › {sub}", crate::native_menu::APP_NAME) };
out.insert((*id).to_string(), (path, ""));
}
}
// The tree's first menu is the application menu, which the in-window bar never shows and
// the native bar builds itself.
for (name, items) in menus::menu_tree().into_iter().skip(1) {
walk(&items, &mut vec![name], &skip, &mut out);
}
out
}
#[cfg(test)]
mod tests {
use super::super::{Catalog, catalog};
use super::*;
use crate::i18n::Lang;
/// The ids of the results `query` lists, best first.
fn ranked(c: &Catalog, query: &str) -> Vec<String> {
rank(&c.list, &c.index, query).iter().filter_map(|&i| c.list.get(i as usize)).map(|e| e.id.clone()).collect()
}
/// A result named `name` (`›`-separated, its last part the label) with id `id`.
fn entry(name: &str, id: &str) -> Entry {
let home = None;
Entry {
id: id.to_string(),
shortcut: String::new(),
shown: name.to_string(),
haystack: [name, name, name, id].map(str::to_lowercase).join("\n"),
kind: kind(id, home.as_deref()),
home,
menu_item: "",
}
}
/// `entries` with their index.
fn synthetic(entries: Vec<Entry>) -> Catalog {
let index = Index::build(&entries, &[]);
Catalog { list: entries, index, ranked: std::sync::Mutex::new(None) }
}
/// Where `id` is among the results of `query`.
fn place(c: &Catalog, query: &str, id: &str) -> Option<usize> {
ranked(c, query).iter().position(|r| r == id)
}
/// For each pair of adjacent word grades, a result where the word gets the better grade ranks
/// above one where it gets the worse, and both are listed. The second word of each query is a
/// whole word of every label, so no whole-query tier applies.
#[test]
fn a_better_word_grade_ranks_first() {
for (query, better, worse) in [
// A whole word of the label, then a word of the label it starts.
("cut zz", entry("Zz Cut", "a.one"), entry("Zz Cutter", "b.two")),
// A word of the label it starts, then a word of the menu path.
("fill zz", entry("Zz Filling", "a.one"), entry("Fill › Zz Other", "b.two")),
// A word of the menu path, then a word of the id.
("zap zz", entry("Zap › Zz One", "a.one"), entry("Zz Two", "zap.two")),
// A word of the id, then text inside a word.
("zip zz", entry("Zz Three", "zip.three"), entry("Zz Unzipped", "b.two")),
] {
let (b, w) = (better.id.clone(), worse.id.clone());
// The worse one comes first in the catalog, so only the grade puts the better first.
let c = synthetic(vec![worse, better]);
assert_eq!(ranked(&c, query), [b, w], "{query}");
}
}
/// For each pair of adjacent whole-query tiers, a result in the better tier ranks above one in
/// the worse.
#[test]
fn a_better_whole_query_tier_ranks_first() {
for (query, better, worse) in [
// The query is the result's id, then it is a label.
("zz.one", entry("Alpha", "zz.one"), entry("zz.one", "b.two")),
// The query is a label, then a label starts with it.
("snap", entry("Snap", "a.one"), entry("Snapshot", "b.two")),
// A label starts with the query, then the query is a label's initials.
("ab", entry("Abacus", "a.one"), entry("Alpha Beta", "b.two")),
// The query is a label's initials, then a whole word of a label that it does not start.
("gb", entry("Green Blue", "a.one"), entry("Zz Gb", "b.two")),
] {
let (b, w) = (better.id.clone(), worse.id.clone());
let c = synthetic(vec![worse, better]);
assert_eq!(ranked(&c, query), [b, w], "{query}");
}
}
/// The kind of result and the label's length order results only when the grades tie: a tool
/// with a short label stays below a command whose label holds the word whole. Ties keep the
/// catalog order, the same on every ranking.
#[test]
fn kind_and_length_never_lift_a_worse_grade() {
let c = synthetic(vec![entry("Zz Cutx", "tool:cutx"), entry("Zz Cut With a Much Longer Label", "a.one")]);
assert_eq!(ranked(&c, "cut zz"), ["a.one", "tool:cutx"]);
let c = synthetic(vec![entry("Zz Cut Long Label", "a.one"), entry("Zz Cut Long", "b.two"), entry("Zz Cut", "tool:cut")]);
assert_eq!(ranked(&c, "cut zz"), ["tool:cut", "b.two", "a.one"], "the tool first, then the shorter label");
let c = synthetic(vec![entry("Zz Same", "a.one"), entry("Zz Same", "b.two"), entry("Zz Same", "c.three")]);
assert_eq!(ranked(&c, "same zz"), ["a.one", "b.two", "c.three"]);
assert_eq!(ranked(&c, "same zz"), ranked(&c, "same zz"));
}
/// A query that is a menu's title ranks a result whose label holds it as a word above the items
/// of that menu, which match only by their menu path. A query that names the menu with `›`
/// still starts the item's name.
#[test]
fn a_menu_title_does_not_lift_its_items() {
let c = synthetic(vec![entry("Object › Paint", "a.one"), entry("Outline Object", "b.two")]);
assert_eq!(ranked(&c, "object"), ["b.two", "a.one"]);
assert_eq!(ranked(&c, "object › pa"), ["a.one"]);
let en = catalog(Lang::EN, false);
for q in ["object", "effect", "select", "view", "type", "edit"] {
let first = rank(&en.list, &en.index, q).first().and_then(|&i| en.list.get(i as usize)).map(|e| e.shown.to_lowercase());
let label = first.as_deref().map(|n| split_name(n).0.to_string()).unwrap_or_default();
assert!(words(&label).any(|w| w.starts_with(q)), "{q}: {first:?}");
}
}
/// The application menu of the native Mac menu bar holds the items [`menu_homes`] puts there,
/// under the same submenus.
#[test]
fn native_homes_follow_the_native_application_menu() {
use crate::native_menu::{self, MenuRole, Node};
fn walk(nodes: &[Node], path: &mut Vec<String>, out: &mut HashMap<String, String>) {
for n in nodes {
match n {
Node::Item(it) => {
if let Some(id) = it.command {
out.entry(id.to_string()).or_insert_with(|| path.join(" › "));
}
}
Node::Submenu { label, children } => {
path.push(label.clone());
walk(children, path, out);
path.pop();
}
_ => {}
}
}
}
let app = crate::VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
let bar = native_menu::mac_layout(&app, &native_menu::from_tree(&app, &menus::menu_tree()), Lang::EN).bar;
let app_menu = bar.menus.iter().find(|m| m.role == MenuRole::App).unwrap();
let mut found = HashMap::new();
walk(&app_menu.children, &mut vec![app_menu.title.clone()], &mut found);
// The items the native bar runs itself (Hide, Hide Others, Minimize) are not palette results.
found.retain(|id, _| ![native_menu::HIDE, native_menu::HIDE_OTHERS, native_menu::MINIMIZE].contains(&id.as_str()));
let homes = menu_homes(true);
let expected: HashMap<String, String> = homes
.iter()
.filter(|(_, (path, _))| path.split(" › ").next() == Some(native_menu::APP_NAME))
.map(|(id, (path, _))| (id.clone(), path.clone()))
.collect();
assert!(!expected.is_empty());
assert_eq!(found, expected);
}
/// Queries from the list of things people type, on the English results: some list their command
/// first, others within the first few results.
#[test]
fn common_queries_list_the_command_near_the_top() {
let c = catalog(Lang::EN, false);
let first = |q: &str| ranked(&c, q).first().cloned().unwrap_or_default();
let within = |q: &str, id: &str, n: usize| place(&c, q, id).is_some_and(|p| p < n);
assert_eq!(first("ea"), "file.exportAs", "the initials of Export As…");
assert_eq!(first("save"), "file.save");
assert!(within("export", "file.exportAs", 3));
assert_eq!(first("rect"), "tool:rectangle");
let (tool, effect) = (place(&c, "rect", "tool:rectangle"), place(&c, "rect", "effect:convertToShape.rectangle"));
assert!(effect.is_some() && tool < effect, "{tool:?} {effect:?}");
assert!(within("type", "tool:type", 2));
assert!(within("layers", "panel:layers", 3));
assert_eq!(first("drop shadow"), "effect:stylize.dropShadow");
assert_eq!(first("view.goto1"), "view.goto1", "the whole id, above Saved View 10");
assert_eq!(first("bring front"), "object.arrange.bringToFront");
assert!(within("ruler", "view.rulers", 4));
assert!(place(&c, "ruler", "perspective.grid.rulers").is_some());
assert_eq!(first("deselect"), "select.none");
let mut blurs: Vec<String> = ranked(&c, "blur").into_iter().take(3).collect();
blurs.sort();
assert_eq!(blurs, ["effect:blur.gaussian", "effect:blur.radial", "effect:blur.smart"]);
assert!(ranked(&c, "zzzz").is_empty());
// English names are searched in every language.
let zh = catalog(Lang::from_code("zh-hant").unwrap(), false);
for q in ["save", "rect"] {
assert_eq!(ranked(&zh, q).first(), ranked(&c, q).first(), "{q}");
}
}
/// What the palette always matched: every word of the query is text in one of the result's
/// names or ids.
fn substring_rule<'a>(c: &'a Catalog, query: &str) -> Vec<&'a str> {
let q = normalize(query);
c.list.iter().filter(|e| q.split_whitespace().all(|w| e.haystack.contains(w))).map(|e| e.id.as_str()).collect()
}
/// Each result's English name, shown name (in English, German and Chinese, Traditional) and id
/// find it, first unless another result has that name; its id always lists it first.
#[test]
fn every_result_is_found_first_by_its_name_and_its_id() {
for code in ["en", "de", "zh-hant"] {
let c = catalog(Lang::from_code(code).unwrap(), false);
let label = |n: &str| split_name(n).0.trim_end_matches('…').to_string();
for e in &c.list {
let english = e.haystack.lines().nth(1).unwrap_or_default();
for query in [english, &e.shown] {
let results = ranked(&c, query);
assert!(results.contains(&e.id), "{code}: {query} finds {}", e.id);
let q = normalize(query);
let named = c.list.iter().filter(|o| names(o).any(|n| n == q || label(n) == label(&q))).count();
if named <= 1 {
assert_eq!(results.first(), Some(&e.id), "{code}: {query}");
}
}
assert_eq!(ranked(&c, &e.id).first(), Some(&e.id), "{code}: {}", e.id);
}
}
}
/// The queries the palette's tests use and a list of things people type.
const QUERIES: &[&str] = &[
"select",
"zoom",
"zoom in",
"show panel",
"group",
"layers",
"color guide",
"drop shadow",
"use precise cursors",
"continue in background",
"export continue in background",
"show rulers",
"delete selection",
"cancel key object",
"fit headline",
"batch",
"flattener preview",
"panel options",
"close path",
"knife",
"play action",
"reset panel",
"other library",
"ellipse",
"blur",
"save",
"export",
"rect",
"type",
"ea",
"bring front",
"ruler",
"deselect",
"view.goto1",
"zzzz",
"pen",
"outlines",
"join paths",
"rounded corners",
"scaling",
"rotated",
"eyedroper",
"rectange",
"elipse",
"gruop",
"remove bg",
"outline text",
"flip",
"combine",
"vectorize",
"colour",
"transparent background",
"png",
"object.group",
"file.exportinbackground",
"window",
"s",
"e",
"…",
"› ",
];
/// For each query, every result the palette found before is still found, and when it found 50
/// or fewer, each of them is among the first 50 results, so the list still shows it.
#[test]
fn every_result_found_before_is_still_found_and_shown() {
assert_eq!(QUERIES.len(), 60);
let c = catalog(Lang::EN, false);
for q in QUERIES {
let before = substring_rule(&c, q);
let now = ranked(&c, q);
for id in &before {
let at = now.iter().position(|r| r == id);
assert!(at.is_some(), "{q}: {id} is still found");
if before.len() <= super::super::MAX_RESULTS {
assert!(at < Some(super::super::MAX_RESULTS), "{q}: {id} is shown at {at:?}");
}
}
}
}
/// A query longer than the index reads still has to match in full: two labels that share their
/// first 200 characters are told apart by the rest.
#[test]
fn a_long_query_matches_in_full() {
let shared = "a".repeat(200);
let c = synthetic(vec![entry(&format!("{shared}b tail"), "a.one"), entry(&format!("{shared}c tail"), "b.two")]);
let query = format!("{shared}b");
assert_eq!(substring_rule(&c, &query), ["a.one"]);
assert_eq!(ranked(&c, &query), ["a.one"]);
}
/// Text in scripts without spaces, right-to-left text, combining characters, a very long pasted
/// query, punctuation alone and names that differ only in the id they show.
#[test]
fn unusual_text_is_searched_safely() {
let c = synthetic(vec![entry("物件 › 群組", "a.one"), entry("مرحبا عالم", "b.two"), entry("Cafe\u{301} Tool", "c.three")]);
assert_eq!(ranked(&c, "群組"), ["a.one"]);
assert_eq!(ranked(&c, "عالم"), ["b.two"]);
assert_eq!(ranked(&c, "cafe\u{301}"), ["c.three"]);
assert!(ranked(&c, &"x".repeat(5000)).is_empty());
assert!(ranked(&c, &"群".repeat(5000)).is_empty());
assert_eq!(ranked(&c, "›"), ["a.one"]);
assert!(ranked(&c, "…,.-").is_empty());
let en = catalog(Lang::EN, false);
let both = ranked(&en, "fit headline");
assert!(both.contains(&"type.fitHeadline".to_string()) && both.contains(&"text.fitHeadline".to_string()), "{both:?}");
for id in ["type.fitHeadline", "text.fitHeadline"] {
assert_eq!(ranked(&en, &format!("Type › Fit Headline ({id})")).first().map(String::as_str), Some(id));
}
let zh = Lang::from_code("zh-hant").unwrap();
let zh_catalog = catalog(zh, false);
let group = crate::i18n::tr(zh, "Group");
assert!(place(&zh_catalog, group, "object.group").is_some_and(|p| p < 3), "{group}");
}
/// Each result's home is the first item of the menu bar that runs it: an Effect menu item's
/// submenu, the Window menu for a panel whose item shows and hides it, Learn's own item, and
/// with the native Mac menu bar Preferences under the application menu's Settings.
#[test]
fn results_know_their_place_in_the_menu_bar() {
let homes = menu_homes(false);
let home = |id: &str| homes.get(id).map(|(path, _)| path.as_str());
assert_eq!(home("effect:stylize.roundCorners"), Some("Effect › Stylize"));
assert_eq!(home("panel:layers"), Some("Window"), "matched by the panel, although the item also asks to toggle it");
assert_eq!(home("panel:learn"), Some("Window"));
assert_eq!(home("panel:character"), Some("Window › Type"));
assert_eq!(home("edit.preferences"), Some("Edit"));
assert_eq!(home("help.about"), Some("Help"), "the in-window bar shows no application menu");
assert_eq!(home("ui.layersPanelOptions"), None);
assert_eq!(homes.get("app.quit"), Some(&("File".to_string(), "Exit")), "with its item's own label");
let native = menu_homes(true);
let native_home = |id: &str| native.get(id).map(|(path, _)| path.as_str());
assert_eq!(native_home("edit.preferences"), Some("VectorCraft › Settings"));
assert_eq!(native_home("help.about"), Some("VectorCraft"));
assert_eq!(native_home("help.discord"), Some("Help"));
let c = catalog(Lang::EN, false);
let of = |id: &str| c.list.iter().find(|e| e.id == id).and_then(|e| e.home.clone());
assert_eq!(of("effect:stylize.roundCorners").as_deref(), Some("Effect › Stylize"));
assert_eq!(of("tool:pen"), None);
// The home's words find the result: Preferences… under the native bar's Settings.
let native_catalog = catalog(Lang::EN, true);
assert!(place(&native_catalog, "settings pref", "edit.preferences").is_some());
assert!(place(&c, "settings pref", "edit.preferences").is_none());
// The menu item's own label finds the result too: File › Exit runs Quit VectorCraft.
assert!(place(&c, "exit", "app.quit").is_some());
}
/// The index of the real results takes at most 512 KiB, homes included.
#[test]
fn the_index_stays_small() {
let c = catalog(Lang::EN, false);
let homes: usize = c.list.iter().filter_map(|e| e.home.as_ref()).map(String::capacity).sum();
let bytes = c.index.bytes() + homes;
println!("{} results, index {} bytes, homes {homes} bytes", c.list.len(), c.index.bytes());
assert!(bytes <= 512 * 1024, "{bytes}");
}
#[test]
#[ignore = "times the index and sample queries; run in a release build"]
fn time_the_index_and_queries() {
let started = std::time::Instant::now();
let c = catalog(Lang::EN, false);
let built = started.elapsed();
let started = std::time::Instant::now();
let index = Index::build(&c.list, &[]);
println!("catalog {built:?}, index alone {:?}, {} results, {} bytes", started.elapsed(), c.list.len(), index.bytes());
let long = "q".repeat(200);
for q in ["e", "ea", "select", "bring front", "zzzz", long.as_str()] {
let started = std::time::Instant::now();
let runs = 100;
for _ in 0..runs {
std::hint::black_box(rank(&c.list, &c.index, q));
}
println!("{:>12}: {:?} per query", q.get(..12).unwrap_or(q), started.elapsed() / runs);
}
let started = std::time::Instant::now();
for _ in 0..100 {
std::hint::black_box(substring_rule(&c, "bring front"));
}
println!("substring rule alone: {:?} per query", started.elapsed() / 100);
}
}
+1 -1
View File
@@ -104,7 +104,7 @@ fn explore_tutorials_on_the_app_bar_shows_and_hides_the_learn_panel() {
let ctx = context();
assert!(!shown(&app));
let nodes = frame(&mut app, &ctx, vec![], app_bar);
let search = center_where(&nodes, |label| label.starts_with("Search commands and tools"));
let search = center_where(&nodes, |label| label.starts_with("Search commands, tools, panels and effects"));
let learn = center(&nodes, "Explore tutorials");
let (search, learn) = (search.expect("the search icon shows"), learn.expect("the app bar has Explore tutorials"));
assert!(learn.x < search.x && (learn.y - search.y).abs() < 1.0, "beside the search icon: {learn:?}, {search:?}");
+15 -3
View File
@@ -753,7 +753,7 @@ fn menu_bar_paths() -> &'static HashMap<&'static str, Vec<(String, Value)>> {
/// The menu path of the item of the menu bar that runs command `id` as a key press runs it
/// ([`a_menu_bar_item_runs`]): the first item that runs it with no params, or else the first item,
/// whose params all its items give.
fn menu_bar_path(id: &str) -> Option<&'static str> {
pub(crate) fn menu_bar_path(id: &str) -> Option<&'static str> {
let (_, params) = command_doc(id)?;
let items = menu_bar_paths().get(id).filter(|_| a_menu_bar_item_runs(id, params))?;
chosen_path(items)
@@ -924,7 +924,7 @@ pub(crate) fn menu_target_now(app: &VectorcraftApp, id: &str) -> Option<Result<(
/// What [`menu_target_now`] gives for command `id` while its menu bar item is dimmed: the status
/// line, with the engine's reason when it gives one. The app's own rules ([`menus::enabled`]) dim
/// UI commands, and some commands the engine would run, without giving a reason.
fn dimmed(app: &VectorcraftApp, id: &str) -> Result<(String, Value), String> {
pub(crate) fn dimmed(app: &VectorcraftApp, id: &str) -> Result<(String, Value), String> {
let Some(why) = vectorcraft_engine::find_command(id).and_then(|c| (c.enabled)(&app.session).err()) else {
return Err(format!("command `{id}` is not available right now"));
};
@@ -936,7 +936,7 @@ fn dimmed(app: &VectorcraftApp, id: &str) -> Result<(String, Value), String> {
/// run without them (as the Variables panel's commands do), and it is a query, whose answer a key
/// press drops (Select All Unused), a command of [`NEEDS_A_PARAM`], or a menu command whose params
/// doc names a field a call must give (File › Document Setup › Units, `{units}`)?
fn needs_a_value(key: &str) -> bool {
pub(crate) fn needs_a_value(key: &str) -> bool {
static KEYS: OnceLock<HashSet<&'static str>> = OnceLock::new();
KEYS.get_or_init(|| {
vectorcraft_engine::command_specs()
@@ -3191,4 +3191,16 @@ mod tests {
assert_eq!(r["shortcut"], "Cmd+Alt+Shift+F11");
assert!(app.run("shortcuts.preset", json!({"name": null})).unwrap_err().starts_with("unknown preset"));
}
/// A command that needs a value is listed in the editor once the user gives it a key, but the
/// command search still leaves it out: a pick gives it no value.
#[test]
fn a_command_given_a_key_that_needs_a_value_is_no_pick() {
let mut overrides = Overrides::default();
crate::keymap::set_override(&mut overrides, "document.setUnits", "Cmd+Alt+Shift+F12");
let entry = entries().iter().find(|e| e.key == "document.setUnits").cloned().expect("the editor has a row for it");
assert!(!listed(&Overrides::default(), &entry) && listed(&overrides, &entry));
assert!(needs_a_value("document.setUnits"));
assert!(crate::palette::items().iter().all(|(_, id, _)| id != "document.setUnits"));
}
}
+4 -2
View File
@@ -205,11 +205,13 @@ fn show_in_folder_needs_a_saved_document_and_a_file_manager() {
assert_eq!(*shown.borrow(), ["/art/a.vectorcraft"]);
}
/// The palette lists neither the old alias nor `file.documentColorMode`, which a pick can't run
/// without a mode; the CMYK and RGB menu items run the one command.
#[test]
fn the_palette_lists_document_color_mode_once() {
fn document_color_mode_is_one_command() {
let items = palette::items();
let ids: Vec<&str> = items.iter().map(|(_, id, _)| id.as_str()).filter(|id| id.to_ascii_lowercase().contains("documentcolormode")).collect();
assert_eq!(ids, ["file.documentColorMode"]);
assert!(ids.is_empty(), "{ids:?}");
let mut app = app();
app.run("file.new", json!({})).unwrap();
let entries = menus::menu_entries(&app);
+1 -1
View File
@@ -327,7 +327,7 @@ mod tests {
let has = |s: &str| texts.iter().any(|t| t == s);
assert_eq!(has("Discord"), width > 1000.0, "{width}: {texts:?}");
// Search is an icon only (as in PhotoCraft): its label lives in the tooltip.
assert!(!has("Search commands and tools"), "{width}: {texts:?}");
assert!(!has("Search commands, tools, panels and effects"), "{width}: {texts:?}");
}
}
+5
View File
@@ -1327,6 +1327,11 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
The panel menu's Save Selection submenu has Save Selection…, Update Selection and Edit Selection…, enabled and run as in the Select menu, and lists the document's saved selections: choosing one selects its objects again (`select.recall`).
Deleting rows from the Layers panel (the trash button, rows dragged onto it, the panel menu's Delete Selection, and Delete or Backspace on highlighted rows) asks "Delete this layer and its artwork?" when a layer or sublayer among them holds art, hidden, locked and nested art included, and "Delete the selected items and their artwork?" when several rows are deleted; OK deletes the rows it asked about in one undo step, and Cancel keeps them (`ui.layerDelete`). The help page's shortcut list names the Layers panel as the place where deleting asks for confirmation ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). An empty layer, a layer with only guides, and groups or objects alone are deleted without a question, and `layer.delete` itself does not ask (`panels::layers` tests `deleting_a_layer_that_holds_art_asks_first`, `delete_selection_asks_only_for_layers_with_art`).
The Command Palette lists Window › Layers › Delete Selection once, as the Layers panel's `ui.layerDelete`, so a pick asks the same question; it does not list `layer.delete`, which scripts run without a question. New Brush…, Brush Options…, Symbol Options…, Import SVG Filter… and Convert to Text are also listed once each, as the UI command that opens the dialog or file chooser (`palette` tests `a_wrapped_engine_command_is_listed_once_as_its_ui_command`, `a_pick_of_delete_selection_asks_before_deleting_a_layer_with_art`).
No two Command Palette results for different commands, tools or plug-ins show the same name, in English or in any language with a complete menu catalog. Results that would share a name show the panel, menu or command they belong to (Export › Continue in Background and Open › Continue in Background, View › Rulers › Show Rulers and View › Perspective Grid › Show Rulers, Layers › Panel Options… and Navigator › Panel Options…, Tools › Knife and Path › Knife); results that still share one show their id after it (Ellipse (shape.ellipse) and Ellipse (addon.shapes.ellipse)), as two filter plug-ins with one name do. A query still finds a result by its name without the added path. Batch…, Flattener Preview and the four Other Library… commands are listed once each as their UI command, and Place… and Print… once each (`palette` tests `different_results_show_different_names`, `results_that_share_a_name_show_where_they_belong`, `filter_plugins_with_one_name_show_their_ids`, `each_id_is_one_result`, `a_pick_of_a_renamed_result_runs_its_own_command`).
The Command Palette leaves out the engine commands that Edit › Keyboard Shortcuts marks as needing a value: a query with no default key and no menu bar item (Document JSON, Select All Unused in the Brushes panel), and a command that needs a value no menu item gives (Window › Transparency's `transparency.set`, Document Setup's units). Of those, it still lists the ones whose pick does something without params: Stop Script, Clear Script Console, Clear Plug-in Cache, Reset Preferences, Forget Import Matches, Begin Undo Group and End Undo Group, the six Save … Preset commands, Delete Gradient Preset, Pixel Snapping Options…, the Asset Export commands, New Symbol, Gradient Vector, Define Perspective Grid and Select Slice. Each panel is a result under Window › Show Panel, whose pick shows the panel and leaves one already showing as it is, and each Effect menu item is a result, named as the menu names it, whose pick runs what its menu item runs; while the item is dimmed, no dialog opens and the status line says why. A query of "layers" shows the Layers panel first. The search field's hint and the app bar's search tooltip say "Search commands, tools, panels and effects" (`palette` tests `the_palette_leaves_out_the_commands_a_pick_cannot_run`, `a_pick_of_a_session_command_runs_it`, `a_panel_is_a_result_whose_pick_shows_it`, `an_effect_is_a_result_whose_pick_runs_its_menu_item`; `shortcut_editor` test `a_command_given_a_key_that_needs_a_value_is_no_pick`).
The Command Palette shows each result as a 20-point row, with no gap between rows, and shows 12 rows at a time in a list that scrolls; a short window shows fewer. A name too long for its row ends with "…". The list holds up to 50 results, and the line under it says how many matched ("14 results", "50 of 120 results. Keep typing to narrow them." or "No commands match"). Up and Down move the highlight and wrap at the ends, Page Up and Page Down move it by the rows shown and stop at the ends, and the highlighted row scrolls into view; after a scroll with the wheel, the highlight moves to the nearest row in view. A click anywhere on a row runs it. Screen readers stay on the search field, whose description names the highlighted result and its place among every match ("2 of 14: …", or "2 of 120: …" when the list holds 50); the rows are list items, the highlighted one selected, and the keyboard focus goes back to where it was when the palette closes, unless a pick opened a dialog (`palette` tests `results_are_compact_rows_that_touch`, `the_footer_counts_the_results`, `with_no_match_enter_runs_nothing`, `the_sixteenth_result_is_reached_by_keyboard_and_runs`, `page_keys_move_by_a_page_without_wrapping`, `a_wheel_scroll_keeps_the_highlight_in_view`, `the_row_under_the_pointer_is_the_one_highlighted`, `a_long_name_ends_with_an_ellipsis`, `the_popup_stays_inside_a_short_window`, `a_click_anywhere_on_a_row_runs_it`, `screen_readers_hear_the_highlighted_result_and_the_count`, `closing_gives_the_focus_back`).
A press of any pointer button outside the Command Palette closes it: a click, a right-click or the start of a drag. While the palette is open, the canvas, the toolbars, the docked panels and the app bar under it do not respond to the pointer, so the press that closes the palette does not press a tool button or another control there. A window drawn above them, such as a progress window, still gets its click, and that click also closes the palette (`palette` tests `a_click_on_the_canvas_closes_the_palette`, `a_click_on_another_control_closes_the_palette_without_pressing_it`, `a_right_click_or_a_drag_outside_closes_the_palette`, `a_click_on_a_window_above_closes_the_palette_and_reaches_it`, `the_click_that_opens_the_palette_does_not_close_it`).
The Command Palette ranks its results by how well they match. A query that is a result's id lists that result first (`view.goto1` lists Saved View 1 above Saved View 10); then come results whose name is the query, results whose name without its menu path starts with it, and results whose initials it is ("ea" finds Export As…). Within each of those, a result where every word of the query is a whole word of its name ranks above one where a word only starts a word of the name, then one where it is a word of the menu that holds it, then of its id, then text inside a word, so a query that is a menu's title ("object") lists results named with that word above the items of that menu. A tool ranks above a menu command, panel, effect or filter plug-in that matches as well, so "rect" lists the Rectangle Tool above Effect › Convert to Shape › Rectangle…, and of two results of the same kind the shorter name comes first. Words of the menu bar item that runs a result also find it, the item's own label included ("exit" finds Quit VectorCraft, which File › Exit runs); with the native macOS menu bar, the items that bar moves into its application menu are found under it (Preferences… under Settings). Every result the earlier search found is still found, and the highlight stays on its result when a plug-in is installed, a shortcut changes or the language changes while the palette is open (`palette::search` tests `a_better_word_grade_ranks_first`, `a_better_whole_query_tier_ranks_first`, `kind_and_length_never_lift_a_worse_grade`, `a_menu_title_does_not_lift_its_items`, `common_queries_list_the_command_near_the_top`, `every_result_is_found_first_by_its_name_and_its_id`, `every_result_found_before_is_still_found_and_shown`, `results_know_their_place_in_the_menu_bar`, `native_homes_follow_the_native_application_menu`; `palette` test `the_highlight_stays_on_its_result_when_the_results_change`).
`object.setProps` with `visible: false` or `locked: true` deselects every selected object that is then hidden or locked, the key object included, as the eye and lock columns do.
Ctrl/Cmd+Alt-clicking an eye switches the other layers to Outline and the row's layer to Preview, or switches all layers back to Preview when the others are in Outline (`layer.outlineOthers`, `layer.previewAll`).
Ctrl/Cmd+Alt-clicking New Layer adds a layer directly below the current layer, at its level (`layer.new {below: true}`), and Ctrl/Cmd+Alt-clicking New Sublayer adds a sublayer under the contents of the layer it goes into (`layer.newSublayer {bottom: true}`), each in one undo step. The reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists these clicks for placing a layer below the selected layer and a new sublayer at the bottom of the layer list.