mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 02:42:47 +00:00
Command Palette: a menu's title no longer lifts every item in that menu
A query that is a menu's title ("object", "effect", "select") put
every item of that menu in the starts-with tier, because the tier also
read each name with its menu path. Such items now rank by the word
grades like the rest, below results whose label holds the query as a
word. A query that holds `›` still starts a name with its menu path.
- A new test checks that the native Mac menu bar's application menu
holds the items the palette places there, under the same submenus.
- The Drop Shadow query checks the exact effect, and the test of common
queries is renamed to say that some only need to be near the top.
- docs/target-app-parity.md: the earlier palette line no longer states
the old ranking rule, and the new line gives the kind of result as
the reason "rect" lists the Rectangle Tool first.
This commit is contained in:
@@ -238,7 +238,8 @@ pub(crate) fn kind(id: &str, home: Option<&str>) -> u8 {
|
||||
}
|
||||
|
||||
/// 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.
|
||||
/// `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;
|
||||
@@ -248,7 +249,9 @@ fn phrase(e: &Entry, query: &str, initials: bool) -> u8 {
|
||||
if labels().any(|l| l == query || l.trim_end_matches('…') == trimmed) {
|
||||
return EXACT_LABEL;
|
||||
}
|
||||
if labels().any(|l| l.starts_with(query)) {
|
||||
// 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 {
|
||||
@@ -457,9 +460,65 @@ mod tests {
|
||||
assert_eq!(ranked(&c, "same zz"), ranked(&c, "same zz"));
|
||||
}
|
||||
|
||||
/// Queries from the list of things people type, on the English results.
|
||||
/// 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 common_queries_list_the_command_first() {
|
||||
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);
|
||||
@@ -471,7 +530,7 @@ mod tests {
|
||||
assert!(effect.is_some() && tool < effect, "{tool:?} {effect:?}");
|
||||
assert!(within("type", "tool:type", 2));
|
||||
assert!(within("layers", "panel:layers", 3));
|
||||
assert!(first("drop shadow").starts_with("effect:"), "{}", first("drop shadow"));
|
||||
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));
|
||||
|
||||
@@ -1253,10 +1253,10 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
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. Results whose name without its menu path is the whole query come first, so "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 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 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. A tool ranks above a menu command, panel, effect or filter plug-in that matches as well, and a shorter name above a longer one, so "rect" lists the Rectangle Tool above Effect › Convert to Shape › Rectangle…. 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), read from the native menu bar when the app uses it. 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`, `common_queries_list_the_command_first`, `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`; `palette` test `the_highlight_stays_on_its_result_when_the_results_change`).
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user