Skip to content

Visual Studio Code, rebuilt in Rust

Rust

test(windows): press and label keys per OS in workbench tests

rokartur036f164bdeac
diff --git a/native/crates/app/src/keybindings_editor/tests.rs b/native/crates/app/src/keybindings_editor/tests.rs
index 302d9a40ef2..e81545c3d80 100644
--- a/native/crates/app/src/keybindings_editor/tests.rs
+++ b/native/crates/app/src/keybindings_editor/tests.rs
@@ -173,7 +173,7 @@ fn filter_by_command_and_when() {
let items = [item("a1", "escape", Some("context1 && context2"), true), item("a1", "alt+escape", Some("whenContext1"), true)];
let model = model(&items, &[], &[]);
let actual = model.fetch("@command:a1 +when:whenContext1", false);
- assert_eq!(actual.iter().map(|entry| keybindings::label(&entry.row.keybinding)).collect::<Vec<_>>(), ["⌥Escape"]);
+ assert_eq!(actual.iter().map(|entry| keybindings::label(&entry.row.keybinding)).collect::<Vec<_>>(), [keybindings::label(&keybindings::parse_keybinding("alt+escape"))]);
let actual = model.fetch("@command:a1 +when:other", false);
assert_eq!(actual.iter().map(|entry| (entry.row.keybinding.is_empty(), entry.row.when.as_str(), entry.row.is_default)).collect::<Vec<_>>(), [(true, "other", false)]);
}
diff --git a/native/crates/app/src/system_wide_keybindings/tests.rs b/native/crates/app/src/system_wide_keybindings/tests.rs
index 71f60b08aaa..e63e198d1ad 100644
--- a/native/crates/app/src/system_wide_keybindings/tests.rs
+++ b/native/crates/app/src/system_wide_keybindings/tests.rs
@@ -20,7 +20,12 @@ fn candidate(accelerator: &str, key: &str, command: &str, args: Option<serde_jso
}
fn rejection(command: &str, label: &str) -> Rejection {
- Rejection { command: command.into(), user_settings_label: label.into() }
+ Rejection { command: command.into(), user_settings_label: meta(label) }
+}
+
+/// The Meta key as this OS names it: Electron's `Cmd` and the label's `cmd` on macOS, `Super` and `win` on Windows.
+fn meta(text: &str) -> String {
+ if cfg!(windows) { text.replace("Cmd", "Super").replace("cmd", "win") } else { text.to_owned() }
}
#[test]
@@ -34,7 +39,7 @@ fn selects_only_user_system_wide_single_combo_bindings_and_preserves_args_and_wh
]));
items[2].is_default = true;
- let expected = Selection { candidates: vec![candidate("Ctrl+Cmd+A", "ctrl+cmd+a", "workbench.action.openAgentsWindow", Some(json!({ "foo": 1 })), true)], ..Selection::default() };
+ let expected = Selection { candidates: vec![candidate(&meta("Ctrl+Cmd+A"), &meta("ctrl+cmd+a"), "workbench.action.openAgentsWindow", Some(json!({ "foo": 1 })), true)], ..Selection::default() };
assert_eq!(select(&items), expected);
}
@@ -57,16 +62,16 @@ fn keeps_the_first_binding_on_accelerator_conflicts() {
{ "key": "cmd+a", "command": "second.loses", "systemWide": true },
]));
- let expected = Selection { candidates: vec![candidate("Cmd+A", "cmd+a", "first.wins", None, false)], duplicates: vec![rejection("second.loses", "cmd+a")], ..Selection::default() };
+ let expected = Selection { candidates: vec![candidate(&meta("Cmd+A"), &meta("cmd+a"), "first.wins", None, false)], duplicates: vec![rejection("second.loses", "cmd+a")], ..Selection::default() };
assert_eq!(select(&items), expected);
}
#[test]
fn accelerators_use_electrons_key_names() {
let accelerator = |key: &str| crate::keybindings::electron_accelerator(&parse_keybinding(key));
- assert_eq!(accelerator("ctrl+shift+alt+cmd+up"), Some("Ctrl+Shift+Alt+Cmd+Up".into()));
+ assert_eq!(accelerator("ctrl+shift+alt+cmd+up"), Some(meta("Ctrl+Shift+Alt+Cmd+Up")));
assert_eq!(accelerator("alt+delete"), Some("Alt+Delete".into()));
- assert_eq!(accelerator("cmd+;"), Some("Cmd+;".into()));
+ assert_eq!(accelerator("cmd+;"), Some(meta("Cmd+;")));
assert_eq!(accelerator("ctrl+f19"), Some("Ctrl+F19".into()));
}
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index caaf76668d1..d5ab545638a 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -2367,7 +2367,9 @@ mod tests {
let editors = workbench.read_with(cx, |workbench, _| {
workbench.editors.editors.iter().map(|editor| (editor.document().uri_string(), editor.preview, editor.document().lines[..2].join("\n"))).collect::<Vec<_>>()
});
- let expected = |name: &str| (format!("untitled:{name}"), false, "{\n\t\"layout\": {".to_string());
+ // Windows has no layout data yet: port/ledger.md M24 row app/src/keyboard_layout.rs:7.
+ let layout = if cfg!(windows) { "null," } else { "{" };
+ let expected = |name: &str| (format!("untitled:{name}"), false, format!("{{\n\t\"layout\": {layout}"));
assert_eq!(editors, [expected("Untitled-1"), expected("Untitled-2")]);
}
@@ -2394,13 +2396,13 @@ mod tests {
cx.simulate_keystrokes("down end");
cx.simulate_input("!");
assert_eq!(text(cx), "ab\ncd!");
- cx.simulate_keystrokes("shift-home cmd-c");
+ cx.simulate_keystrokes("shift-home secondary-c");
assert_eq!(cx.read_from_clipboard().and_then(|item| item.text()).as_deref(), Some("cd!"));
cx.simulate_keystrokes("backspace");
assert_eq!(text(cx), "ab\n");
- cx.simulate_keystrokes("cmd-z cmd-z enter tab");
+ cx.simulate_keystrokes("secondary-z secondary-z enter tab");
assert_eq!(text(cx), "ab\ncd\n ");
- cx.simulate_keystrokes("cmd-s");
+ cx.simulate_keystrokes("secondary-s");
assert_eq!(std::fs::read_to_string(&file).unwrap(), "ab\ncd\n ");
assert!(workbench.read_with(cx, |workbench, _| !workbench.editors.active().unwrap().is_dirty()));
let methods: Vec<_> = receiver.try_iter().map(|message| message.method).collect();
@@ -2434,12 +2436,12 @@ mod tests {
});
receiver.try_iter().count();
- cx.simulate_keystrokes("cmd-s");
+ cx.simulate_keystrokes("secondary-s");
assert_eq!(std::fs::read_to_string(&file).unwrap(), "ab\ncd\n");
assert!(workbench.read_with(cx, |workbench, _| !workbench.editors.active().unwrap().is_dirty()));
let methods: Vec<_> = receiver.try_iter().map(|message| message.method).collect();
assert_eq!(methods.iter().filter(|method| **method == "$acceptModelChanged").count(), 2);
- cx.simulate_keystrokes("cmd-z");
+ cx.simulate_keystrokes("secondary-z");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().lines.join("\n")), "ab \ncd\n\n\n");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2471,11 +2473,13 @@ mod tests {
};
// wordHighlighter.ts stops the highlights once no code editor has the focus.
- cx.simulate_keystrokes("ctrl-shift-m tab");
+ // toggleTabFocusMode.ts: Ctrl+M outside macOS.
+ let toggle_tab_focus = if cfg!(target_os = "macos") { "ctrl-shift-m tab" } else { "ctrl-m tab" };
+ cx.simulate_keystrokes(toggle_tab_focus);
assert_eq!(state(cx), ("ab".to_string(), 0, true, Some(json!(true))));
cx.simulate_keystrokes("shift-tab");
assert_eq!(state(cx), ("ab".to_string(), 1, false, Some(json!(true))));
- cx.simulate_keystrokes("ctrl-shift-m tab");
+ cx.simulate_keystrokes(toggle_tab_focus);
assert_eq!(state(cx), (" ab".to_string(), 0, false, Some(json!(false))));
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2490,8 +2494,11 @@ mod tests {
let file = dir.join("a.txt");
std::fs::write(&file, "abc").unwrap();
let user_file = dir.join("keybindings.json");
- let rules = r#"// keybindings.json is JSONC
- [{ "key": "end", "command": "-cursorEnd" }, { "key": "cmd+k cmd+e", "command": "cursorEnd", "when": "editorTextFocus && mine" }]"#;
+ let primary = if cfg!(target_os = "macos") { "cmd" } else { "ctrl" };
+ let rules = format!(
+ r#"// keybindings.json is JSONC
+ [{{ "key": "end", "command": "-cursorEnd" }}, {{ "key": "{primary}+k {primary}+e", "command": "cursorEnd", "when": "editorTextFocus && mine" }}]"#
+ );
std::fs::write(&user_file, rules).unwrap();
let (workbench, cx) = cx.add_window_view(|window, cx| {
let mut workbench = Workbench::new(theme, app_root.clone(), None, Languages::new(&[]), crate::default_settings(), HostSync::new(std::sync::mpsc::channel().0), cx);
@@ -2505,18 +2512,19 @@ mod tests {
cx.simulate_keystrokes("end");
assert_eq!(column(cx), 0, "the user removed the default End binding");
- cx.simulate_keystrokes("cmd-k cmd-e");
+ cx.simulate_keystrokes("secondary-k secondary-e");
assert_eq!(column(cx), 0, "the chord's when clause needs the `mine` context key");
workbench.update_in(cx, |workbench, window, cx| workbench.execute_command("_setContext", vec!["mine".into(), true.into()], window, cx));
- cx.simulate_keystrokes("cmd-k");
- assert_eq!(status(cx).as_deref(), Some("(⌘K) was pressed. Waiting for second key of chord..."));
- cx.simulate_keystrokes("cmd-e");
+ cx.simulate_keystrokes("secondary-k");
+ let ctrl_k = if cfg!(target_os = "macos") { "⌘K" } else { "Ctrl+K" };
+ assert_eq!(status(cx), Some(format!("({ctrl_k}) was pressed. Waiting for second key of chord...")));
+ cx.simulate_keystrokes("secondary-e");
assert_eq!(column(cx), 3);
assert_eq!(status(cx), None, "leaving chord mode drops its message");
- cx.simulate_keystrokes("cmd-k x");
+ cx.simulate_keystrokes("secondary-k x");
let message = workbench.read_with(cx, |workbench, _| workbench.status_message.as_ref().map(|(message, _)| message.clone()));
- assert_eq!(message.as_deref(), Some("The key combination (⌘K, X) is not a command."));
- cx.simulate_keystrokes("cmd-k cmd-w");
+ assert_eq!(message, Some(format!("The key combination ({ctrl_k}, X) is not a command.")));
+ cx.simulate_keystrokes("secondary-k secondary-w");
assert!(workbench.read_with(cx, |workbench, _| workbench.editors.editors.is_empty()), "workbench.action.closeAllEditors");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2541,28 +2549,31 @@ mod tests {
let hidden = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().folding.hidden().to_vec());
let cursors = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().selections.len());
- cx.simulate_keystrokes("cmd-k cmd-0");
+ cx.simulate_keystrokes("secondary-k secondary-0");
assert_eq!(hidden(cx), [1..4, 5..6], "editor.foldAll");
- cx.simulate_keystrokes("cmd-k cmd-j");
+ cx.simulate_keystrokes("secondary-k secondary-j");
assert!(hidden(cx).is_empty(), "editor.unfoldAll");
- cx.simulate_keystrokes("alt-cmd-[");
+ // folding.ts: editor.fold and editor.unfold are Ctrl+Shift+[ and ] outside macOS.
+ let (fold, unfold) = if cfg!(target_os = "macos") { ("alt-cmd-[", "alt-cmd-]") } else { ("ctrl-shift-[", "ctrl-shift-]") };
+ cx.simulate_keystrokes(fold);
assert_eq!(hidden(cx), [1..4], "editor.fold");
- cx.simulate_keystrokes("alt-cmd-]");
+ cx.simulate_keystrokes(unfold);
assert!(hidden(cx).is_empty(), "editor.unfold");
- cx.simulate_keystrokes("down cmd-k cmd-[");
+ cx.simulate_keystrokes("down secondary-k secondary-[");
assert_eq!(hidden(cx), [2..3], "editor.foldRecursively");
- cx.simulate_keystrokes("cmd-k cmd-]");
+ cx.simulate_keystrokes("secondary-k secondary-]");
assert!(hidden(cx).is_empty(), "editor.unfoldRecursively");
- cx.simulate_keystrokes("alt-cmd-down");
+ cx.simulate_keystrokes("alt-secondary-down");
assert_eq!(cursors(cx), 2, "editor.action.insertCursorBelow");
cx.simulate_keystrokes("escape");
assert_eq!(cursors(cx), 1, "removeSecondaryCursors wins over cancelSelection with several cursors");
// An edit that drops the folded lines changes the visible lines: the host hears the new visibleRanges.
- cx.simulate_keystrokes("up alt-cmd-[");
+ cx.simulate_keystrokes("up");
+ cx.simulate_keystrokes(fold);
receiver.try_iter().count();
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
cx.simulate_input("x");
let visible_ranges: Vec<_> = receiver.try_iter().filter(|message| message.method == "$acceptEditorPropertiesChanged" && !message.args[1]["visibleRanges"].is_null()).collect();
assert_eq!(visible_ranges.len(), 1, "{visible_ranges:?}");
@@ -2588,7 +2599,9 @@ mod tests {
cx.run_until_parked();
// The keys of the pixel-check "folded" window, dispatched like `--screenshot-keys` in main.rs.
cx.update(|window, cx| {
- for key in "cmd-down up alt-cmd-[ up up up up up up up up up up up up alt-cmd-[".split(' ') {
+ // cursorBottom and editor.fold are Ctrl+End and Ctrl+Shift+[ outside macOS.
+ let keys = if cfg!(target_os = "macos") { "cmd-down up alt-cmd-[ up up up up up up up up up up up up alt-cmd-[" } else { "ctrl-end up ctrl-shift-[ up up up up up up up up up up up up ctrl-shift-[" };
+ for key in keys.split(' ') {
window.dispatch_keystroke(gpui::Keystroke::parse(key).unwrap(), cx);
}
});
@@ -2629,14 +2642,14 @@ mod tests {
})
};
- cx.simulate_keystrokes("right cmd-k cmd-b");
+ cx.simulate_keystrokes("right secondary-k secondary-b");
assert_eq!(state(cx).0, Some(Position::new(0, 1)), "editor.action.setSelectionAnchor");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.accessibility.alert.clone().unwrap().0), "Anchor set at 1:2");
cx.simulate_input("ab");
assert_eq!(state(cx).0, Some(Position::new(0, 3)), "typing at the anchor pushes it");
cx.simulate_keystrokes("escape");
assert_eq!(state(cx).0, None, "editor.action.cancelSelectionAnchor");
- cx.simulate_keystrokes("cmd-k cmd-b down cmd-k cmd-k");
+ cx.simulate_keystrokes("secondary-k secondary-b down secondary-k secondary-k");
assert_eq!(state(cx), (None, vec![Selection { anchor: Position::new(0, 3), head: Position::new(1, 3) }]), "editor.action.selectFromAnchorToCursor");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2705,24 +2718,24 @@ mod tests {
cx.run_until_parked();
let lines = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().lines.clone());
- cx.simulate_keystrokes("cmd-/");
+ cx.simulate_keystrokes("secondary-/");
assert_eq!(lines(cx), ["// let a = 1;", " let b = 2;"], "editor.action.commentLine");
- cx.simulate_keystrokes("cmd-/");
+ cx.simulate_keystrokes("secondary-/");
assert_eq!(lines(cx), ["let a = 1;", " let b = 2;"], "editor.action.commentLine removes");
- cx.simulate_keystrokes("cmd-a cmd-k cmd-c");
+ cx.simulate_keystrokes("secondary-a secondary-k secondary-c");
assert_eq!(lines(cx), ["// let a = 1;", "// let b = 2;"], "editor.action.addCommentLine");
- cx.simulate_keystrokes("cmd-k cmd-u");
+ cx.simulate_keystrokes("secondary-k secondary-u");
assert_eq!(lines(cx), ["let a = 1;", " let b = 2;"], "editor.action.removeCommentLine");
cx.simulate_keystrokes("shift-alt-a");
assert_eq!(lines(cx), ["/* let a = 1;", " let b = 2; */"], "editor.action.blockComment");
- cx.simulate_keystrokes("cmd-z");
+ cx.simulate_keystrokes("secondary-z");
assert_eq!(lines(cx), ["let a = 1;", " let b = 2;"], "undo");
let second = dir.join("b.ts");
std::fs::write(&second, "export function main() {\n\treturn 42;\n}\n").unwrap();
cx.update(|window, cx| workbench.update(cx, |workbench, cx| workbench.open_file(second.clone(), true, window, cx)));
cx.run_until_parked();
- cx.simulate_keystrokes("down end cmd-/ shift-alt-a cmd-a cmd-k cmd-c");
+ cx.simulate_keystrokes("down end secondary-/ shift-alt-a secondary-a secondary-k secondary-c");
assert_eq!(lines(cx), ["// export function main() {", "// \t// return 42;/* */", "// }", ""], "the reference's steps");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2750,11 +2763,15 @@ mod tests {
assert_eq!(lines(cx), ["two", "one", "three"], "editor.action.moveLinesDownAction");
cx.simulate_keystrokes("shift-alt-down");
assert_eq!(lines(cx), ["two", "one", "one", "three"], "editor.action.copyLinesDownAction");
- cx.simulate_keystrokes("ctrl-j");
+ // linesOperations.ts binds joinLines on macOS only.
+ match cfg!(target_os = "macos") {
+ true => cx.simulate_keystrokes("ctrl-j"),
+ false => workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("editor.action.joinLines", Vec::new(), window, cx))),
+ }
assert_eq!(lines(cx), ["two", "one", "one three"], "editor.action.joinLines");
- cx.simulate_keystrokes("shift-cmd-k");
+ cx.simulate_keystrokes("shift-secondary-k");
assert_eq!(lines(cx), ["two", "one"], "editor.action.deleteLines");
- cx.simulate_keystrokes("cmd-]");
+ cx.simulate_keystrokes("secondary-]");
assert_eq!(lines(cx), ["two", " one"], "editor.action.indentLines");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2817,7 +2834,7 @@ mod tests {
cx.simulate_input("a");
cx.simulate_keystrokes("shift-tab");
cx.simulate_input("the");
- cx.simulate_keystrokes("alt-cmd-enter");
+ cx.simulate_keystrokes("alt-secondary-enter");
assert_eq!(zone(cx).0, 62.);
let text = workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().lines.join("\n"));
assert_eq!(text, "a cat\nand a dog\na end");
diff --git a/native/crates/app/src/workbench/auxiliary_windows/tests.rs b/native/crates/app/src/workbench/auxiliary_windows/tests.rs
index eea1501e394..8ed959d345d 100644
--- a/native/crates/app/src/workbench/auxiliary_windows/tests.rs
+++ b/native/crates/app/src/workbench/auxiliary_windows/tests.rs
@@ -66,7 +66,7 @@ fn move_editor_into_new_window_opens_a_part_with_the_editor(cx: &mut TestAppCont
// The editor window's keys reach the workbench: Cmd+W closes its last editor, and the window with it.
let handle = editor_window(&workbench, cx);
let mut window_cx = VisualTestContext::from_window(handle, cx);
- window_cx.simulate_keystrokes("cmd-w");
+ window_cx.simulate_keystrokes("secondary-w");
window_cx.run_until_parked();
assert_eq!(parts(&workbench, cx), vec![vec![vec!["a.txt".to_string()]]]);
assert_eq!(cx.windows().len(), 1);
diff --git a/native/crates/app/src/workbench/breadcrumbs/tests.rs b/native/crates/app/src/workbench/breadcrumbs/tests.rs
index 4b9a4fd8094..062386eac8c 100644
--- a/native/crates/app/src/workbench/breadcrumbs/tests.rs
+++ b/native/crates/app/src/workbench/breadcrumbs/tests.rs
@@ -33,7 +33,7 @@ fn the_keyboard_focuses_moves_through_and_reveals_the_breadcrumbs(cx: &mut TestA
};
assert_eq!(state(cx), (None, false, true, Position::new(1, 2)));
- cx.simulate_keystrokes("cmd-shift-;");
+ cx.simulate_keystrokes("secondary-shift-;");
assert_eq!(state(cx), (Some(2), true, false, Position::new(1, 2)), "a.txt, A, run: the last item");
cx.simulate_keystrokes("left left left");
assert_eq!(state(cx).0, Some(0), "the focus stops at the first item");
@@ -42,7 +42,7 @@ fn the_keyboard_focuses_moves_through_and_reveals_the_breadcrumbs(cx: &mut TestA
cx.simulate_keystrokes("space");
assert_eq!(state(cx), (None, false, true, Position::new(0, 6)), "Space reveals A at the start of its name");
- cx.simulate_keystrokes("cmd-shift-; escape");
+ cx.simulate_keystrokes("secondary-shift-; escape");
assert_eq!(state(cx), (None, false, true, Position::new(0, 6)), "Escape focuses the editor");
}
@@ -82,7 +82,7 @@ fn focus_and_select_shows_the_outline_picker(cx: &mut TestAppContext) {
};
let ids = |names: &[&str]| names.iter().map(|name| format!("root/provider_0/{name}")).collect::<Vec<_>>();
- cx.simulate_keystrokes("cmd-shift-.");
+ cx.simulate_keystrokes("secondary-shift-.");
let (picker, active, _) = state(cx);
assert_eq!(picker, Some((2, ids(&["A", "A/run", "A/stop", "B"]), Some(ids(&["A/run"])[0].clone()), true)), "run's picker, A expanded");
assert!(active, "a showing picker keeps breadcrumbsActive");
@@ -159,7 +159,7 @@ fn a_click_shows_the_file_picker(cx: &mut TestAppContext) {
assert_eq!((picker, path), (false, dir.join("b.txt")), "Enter opens b.txt and closes the picker");
cx.simulate_click(file_item, gpui::Modifiers::none());
- cx.simulate_keystrokes("up cmd-enter");
+ cx.simulate_keystrokes("up secondary-enter");
workbench.read_with(cx, |workbench, _| {
let groups = workbench.groups_in_grid_order();
assert_eq!((groups.len(), workbench.editors.id), (2, groups[1]), "revealFocusedFromTreeAside opens to the side");
@@ -181,7 +181,7 @@ fn toggle_to_on_and_use_quick_pick(cx: &mut TestAppContext) {
workbench.reload_changed_settings_files(cx);
});
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-shift-.");
+ cx.simulate_keystrokes("secondary-shift-.");
cx.run_until_parked();
workbench.update(cx, |workbench, _| {
assert_eq!(workbench.setting("breadcrumbs.enabled"), json!(true), "toggleToOn turns the breadcrumbs on");
diff --git a/native/crates/app/src/workbench/comment_node/tests.rs b/native/crates/app/src/workbench/comment_node/tests.rs
index c22619b7cb9..d203ea13344 100644
--- a/native/crates/app/src/workbench/comment_node/tests.rs
+++ b/native/crates/app/src/workbench/comment_node/tests.rs
@@ -42,7 +42,7 @@ fn a_comment_switched_to_editing_runs_the_edit_actions(cx: &mut TestAppContext)
assert_eq!(editing(cx), Some((Some(3), "Looks good".to_owned())));
cx.run_until_parked();
cx.simulate_input("!");
- cx.simulate_keystrokes("cmd-enter");
+ cx.simulate_keystrokes("secondary-enter");
cx.run_until_parked();
let thread = json!({ "$mid": 7, "commentControlHandle": 1, "commentThreadHandle": 7 });
assert_eq!(*ran.lock().unwrap(), vec![json!({ "thread": thread, "commentUniqueId": 3, "text": "Looks good!", "$mid": 11 })]);
diff --git a/native/crates/app/src/workbench/comment_thread_widget/tests.rs b/native/crates/app/src/workbench/comment_thread_widget/tests.rs
index 7f33fcd9db6..b7483668307 100644
--- a/native/crates/app/src/workbench/comment_thread_widget/tests.rs
+++ b/native/crates/app/src/workbench/comment_thread_widget/tests.rs
@@ -83,7 +83,7 @@ fn an_expanded_thread_shows_a_zone_and_replies_run_the_form_actions(cx: &mut Tes
});
cx.simulate_keystrokes("backspace backspace backspace backspace backspace");
assert_eq!(zones(&workbench, cx)[0].1, replying);
- cx.simulate_keystrokes("cmd-enter");
+ cx.simulate_keystrokes("secondary-enter");
cx.run_until_parked();
let thread = json!({ "$mid": 7, "commentControlHandle": 1, "commentThreadHandle": 7 });
assert_eq!(*ran.lock().unwrap(), vec![json!({ "thread": thread, "text": "Agreed\n!", "$mid": 9 })]);
diff --git a/native/crates/app/src/workbench/comments_view.rs b/native/crates/app/src/workbench/comments_view.rs
index 8db917a20c5..d5195ab5e11 100644
--- a/native/crates/app/src/workbench/comments_view.rs
+++ b/native/crates/app/src/workbench/comments_view.rs
@@ -733,7 +733,7 @@ mod tests {
drop(workbench.handle_comments_request("$createCommentThread", &[json!(1), json!(7), json!("t"), resource, range, json!([comment]), json!({ "value": "test.ext" }), json!(false)], window, cx));
drop(workbench.execute_command("workbench.action.focusCommentsPanel", Vec::new(), window, cx));
});
- cx.simulate_keystrokes("cmd-f a n n");
+ cx.simulate_keystrokes("secondary-f a n n");
cx.executor().advance_clock(std::time::Duration::from_millis(300));
cx.simulate_keystrokes("escape");
cx.executor().advance_clock(std::time::Duration::from_millis(300));
@@ -744,7 +744,7 @@ mod tests {
assert_eq!(filter(cx), ("ann".to_owned(), "ann".to_owned()));
let stored = workbench.read_with(cx, |workbench, _| workbench.workspace_storage.lock().unwrap().get(MEMENTO_KEY).map(str::to_owned).unwrap());
assert_eq!(serde_json::from_str::<Value>(&stored).unwrap()["filterHistory"], json!(["ann"]));
- cx.simulate_keystrokes("cmd-down");
+ cx.simulate_keystrokes("secondary-down");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.comments.view.tree_focus.is_focused(window)));
}
diff --git a/native/crates/app/src/workbench/debug_hover/tests.rs b/native/crates/app/src/workbench/debug_hover/tests.rs
index 09858d3f5fb..53c931a1a90 100644
--- a/native/crates/app/src/workbench/debug_hover/tests.rs
+++ b/native/crates/app/src/workbench/debug_hover/tests.rs
@@ -350,7 +350,7 @@ fn a_click_on_a_hover_row_focuses_the_tree(cx: &mut TestAppContext) {
cx.simulate_click(tree.origin + point(px(100.), px(ROW_HEIGHT / 2.)), Modifiers::none());
assert_eq!(state(cx), (true, some("hover/alpha"), some("hover/alpha"), false));
workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), file.parent().unwrap().join("keybindings.json")));
- cx.simulate_keystrokes("cmd-alt-f");
+ cx.simulate_keystrokes("secondary-alt-f");
assert!(workbench.read_with(cx, |workbench, _| workbench.debug_hover.find.open), "Cmd+Alt+F after the click opens the tree's find widget");
std::fs::remove_dir_all(file.parent().unwrap()).unwrap();
}
@@ -385,12 +385,12 @@ fn the_find_widget_filters_the_hover_tree(cx: &mut TestAppContext) {
};
let row = |key: &str, highlights: Vec<Range<usize>>| (key.to_owned(), highlights);
- cx.simulate_keystrokes("cmd-alt-f");
+ cx.simulate_keystrokes("secondary-alt-f");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.debug_hover.find.open && workbench.debug_hover.find.focus.is_focused(window)));
cx.simulate_input("bet");
assert_eq!(rows(cx), [row("hover/alpha", vec![]), row("hover/beta", vec![0..3]), row("hover/gamma", vec![])], "highlight mode keeps every row");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.debug_hover.focused.clone()).as_deref(), Some("hover/beta"));
- cx.simulate_keystrokes("cmd-alt-f");
+ cx.simulate_keystrokes("secondary-alt-f");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.debug_hover.find.input.selected_text()), "bet", "list.find again selects the pattern");
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("list.toggleFindMode", Vec::new(), window, cx)));
diff --git a/native/crates/app/src/workbench/define_keybinding/tests.rs b/native/crates/app/src/workbench/define_keybinding/tests.rs
index f5b4a326c8b..3d60ca9c447 100644
--- a/native/crates/app/src/workbench/define_keybinding/tests.rs
+++ b/native/crates/app/src/workbench/define_keybinding/tests.rs
@@ -131,18 +131,18 @@ fn define_keybinding_inserts_a_rule_into_the_user_keybindings_json(cx: &mut Test
workbench.update_in(cx, |workbench, window, cx| workbench.open_file(dir.join("other.json"), true, window, cx));
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-k cmd-k");
+ cx.simulate_keystrokes("secondary-k secondary-k");
assert!(!workbench.read_with(cx, |workbench, _| workbench.define_widget_shown(true)), "another file has no Define Keybinding");
workbench.update_in(cx, |workbench, window, cx| workbench.open_disk_resource(files::user_data::SCHEME, file.clone(), true, window, cx));
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-k cmd-k");
+ cx.simulate_keystrokes("secondary-k secondary-k");
cx.run_until_parked();
assert!(
workbench.read_with(cx, |workbench, _| workbench.define_widget_shown(true)),
"Cmd+K Cmd+K shows the define widget over keybindings.json"
);
- cx.simulate_keystrokes("cmd-u enter");
+ cx.simulate_keystrokes("secondary-u enter");
let text = workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().lines.join("\n"));
// SmartSnippetInserter puts it right after `[`; the snippet's tabs become the file's 4 spaces.
assert_eq!(text, "[{\n \"key\": \"cmd+u\",\n \"command\": \"commandId\",\n \"when\": \"editorTextFocus\"\n}\n]");
diff --git a/native/crates/app/src/workbench/editor_groups/tests.rs b/native/crates/app/src/workbench/editor_groups/tests.rs
index 4371566764a..a7740608354 100644
--- a/native/crates/app/src/workbench/editor_groups/tests.rs
+++ b/native/crates/app/src/workbench/editor_groups/tests.rs
@@ -68,7 +68,7 @@ fn a_divider_separates_two_inactive_tabs_only(cx: &mut TestAppContext) {
fn split_editor_shows_the_same_model_in_a_new_group_to_the_right(cx: &mut TestAppContext) {
let (_dir, workbench, cx) = workbench_with("split", &["a.txt"], cx);
workbench.update(cx, |workbench, _| workbench.editors.active_mut().unwrap().move_to(Position::new(1, 3), false));
- cx.simulate_keystrokes("cmd-\\");
+ cx.simulate_keystrokes("secondary-\\");
cx.run_until_parked();
assert_eq!(groups(&workbench, cx), (vec![vec!["a.txt".to_string()], vec!["a.txt".to_string()]], 1));
workbench.update(cx, |workbench, _| {
@@ -210,14 +210,14 @@ fn the_output_view_shows_in_the_panel_and_takes_the_focus_from_the_groups(cx: &m
#[gpui::test]
fn close_editors_in_other_groups_leaves_the_active_group(cx: &mut TestAppContext) {
let (_dir, workbench, cx) = workbench_with("close-others", &["a.txt"], cx);
- cx.simulate_keystrokes("cmd-\\");
- cx.simulate_keystrokes("cmd-\\");
+ cx.simulate_keystrokes("secondary-\\");
+ cx.simulate_keystrokes("secondary-\\");
cx.run_until_parked();
assert_eq!(groups(&workbench, cx).0.len(), 3);
run(&workbench, "workbench.action.closeEditorsInOtherGroups", cx);
assert_eq!(groups(&workbench, cx), (vec![vec!["a.txt".to_string()]], 0));
// CloseAllEditorsAction empties every group; the emptied ones close.
- cx.simulate_keystrokes("cmd-\\");
+ cx.simulate_keystrokes("secondary-\\");
run(&workbench, "workbench.action.closeAllEditors", cx);
assert_eq!(groups(&workbench, cx), (vec![Vec::<String>::new()], 0));
}
@@ -225,7 +225,7 @@ fn close_editors_in_other_groups_leaves_the_active_group(cx: &mut TestAppContext
#[gpui::test]
fn the_grid_and_its_editors_come_back_from_workspace_storage(cx: &mut TestAppContext) {
let (_dir, workbench, cx) = workbench_with("part-state", &["a.txt", "b.txt"], cx);
- cx.simulate_keystrokes("cmd-\\");
+ cx.simulate_keystrokes("secondary-\\");
cx.run_until_parked();
run(&workbench, "workbench.action.focusFirstEditorGroup", cx);
let saved = workbench.read_with(cx, |workbench, _| workbench.workspace_storage.lock().unwrap().get("memento/workbench.parts.editor").map(str::to_owned).unwrap());
diff --git a/native/crates/app/src/workbench/editor_menus/tests.rs b/native/crates/app/src/workbench/editor_menus/tests.rs
index 923d378a863..4fa17e178f1 100644
--- a/native/crates/app/src/workbench/editor_menus/tests.rs
+++ b/native/crates/app/src/workbench/editor_menus/tests.rs
@@ -159,14 +159,14 @@ fn pinned_editors_go_first_and_survive_the_mass_closes(cx: &mut TestAppContext)
let sticky = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.editors.iter().map(|editor| editor.sticky).collect::<Vec<_>>());
let active = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().document().name());
workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.editor_focus, cx));
- cx.simulate_keystrokes("cmd-k shift-enter");
+ cx.simulate_keystrokes("secondary-k shift-enter");
assert_eq!(open_names(&workbench, cx), ["c.txt", "a.txt", "b.txt"]);
assert_eq!(sticky(cx), [true, false, false]);
workbench.update_in(cx, |workbench, window, cx| workbench.show_tab_context_menu(0, super::point_anchor(point(px(200.), px(50.))), window, cx));
assert!(menu_titles(&workbench, cx).contains(&"Unpin".to_string()));
cx.simulate_keystrokes("escape");
- cx.simulate_keystrokes("cmd-w");
+ cx.simulate_keystrokes("secondary-w");
assert_eq!(open_names(&workbench, cx).len(), 3, "the keyboard does not close a sticky editor");
assert_eq!(active(cx), "b.txt", "the most recent non-sticky editor opens instead");
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.closeEditorsInGroup", vec![], window, cx)));
@@ -179,7 +179,7 @@ fn pinned_editors_go_first_and_survive_the_mass_closes(cx: &mut TestAppContext)
cx.run_until_parked();
assert_eq!(open_names(&workbench, cx), ["c.txt"]);
workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.editor_focus, cx));
- cx.simulate_keystrokes("cmd-k shift-enter");
+ cx.simulate_keystrokes("secondary-k shift-enter");
assert_eq!(sticky(cx), [false], "the chord unpins a pinned editor");
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.pinEditor", vec![], window, cx)));
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.closeActivePinnedEditor", vec![], window, cx)));
diff --git a/native/crates/app/src/workbench/editor_status.rs b/native/crates/app/src/workbench/editor_status.rs
index 5544d472270..ff1eb73b4ea 100644
--- a/native/crates/app/src/workbench/editor_status.rs
+++ b/native/crates/app/src/workbench/editor_status.rs
@@ -720,7 +720,7 @@ mod tests {
run("workbench.action.editor.changeLanguageMode", cx);
pick("Rust", cx);
- cx.simulate_keystrokes("cmd-s");
+ cx.simulate_keystrokes("secondary-s");
run("workbench.action.editor.changeEncoding", cx);
assert_eq!(labels(cx), ["Reopen with Encoding", "Save with Encoding"]);
pick("Save with Encoding", cx);
diff --git a/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs b/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
index 1c446329c4c..cd47d621ef8 100644
--- a/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/editor_view/merge_editor_view/tests.rs
@@ -202,7 +202,7 @@ fn toggle_between_inputs_moves_the_keyboard_focus(cx: &mut TestAppContext) {
open_with_keybindings(&workbench, &dir, cx);
let focus = |cx: &mut VisualTestContext| workbench.update_in(cx, |workbench, window, _| (workbench.editors.active_merge().unwrap().focused_input, workbench.key_context(window)["isMergeResultEditor"].clone()));
assert_eq!(focus(cx), (None, json!(true)));
- cx.simulate_keystrokes("shift-cmd-t");
+ cx.simulate_keystrokes("shift-secondary-t");
assert_eq!(focus(cx), (Some(Input::One), json!(false)));
cx.simulate_keystrokes("x");
let texts = workbench.read_with(cx, |workbench, _| {
@@ -211,9 +211,9 @@ fn toggle_between_inputs_moves_the_keyboard_focus(cx: &mut TestAppContext) {
(text(&merge.input1.side), text(&merge.result))
});
assert_eq!(texts, ("one\nTWO incoming\nthree".to_string(), "one\ntwo\nthree".to_string()), "a focused input takes no typing");
- cx.simulate_keystrokes("shift-cmd-t");
+ cx.simulate_keystrokes("shift-secondary-t");
assert_eq!(focus(cx), (Some(Input::Two), json!(false)));
- cx.simulate_keystrokes("shift-cmd-t");
+ cx.simulate_keystrokes("shift-secondary-t");
assert_eq!(focus(cx), (Some(Input::One), json!(false)));
std::fs::remove_dir_all(dir).unwrap();
}
diff --git a/native/crates/app/src/workbench/explorer_actions/tests.rs b/native/crates/app/src/workbench/explorer_actions/tests.rs
index 0cb93fb7cfd..efaf2f4f323 100644
--- a/native/crates/app/src/workbench/explorer_actions/tests.rs
+++ b/native/crates/app/src/workbench/explorer_actions/tests.rs
@@ -150,7 +150,7 @@ fn rename_copy_paste_cut_delete_and_undo(cx: &mut TestAppContext) {
cx.run_until_parked();
cx.update(|window, _| window.activate_window());
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
cx.simulate_input("c.txt");
cx.simulate_keystrokes("enter");
cx.run_until_parked();
@@ -158,34 +158,34 @@ fn rename_copy_paste_cut_delete_and_undo(cx: &mut TestAppContext) {
// The renamed row keeps its selection (explorerService.ts renames the model element in place).
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.folder.as_ref().unwrap().selected.clone()), [dir.join("c.txt")]);
- cx.simulate_keystrokes("cmd-c cmd-v");
+ cx.simulate_keystrokes("secondary-c secondary-v");
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy.txt", "c.txt", "sub"]);
select(&workbench, &dir.join("c.txt"), cx);
- cx.simulate_keystrokes("cmd-v");
+ cx.simulate_keystrokes("secondary-v");
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy 2.txt", "c copy.txt", "c.txt", "sub"]);
- cx.simulate_keystrokes("cmd-z");
+ cx.simulate_keystrokes("secondary-z");
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy.txt", "c.txt", "sub"]);
- cx.simulate_keystrokes("shift-cmd-z");
+ cx.simulate_keystrokes("shift-secondary-z");
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy 2.txt", "c copy.txt", "c.txt", "sub"]);
select(&workbench, &dir.join("c copy 2.txt"), cx);
- cx.simulate_keystrokes("cmd-x");
+ cx.simulate_keystrokes("secondary-x");
assert!(workbench.read_with(cx, |workbench, _| workbench.folder.as_ref().unwrap().is_cut(&dir.join("c copy 2.txt"))));
select(&workbench, &dir.join("sub"), cx);
- cx.simulate_keystrokes("cmd-v");
+ cx.simulate_keystrokes("secondary-v");
cx.run_until_parked();
assert_eq!(names(&dir.join("sub")), ["c copy 2.txt"]);
select(&workbench, &dir.join("c copy.txt"), cx);
- cx.simulate_keystrokes("alt-cmd-backspace");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "alt-cmd-backspace" } else { "shift-delete" });
cx.run_until_parked();
assert_eq!(names(&dir), ["c.txt", "sub"]);
- cx.simulate_keystrokes("cmd-z");
+ cx.simulate_keystrokes("secondary-z");
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy.txt", "c.txt", "sub"], "undo restores the deleted file");
std::fs::remove_dir_all(&dir).unwrap();
@@ -200,7 +200,7 @@ fn cmd_v_pastes_the_files_finder_copied(cx: &mut TestAppContext) {
std::fs::write(finder.join("from-finder.txt"), "finder").unwrap();
select(&workbench, &dir.join("sub"), cx);
cx.write_to_clipboard(gpui::ClipboardItem { entries: vec![gpui::ClipboardEntry::ExternalPaths(gpui::ExternalPaths(vec![finder.join("from-finder.txt")].into()))] });
- cx.simulate_keystrokes("cmd-v");
+ cx.simulate_keystrokes("secondary-v");
cx.run_until_parked();
assert_eq!(names(&dir.join("sub")), ["from-finder.txt"]);
assert_eq!(std::fs::read_to_string(dir.join("sub/from-finder.txt")).unwrap(), "finder");
@@ -305,14 +305,16 @@ fn copy_path_copies_the_selected_items_paths(cx: &mut TestAppContext) {
let (dir, workbench, cx) = explorer("explorer-copy-path", cx);
let clipboard = |cx: &mut VisualTestContext| cx.read_from_clipboard().and_then(|item| item.text()).unwrap();
select(&workbench, &dir.join("sub"), cx);
- cx.simulate_keystrokes("alt-cmd-c");
+ // fileCommands.ts: Shift+Alt+C and Ctrl+K Ctrl+Shift+C on Windows.
+ let (copy_path, copy_relative_path) = if cfg!(target_os = "macos") { ("alt-cmd-c", "shift-alt-cmd-c") } else { ("shift-alt-c", "ctrl-k ctrl-shift-c") };
+ cx.simulate_keystrokes(copy_path);
assert_eq!(clipboard(cx), dir.join("sub").to_string_lossy());
- cx.simulate_keystrokes("shift-alt-cmd-c");
+ cx.simulate_keystrokes(copy_relative_path);
assert_eq!(clipboard(cx), "sub");
workbench.update(cx, |workbench, _| workbench.folder.as_mut().unwrap().click_select(&dir.join("a.txt"), true, false));
- cx.simulate_keystrokes("shift-alt-cmd-c");
- assert_eq!(clipboard(cx), "sub\na.txt");
+ cx.simulate_keystrokes(copy_relative_path);
+ assert_eq!(clipboard(cx), if cfg!(windows) { "sub\r\na.txt" } else { "sub\na.txt" });
let user = std::env::temp_dir().join(format!("code-gpui-copy-path-user-{}", std::process::id()));
let settings = config::service::Settings::load(config::registry::Registry::with_extensions(&[]), user.clone(), None);
workbench.update(cx, |workbench, _| {
@@ -321,7 +323,7 @@ fn copy_path_copies_the_selected_items_paths(cx: &mut TestAppContext) {
});
std::fs::create_dir_all(dir.join("sub/deep")).unwrap();
workbench.update_in(cx, |workbench, window, cx| workbench.select_explorer_item(&dir.join("sub/deep"), window, cx));
- cx.simulate_keystrokes("shift-alt-cmd-c");
+ cx.simulate_keystrokes(copy_relative_path);
assert_eq!(clipboard(cx), "sub\\deep");
std::fs::remove_dir_all(&dir).unwrap();
std::fs::remove_dir_all(&user).unwrap();
@@ -732,7 +734,7 @@ fn view_title_and_file_actions_collapse_reveal_and_copy_the_active_file(cx: &mut
select(&workbench, &dir.join("sub"), cx);
run(&workbench, "workbench.action.files.copyPathOfActiveFile", cx);
- assert_eq!(cx.read_from_clipboard().and_then(|item| item.text()).unwrap(), dir.join("sub/inner/x.txt").to_string_lossy(), "the active editor's path, not the selection's");
+ assert_eq!(cx.read_from_clipboard().and_then(|item| item.text()).unwrap(), dir.join("sub").join("inner").join("x.txt").to_string_lossy(), "the active editor's path, not the selection's");
std::fs::remove_dir_all(&dir).unwrap();
std::fs::remove_dir_all(&user).unwrap();
}
@@ -760,7 +762,7 @@ fn keys_move_the_focus_expand_collapse_select_and_open(cx: &mut TestAppContext)
assert_eq!(focused(&workbench, cx), Some(dir.join("sub/b.txt")));
assert_eq!(selected(cx), [dir.join("sub/b.txt")], "shift-up adds the row it moves to");
cx.simulate_keystrokes("home");
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
assert_eq!(selected(cx), [dir.join("sub"), dir.join("sub/b.txt"), dir.join("a.txt")]);
cx.simulate_keystrokes("escape");
assert_eq!(selected(cx), Vec::<PathBuf>::new(), "escape clears a multi-selection and keeps the focus");
@@ -770,12 +772,12 @@ fn keys_move_the_focus_expand_collapse_select_and_open(cx: &mut TestAppContext)
let active = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().map(|editor| editor.document().path.clone()));
assert_eq!(active(cx), Some(dir.join("a.txt")), "space opens a file");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.explorer.focus.is_focused(window)), "space keeps the focus");
- cx.simulate_keystrokes("up cmd-down");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "up cmd-down" } else { "up enter" });
assert_eq!(active(cx), Some(dir.join("sub/b.txt")), "cmd-down opens a file and passes the focus");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.editor_focus.is_focused(window)));
workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.explorer.focus.clone(), cx));
- cx.simulate_keystrokes("cmd-left");
+ cx.simulate_keystrokes("secondary-left");
assert_eq!(rows(&workbench, cx), ["sub", "a.txt"], "cmd-left collapses every folder");
std::fs::remove_dir_all(&dir).unwrap();
}
@@ -826,7 +828,7 @@ fn find_filters_the_tree_by_a_file_search_and_restores_it_on_close(cx: &mut Test
std::fs::write(dir.join("sub/needle.rs"), "").unwrap();
std::fs::write(dir.join("other.md"), "").unwrap();
select(&workbench, &dir.join("a.txt"), cx);
- cx.simulate_keystrokes("alt-cmd-f");
+ cx.simulate_keystrokes("alt-secondary-f");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.explorer.find.is_open() && workbench.explorer.find.focus.is_focused(window)));
// Highlight mode keeps every row; no row's name matches, so the focus stays.
@@ -846,7 +848,7 @@ fn find_filters_the_tree_by_a_file_search_and_restores_it_on_close(cx: &mut Test
assert_eq!(rows(&workbench, cx), ["sub", "a.txt", "other.md"], "the session's view state comes back");
assert_eq!(focused(&workbench, cx), Some(dir.join("a.txt")));
- cx.simulate_keystrokes("alt-cmd-f");
+ cx.simulate_keystrokes("alt-secondary-f");
settle_find(cx);
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.explorer.find.input.value.clone()), "needle", "the widget reopens with the last pattern");
assert_eq!(rows(&workbench, cx), ["sub", "needle.rs"]);
diff --git a/native/crates/app/src/workbench/file_compare/tests.rs b/native/crates/app/src/workbench/file_compare/tests.rs
index 69b394b3015..8bac46630a9 100644
--- a/native/crates/app/src/workbench/file_compare/tests.rs
+++ b/native/crates/app/src/workbench/file_compare/tests.rs
@@ -42,7 +42,7 @@ fn the_compare_commands_open_diff_editors(cx: &mut TestAppContext) {
workbench.update_in(cx, |workbench, window, cx| workbench.open_file(a.clone(), true, window, cx));
assert!(ruler_background(cx).is_some(), "the ruler hides the minimap's highlights");
cx.simulate_input("x");
- cx.simulate_keystrokes("cmd-k d");
+ cx.simulate_keystrokes("secondary-k d");
cx.run_until_parked();
assert_eq!(ruler_background(cx), None, "a diff's side has no minimap, so its line backgrounds show under the ruler");
let has_symbols = workbench.update(cx, |workbench, _| {
diff --git a/native/crates/app/src/workbench/find_widget/tests.rs b/native/crates/app/src/workbench/find_widget/tests.rs
index bdcb6ef9d47..068e0541a0b 100644
--- a/native/crates/app/src/workbench/find_widget/tests.rs
+++ b/native/crates/app/src/workbench/find_widget/tests.rs
@@ -44,7 +44,7 @@ fn find_on_type_and_cursor_move_on_type_off_wait_for_enter(cx: &mut TestAppConte
};
assert_eq!(found(cx), ("and".into(), 1, (1, 0)), "seeded from the word at the cursor");
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
cx.simulate_input("dog");
assert_eq!(found(cx), ("and".into(), 1, (1, 0)), "typing does not search");
cx.simulate_keystrokes("enter");
@@ -147,7 +147,7 @@ fn each_group_keeps_its_own_find_widget_and_shares_the_history(cx: &mut TestAppC
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.editors.id), right);
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("actions.find", vec![], window, cx)));
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
cx.simulate_input("dog");
cx.executor().advance_clock(std::time::Duration::from_millis(500));
cx.run_until_parked();
diff --git a/native/crates/app/src/workbench/keybindings_editor_view/tests.rs b/native/crates/app/src/workbench/keybindings_editor_view/tests.rs
index a9d22c08bd2..62bbc43a657 100644
--- a/native/crates/app/src/workbench/keybindings_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/keybindings_editor_view/tests.rs
@@ -95,7 +95,7 @@ fn a_column_width_must_be_an_integer_percentage() {
#[gpui::test]
fn resize_column_sets_the_picked_column_to_a_percentage_of_the_table(cx: &mut TestAppContext) {
let (workbench, cx, _) = keybindings_editor_window(cx, "resize-column", "");
- cx.simulate_keystrokes("cmd-k cmd-s");
+ cx.simulate_keystrokes("secondary-k secondary-s");
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("keybindings.editor.focusKeybindings", Vec::new(), window, cx)));
cx.run_until_parked();
let width = workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.columns.size());
@@ -190,7 +190,7 @@ fn search(workbench: &gpui::Entity<Workbench>, query: &str, cx: &mut VisualTestC
#[gpui::test]
fn keys_define_a_keybinding_that_lands_in_keybindings_json(cx: &mut TestAppContext) {
let (workbench, cx, file) = keybindings_editor_window(cx, "define", "");
- cx.simulate_keystrokes("cmd-k cmd-s");
+ cx.simulate_keystrokes("secondary-k secondary-s");
assert!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.open));
assert!(shown_commands(&workbench, cx).len() > 100, "every command is listed");
@@ -198,13 +198,13 @@ fn keys_define_a_keybinding_that_lands_in_keybindings_json(cx: &mut TestAppConte
// define widget closes the modal, as in 1.147.0: its capture listener runs closeModalEditor first.
cx.simulate_input("copy");
filter(cx);
- cx.simulate_keystrokes("cmd-down");
+ cx.simulate_keystrokes("secondary-down");
assert!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.open), "Cmd+Down keeps the modal");
cx.simulate_keystrokes("enter");
assert!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.define.is_some()), "Enter in the table opens the define widget");
cx.simulate_keystrokes("escape");
assert!(workbench.read_with(cx, |workbench, _| !workbench.keybindings_editor.open));
- cx.simulate_keystrokes("cmd-k cmd-s");
+ cx.simulate_keystrokes("secondary-k secondary-s");
filter(cx);
assert!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.search.value.is_empty()), "the modal opens with an empty search");
@@ -221,7 +221,7 @@ fn keys_define_a_keybinding_that_lands_in_keybindings_json(cx: &mut TestAppConte
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.selected), Some(0));
cx.simulate_keystrokes("enter");
assert!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.define.is_some()), "Enter opens the define widget");
- cx.simulate_keystrokes("cmd-k cmd-j");
+ cx.simulate_keystrokes("secondary-k secondary-j");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.define.as_ref().unwrap().chords.clone()), parse_keybinding("cmd+k cmd+j"));
cx.simulate_keystrokes("enter");
cx.run_until_parked();
@@ -229,8 +229,8 @@ fn keys_define_a_keybinding_that_lands_in_keybindings_json(cx: &mut TestAppConte
assert!(written.contains("\"key\": \"cmd+k cmd+j\"") && written.contains("\"command\": \"workbench.action.clearCommandHistory\""), "{written}");
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.entries[0].row.keybinding.clone()), parse_keybinding("cmd+k cmd+j"));
- // Cmd+Backspace removes it; the list keys move through the rows, Escape in the table closes the modal.
- cx.simulate_keystrokes("cmd-backspace");
+ // Cmd+Backspace (Delete outside macOS) removes it; the list keys move through the rows, Escape in the table closes the modal.
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
cx.run_until_parked();
assert!(!std::fs::read_to_string(&file).unwrap().contains("cmd+k cmd+j"));
search(&workbench, "workbench.action", cx);
@@ -252,7 +252,7 @@ fn writes_wait_until_an_open_keybindings_json_is_saved(cx: &mut TestAppContext)
// The bound row's Remove Keybinding refuses, the file keeps the keybinding.
search(&workbench, "@command:workbench.action.clearCommandHistory", cx);
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.entries[0].row.keybinding.clone()), parse_keybinding("cmd+k cmd+j"));
- cx.simulate_keystrokes("cmd-backspace");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
cx.run_until_parked();
assert_eq!(std::fs::read_to_string(&file).unwrap(), content);
// keybindingsEditor.ts `onKeybindingEditingError`: an error notification, not a dialog.
@@ -264,8 +264,8 @@ fn writes_wait_until_an_open_keybindings_json_is_saved(cx: &mut TestAppContext)
#[gpui::test]
fn the_modal_blocks_the_command_palette_key_but_not_the_command(cx: &mut TestAppContext) {
let (workbench, cx, _) = keybindings_editor_window(cx, "palette", "");
- cx.simulate_keystrokes("cmd-k cmd-s");
- cx.simulate_keystrokes("cmd-shift-p");
+ cx.simulate_keystrokes("secondary-k secondary-s");
+ cx.simulate_keystrokes("secondary-shift-p");
assert!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().is_none()), "modalEditorPart.ts stops workbench.action.showCommands");
// The menu bar's View > Command Palette... runs the command itself; the quick input draws above the modal.
@@ -279,8 +279,8 @@ fn the_modal_blocks_the_command_palette_key_but_not_the_command(cx: &mut TestApp
fn with_use_modal_off_the_command_palette_key_runs(cx: &mut TestAppContext) {
let (workbench, cx, _) = keybindings_editor_window(cx, "palette-modal-off", "");
workbench.update(cx, |workbench, _| workbench.update_user_setting("workbench.editor.useModal", serde_json::json!("off")));
- cx.simulate_keystrokes("cmd-k cmd-s");
- cx.simulate_keystrokes("cmd-shift-p");
+ cx.simulate_keystrokes("secondary-k secondary-s");
+ cx.simulate_keystrokes("secondary-shift-p");
assert!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().is_some()));
}
@@ -289,7 +289,7 @@ fn with_use_modal_off_the_command_palette_key_runs(cx: &mut TestAppContext) {
#[gpui::test]
fn typing_in_the_table_focuses_the_next_matching_command(cx: &mut TestAppContext) {
let (workbench, cx, _) = keybindings_editor_window(cx, "type-navigation", "");
- cx.simulate_keystrokes("cmd-k cmd-s");
+ cx.simulate_keystrokes("secondary-k secondary-s");
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("keybindings.editor.focusKeybindings", Vec::new(), window, cx)));
cx.run_until_parked();
let focused_label = |cx: &mut VisualTestContext| {
diff --git a/native/crates/app/src/workbench/keyboard/tests.rs b/native/crates/app/src/workbench/keyboard/tests.rs
index 75993c80530..7846a4dd5d8 100644
--- a/native/crates/app/src/workbench/keyboard/tests.rs
+++ b/native/crates/app/src/workbench/keyboard/tests.rs
@@ -60,7 +60,14 @@ fn set_context(workbench: &Entity<Workbench>, key: &str, value: Option<bool>, cx
});
}
-const WAITING: &str = "(⌘K) was pressed. Waiting for second key of chord...";
+/// `cmd` is the Windows key outside macOS, so the labels follow the OS.
+fn key_label(keybinding: &str) -> String {
+ crate::keybindings::label(&parse_keybinding(keybinding))
+}
+
+fn waiting() -> String {
+ format!("({}) was pressed. Waiting for second key of chord...", key_label("cmd+k"))
+}
#[gpui::test]
fn a_single_chord_keybinding_is_dispatched(cx: &mut TestAppContext) {
@@ -71,7 +78,7 @@ fn a_single_chord_keybinding_is_dispatched(cx: &mut TestAppContext) {
#[gpui::test]
fn a_multi_chord_keybinding_is_dispatched(cx: &mut TestAppContext) {
let (workbench, cx, calls) = workbench_with(vec![kb_item("cmd+k cmd+i", "myCommand", None)], cx);
- assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(WAITING.into()), None));
+ assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(waiting()), None));
assert_eq!(press(&workbench, "cmd-i", cx, &calls), (vec!["myCommand".into()], None, None));
}
@@ -84,15 +91,15 @@ fn a_single_chord_keybinding_with_an_empty_command_unbinds_it(cx: &mut TestAppCo
#[gpui::test]
fn a_multi_chord_keybinding_with_an_empty_command_is_not_a_command(cx: &mut TestAppContext) {
let (workbench, cx, calls) = workbench_with(vec![kb_item("cmd+k cmd+i", "myCommand", None), kb_item("cmd+k cmd+i", "", None)], cx);
- assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(WAITING.into()), None));
- assert_eq!(press(&workbench, "cmd-i", cx, &calls), (vec![], None, Some("The key combination (⌘K, ⌘I) is not a command.".into())));
+ assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(waiting()), None));
+ assert_eq!(press(&workbench, "cmd-i", cx, &calls), (vec![], None, Some(format!("The key combination ({}, {}) is not a command.", key_label("cmd+k"), key_label("cmd+i")))));
}
#[gpui::test]
fn issue_16498_chord_mode_is_quit_for_invalid_chords(cx: &mut TestAppContext) {
let (workbench, cx, calls) = workbench_with(vec![kb_item("cmd+k cmd+x", "chordCommand", None), kb_item("backspace", "simpleCommand", None)], cx);
- assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(WAITING.into()), None));
- assert_eq!(press(&workbench, "backspace", cx, &calls), (vec![], None, Some("The key combination (⌘K, Backspace) is not a command.".into())));
+ assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(waiting()), None));
+ assert_eq!(press(&workbench, "backspace", cx, &calls), (vec![], None, Some(format!("The key combination ({}, Backspace) is not a command.", key_label("cmd+k")))));
assert_eq!(press(&workbench, "backspace", cx, &calls).0, ["simpleCommand"]);
}
@@ -111,7 +118,7 @@ fn can_trigger_command_that_is_sharing_keybinding_with_chord(cx: &mut TestAppCon
set_context(&workbench, "key1", Some(true), cx);
assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec!["simpleCommand".into()], None, None));
set_context(&workbench, "key1", None, cx);
- assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(WAITING.into()), None));
+ assert_eq!(press(&workbench, "cmd-k", cx, &calls), (vec![], Some(waiting()), None));
assert_eq!(press(&workbench, "cmd-x", cx, &calls), (vec!["chordCommand".into()], None, None));
}
diff --git a/native/crates/app/src/workbench/local_history_actions/tests.rs b/native/crates/app/src/workbench/local_history_actions/tests.rs
index d849835acf0..0483fe05465 100644
--- a/native/crates/app/src/workbench/local_history_actions/tests.rs
+++ b/native/crates/app/src/workbench/local_history_actions/tests.rs
@@ -109,7 +109,7 @@ fn the_timeline_lists_the_entries_and_their_commands_run(cx: &mut TestAppContext
});
workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.localHistory.rename", vec![second.clone()], window, cx)));
- cx.simulate_keystrokes("cmd-a");
+ cx.simulate_keystrokes("secondary-a");
cx.simulate_input("Renamed");
cx.simulate_keystrokes("enter");
cx.run_until_parked();
diff --git a/native/crates/app/src/workbench/menubar/tests.rs b/native/crates/app/src/workbench/menubar/tests.rs
index f194e3dcfbc..b8095f11344 100644
--- a/native/crates/app/src/workbench/menubar/tests.rs
+++ b/native/crates/app/src/workbench/menubar/tests.rs
@@ -33,6 +33,15 @@ fn command<'a>(menubar: &'a Menubar, menu: &str, id: &str) -> &'a MenuAction {
actions.iter().find(|action| matches!(action, MenuAction::Command { id: found, .. } if found == id)).unwrap()
}
+/// The Preferences menu is a top-level menu on macOS only, for the app menu; elsewhere it is in File.
+fn main_menu_titles() -> Vec<&'static str> {
+ let mut titles = vec!["File", "Edit", "Selection", "View", "Go", "Help"];
+ if cfg!(target_os = "macos") {
+ titles.push("Preferences");
+ }
+ titles
+}
+
fn enabled(action: &MenuAction) -> bool {
matches!(action, MenuAction::Command { enabled: true, .. })
}
@@ -59,7 +68,7 @@ fn menus_follow_the_reference_order_and_enablement(cx: &mut TestAppContext) {
let (workbench, cx) = workbench(None, cx);
let menubar = cx.update(|window, cx| workbench.read(cx).menubar(window));
let titles: Vec<&str> = menubar.menus.iter().map(|(title, _)| title.as_str()).collect();
- assert_eq!(titles, ["File", "Edit", "Selection", "View", "Go", "Help", "Preferences"]);
+ assert_eq!(titles, main_menu_titles());
// The empty window of the reference capture: Save, Save All and Revert File are disabled.
for id in ["workbench.action.files.save", "saveAll", "workbench.action.files.revert"] {
assert!(!enabled(command(&menubar, "File", id)), "{id}");
@@ -96,6 +105,8 @@ fn the_selection_menu_names_the_multi_cursor_modifier_it_switches_to(cx: &mut Te
assert_eq!(title(cx), "Switch to Alt+Click for Multi-Cursor");
}
+// The macOS app menu holds Preferences and the Cmd key equivalents.
+#[cfg(target_os = "macos")]
#[gpui::test]
fn native_menus_show_keybindings_as_key_equivalents_or_in_the_label(cx: &mut TestAppContext) {
let (workbench, cx) = workbench(None, cx);
@@ -184,7 +195,7 @@ fn a_custom_menu_bar_title_opens_its_menu(cx: &mut TestAppContext) {
MenuAction::Submenu { title, .. } => title,
_ => "-".into(),
}).collect();
- assert_eq!(titles, ["File", "Edit", "Selection", "View", "Go", "Help", "Preferences"]);
+ assert_eq!(titles, main_menu_titles());
}
/// menubar.ts `setMacWindowMenu`: Always on Top, checked from the window level, then Switch Window.
@@ -222,7 +233,8 @@ fn open_recent_lists_folders_then_files_before_more(cx: &mut TestAppContext) {
});
workbench.read(cx).menubar(window)
});
- assert_eq!(menubar.recent.iter().map(|(label, _)| label.as_str()).collect::<Vec<_>>(), ["/tmp/a&b", "/tmp/one.txt"]);
+ let (folder, file) = (Path::new("/tmp/a&b").display().to_string(), Path::new("/tmp/one.txt").display().to_string());
+ assert_eq!(menubar.recent.iter().map(|(label, _)| label.as_str()).collect::<Vec<_>>(), [folder.as_str(), file.as_str()]);
assert_eq!(menubar.recent_workspaces, 1);
let (menus, _) = native_menus(&menubar);
let MenuItem::Submenu(recent) = menus[1].items.iter().find(|item| matches!(item, MenuItem::Submenu(menu) if menu.name.as_ref() == "Open Recent")).unwrap() else { unreachable!() };
@@ -231,7 +243,7 @@ fn open_recent_lists_folders_then_files_before_more(cx: &mut TestAppContext) {
MenuItem::Separator => "-".into(),
_ => "?".into(),
}).collect();
- assert_eq!(names[..7], ["Reopen Closed Editor", "-", "/tmp/a&b", "-", "/tmp/one.txt", "-", "More…"]);
+ assert_eq!(names[..7], ["Reopen Closed Editor", "-", folder.as_str(), "-", file.as_str(), "-", "More…"]);
}
#[test]
@@ -240,6 +252,7 @@ fn truncate_middle_keeps_both_ends() {
assert_eq!(truncate_middle("abc", 5), "abc");
}
+#[cfg(target_os = "macos")]
/// The menu bar against 1.147.0's `IMenubarData` (`port/tools/ref-menubar`, menus and keybinding labels kept in
/// `reference-empty.json` and `reference-file.json`): every reference item whose command the port registers, in the
/// reference's order, groups, labels and enablement, nothing more. Open Recent's entries depend on the history.
@@ -296,6 +309,7 @@ fn assert_menubar_matches_the_reference(reference: &str, folder: Option<&Path>,
std::fs::remove_dir_all(user).unwrap();
}
+#[cfg(target_os = "macos")]
fn reference_ids(menus: &Value) -> Vec<String> {
let mut ids = Vec::new();
let mut stack: Vec<&Value> = menus.as_object().unwrap().values().map(|menu| &menu["items"]).collect();
@@ -310,10 +324,12 @@ fn reference_ids(menus: &Value) -> Vec<String> {
ids
}
+#[cfg(target_os = "macos")]
fn label(title: &str) -> String {
title.replace("&&", "")
}
+#[cfg(target_os = "macos")]
fn port_lines(actions: &[MenuAction], depth: usize, lines: &mut Vec<String>) {
let indent = " ".repeat(depth);
for action in actions {
@@ -328,6 +344,7 @@ fn port_lines(actions: &[MenuAction], depth: usize, lines: &mut Vec<String>) {
}
}
+#[cfg(target_os = "macos")]
/// The reference items the port can show; separators collapse as `getFlatContextMenuActions` leaves them.
fn reference_lines(items: &Value, depth: usize, registered: &[String], lines: &mut Vec<String>) {
let indent = " ".repeat(depth);
@@ -356,11 +373,14 @@ fn reference_lines(items: &Value, depth: usize, registered: &[String], lines: &m
}
}
+// The references are macOS captures.
+#[cfg(target_os = "macos")]
#[gpui::test]
fn the_empty_window_menu_bar_matches_the_reference(cx: &mut TestAppContext) {
assert_menubar_matches_the_reference(include_str!("reference-empty.json"), None, None, cx);
}
+#[cfg(target_os = "macos")]
#[gpui::test]
fn the_folder_and_file_menu_bar_matches_the_reference(cx: &mut TestAppContext) {
let folder = std::env::temp_dir().join(format!("code-gpui-menubar-folder-{}", std::process::id()));
diff --git a/native/crates/app/src/workbench/modal_editor_group/tests.rs b/native/crates/app/src/workbench/modal_editor_group/tests.rs
index 714c1398db2..eb4b9a5fa21 100644
--- a/native/crates/app/src/workbench/modal_editor_group/tests.rs
+++ b/native/crates/app/src/workbench/modal_editor_group/tests.rs
@@ -197,7 +197,7 @@ fn settings_json_joins_the_settings_editor_in_the_modal_group(cx: &mut TestAppCo
workbench.read_with(cx, |workbench, _| assert_eq!(workbench.editors.active().unwrap().document().path, dir.join("settings.json")));
assert!(cx.debug_bounds("settings-sash").is_none());
- cx.simulate_keystrokes("cmd-w");
+ cx.simulate_keystrokes("secondary-w");
cx.run_until_parked();
assert!(cx.debug_bounds("settings-sash").is_some(), "the Settings editor shows again");
workbench.update_in(cx, |workbench, window, _| assert!(workbench.settings_editor.search_focus.is_focused(window)));
@@ -296,7 +296,7 @@ fn open_modal_editor_in_main_window_moves_its_editors_to_the_main_part(cx: &mut
});
assert!(cx.debug_bounds("modal-editor").is_none());
- cx.simulate_keystrokes("cmd-w");
+ cx.simulate_keystrokes("secondary-w");
cx.run_until_parked();
assert!(cx.debug_bounds("settings-sash").is_some(), "the Settings editor draws in the main part");
assert!(cx.debug_bounds("modal-editor").is_none());
@@ -324,7 +324,7 @@ fn the_workspace_trust_editor_moves_to_the_main_part(cx: &mut TestAppContext) {
assert!(cx.debug_bounds("modal-editor").is_none());
assert!(cx.debug_bounds("workspace-trust-editor").is_some(), "the Workspace Trust editor draws in the main part");
- cx.simulate_keystrokes("cmd-w");
+ cx.simulate_keystrokes("secondary-w");
cx.run_until_parked();
workbench.read_with(cx, |workbench, _| assert!(!workbench.trust_editor.open && workbench.settings_editor.open));
}
@@ -336,7 +336,7 @@ fn the_settings_editor_joins_the_keyboard_shortcuts_editor(cx: &mut TestAppConte
run(&workbench, "workbench.action.openGlobalKeybindings", cx);
run(&workbench, "workbench.action.openSettings2", cx);
assert!(cx.debug_bounds("settings-sash").is_some());
- cx.simulate_keystrokes("cmd-w");
+ cx.simulate_keystrokes("secondary-w");
cx.run_until_parked();
assert!(cx.debug_bounds("settings-sash").is_none());
workbench.update_in(cx, |workbench, window, _| {
diff --git a/native/crates/app/src/workbench/notebook_editor/tests.rs b/native/crates/app/src/workbench/notebook_editor/tests.rs
index 23acc29e182..87b8f611c1d 100644
--- a/native/crates/app/src/workbench/notebook_editor/tests.rs
+++ b/native/crates/app/src/workbench/notebook_editor/tests.rs
@@ -325,7 +325,7 @@ fn notebook_find_goes_through_the_matches_of_all_cells_and_replaces_them(cx: &mu
{ "cellKind": 1, "language": "markdown", "source": "x md", "outputs": [], "metadata": {} },
]);
let (workbench, cx, _) = workbench_with_cells(cells, cx);
- cx.simulate_keystrokes("cmd-f");
+ cx.simulate_keystrokes("secondary-f");
workbench.update_in(cx, |workbench, window, cx| {
assert!(workbench.notebook_views.find.find_focus.is_focused(window), "Cmd+F in the cell list focuses the notebook find input");
workbench.edit_notebook_find_input(super::super::input_box_view::InputId::NotebookFind, |input| input.set_value("x".into()), cx);
@@ -475,7 +475,7 @@ fn the_cell_list_takes_the_keyboard_and_enter_and_escape_move_into_and_out_of_a_
assert_eq!(state(cx), (0, false, true), "Enter edits the markdown cell");
cx.simulate_keystrokes("escape");
assert_eq!(state(cx), (0, true, false), "Escape leaves the cell editor for the list");
- cx.simulate_keystrokes("cmd-down");
+ cx.simulate_keystrokes("secondary-down");
assert_eq!(state(cx), (1, true, false));
let crumbs = workbench.read_with(cx, |workbench, _| workbench.notebook_breadcrumbs(gpui::rgba(0xffffffff), 22.).unwrap().1.into_iter().map(|(_, label)| label).collect::<Vec<_>>());
// notebookOutline.ts renders `' ' + label` right after a margin-less codicon.
diff --git a/native/crates/app/src/workbench/outline_pane/tests.rs b/native/crates/app/src/workbench/outline_pane/tests.rs
index a609bc00c10..f6b68d9959c 100644
--- a/native/crates/app/src/workbench/outline_pane/tests.rs
+++ b/native/crates/app/src/workbench/outline_pane/tests.rs
@@ -147,7 +147,7 @@ fn find_filters_or_highlights_the_symbols(cx: &mut TestAppContext) {
run("outline.focus", cx);
assert_eq!(rows(cx), ["B", "a"]);
- cx.simulate_keystrokes("alt-cmd-f");
+ cx.simulate_keystrokes("alt-secondary-f");
assert!(workbench.update_in(cx, |workbench, window, _| workbench.outline_pane.find.is_open() && workbench.outline_pane.find.focus.is_focused(window)));
cx.simulate_input("ru");
assert_eq!(rows(cx), ["B", " run"], "the filter keeps the match and its parent, expanded");
diff --git a/native/crates/app/src/workbench/part_grid/tests.rs b/native/crates/app/src/workbench/part_grid/tests.rs
index 61de2d6ee20..c1929a1b006 100644
--- a/native/crates/app/src/workbench/part_grid/tests.rs
+++ b/native/crates/app/src/workbench/part_grid/tests.rs
@@ -62,15 +62,15 @@ fn the_side_bar_is_hidden_in_an_empty_window_and_cmd_b_toggles_it_for_the_next_o
let stores = stores();
let (workbench, window_cx) = open(None, &stores, cx);
assert!(!side_bar_visible(&workbench, window_cx));
- window_cx.simulate_keystrokes("cmd-b");
+ window_cx.simulate_keystrokes("secondary-b");
assert!(side_bar_visible(&workbench, window_cx));
assert_eq!(stores.workspace.lock().unwrap().get("workbench.sideBar.hidden"), Some("false"));
- window_cx.simulate_keystrokes("cmd-b");
+ window_cx.simulate_keystrokes("secondary-b");
assert!(!side_bar_visible(&workbench, window_cx));
// layoutActions.ts: Close Primary Side Bar is enabled only while the side bar shows.
let context = workbench.update_in(window_cx, |workbench, window, _| workbench.key_context(window));
assert_eq!(context["sideBarVisible"], false);
- window_cx.simulate_keystrokes("cmd-b");
+ window_cx.simulate_keystrokes("secondary-b");
drop(workbench);
window_cx.update(|window, _| window.remove_window());
@@ -91,7 +91,7 @@ fn cmd_j_shows_the_panel_under_the_editor_and_maximize_hides_the_editor_until_th
vec![height(Part::Editor), height(Part::Panel)]
})
};
- window_cx.simulate_keystrokes("cmd-j");
+ window_cx.simulate_keystrokes("secondary-j");
assert!(workbench.read_with(window_cx, |workbench, _| workbench.is_part_visible(Part::Panel)));
assert_eq!(stores.workspace.lock().unwrap().get("workbench.panel.hidden"), Some("false"));
// layout.ts: the panel takes a third of the window's height, 768 / 3 in the test window.
@@ -101,11 +101,11 @@ fn cmd_j_shows_the_panel_under_the_editor_and_maximize_hides_the_editor_until_th
window_cx.update(|window, cx| workbench.update(cx, |workbench, cx| workbench.execute_command("workbench.action.toggleMaximizedPanel", Vec::new(), window, cx)));
assert!(workbench.read_with(window_cx, |workbench, _| workbench.is_panel_maximized()));
assert_eq!(column(window_cx)[0], 0.);
- window_cx.simulate_keystrokes("cmd-j");
+ window_cx.simulate_keystrokes("secondary-j");
assert!(!workbench.read_with(window_cx, |workbench, _| workbench.is_part_visible(Part::Panel) || workbench.is_panel_maximized()));
assert_eq!(column(window_cx)[0], editor + panel);
- window_cx.simulate_keystrokes("alt-cmd-b");
+ window_cx.simulate_keystrokes("alt-secondary-b");
assert!(workbench.read_with(window_cx, |workbench, _| workbench.is_part_visible(Part::AuxiliaryBar)));
let context = workbench.update_in(window_cx, |workbench, window, _| workbench.key_context(window));
assert_eq!((context["auxiliaryBarVisible"].clone(), context["panelVisible"].clone()), (true.into(), false.into()));
@@ -227,7 +227,7 @@ fn zen_mode_hides_the_parts_and_puts_back_the_ones_it_hid(cx: &mut TestAppContex
let (workbench, window_cx) = open(Some(dir.clone()), &stores, cx);
let shown = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| (workbench.is_part_visible(Part::SideBar), workbench.is_part_visible(Part::ActivityBar), workbench.is_status_bar_visible()));
assert_eq!(shown(window_cx), (true, true, true));
- window_cx.simulate_keystrokes("cmd-k z");
+ window_cx.simulate_keystrokes("secondary-k z");
assert_eq!(shown(window_cx), (false, false, false));
let context = workbench.update_in(window_cx, |workbench, window, _| workbench.key_context(window));
assert_eq!((context["inZenMode"].clone(), context["isCenteredLayout"].clone()), (true.into(), true.into()));
@@ -245,7 +245,7 @@ fn zen_mode_hides_the_parts_and_puts_back_the_ones_it_hid(cx: &mut TestAppContex
std::fs::write(dir.join("notes.txt"), "text\n").unwrap();
reopened.update_in(window_cx, |workbench, window, cx| workbench.open_file(dir.join("notes.txt"), true, window, cx));
window_cx.run_until_parked();
- window_cx.simulate_keystrokes("cmd-k z");
+ window_cx.simulate_keystrokes("secondary-k z");
assert!(reopened.read_with(window_cx, |workbench, _| workbench.zen_mode.active));
window_cx.simulate_keystrokes("escape escape");
assert!(reopened.read_with(window_cx, |workbench, _| !workbench.zen_mode.active));
@@ -258,7 +258,7 @@ fn maximizing_the_secondary_side_bar_hides_the_other_parts_and_restore_brings_th
let dir = std::env::temp_dir().join(format!("code-gpui-auxiliary-maximized-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let (workbench, window_cx) = open(Some(dir.clone()), &stores, cx);
- window_cx.simulate_keystrokes("alt-cmd-b");
+ window_cx.simulate_keystrokes("alt-secondary-b");
let shown = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| [Part::SideBar, Part::Editor, Part::Panel, Part::AuxiliaryBar].map(|part| workbench.is_part_visible(part)));
let width = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.part_grid.grid.as_ref().unwrap().part_bounds(Part::AuxiliaryBar).unwrap()[2]);
assert_eq!(shown(window_cx), [true, true, false, true]);
@@ -276,7 +276,7 @@ fn maximizing_the_secondary_side_bar_hides_the_other_parts_and_restore_brings_th
assert_eq!(context["auxiliaryBarMaximized"], true);
// Showing another part leaves the maximized state first (layout.ts `setSideBarHidden`).
- window_cx.simulate_keystrokes("cmd-b");
+ window_cx.simulate_keystrokes("secondary-b");
assert_eq!(shown(window_cx), [true, true, false, true]);
assert!((width(window_cx) - before).abs() < 1., "{} {before}", width(window_cx));
diff --git a/native/crates/app/src/workbench/quick_access/tests.rs b/native/crates/app/src/workbench/quick_access/tests.rs
index 69f1652c3b4..2c6df5385c5 100644
--- a/native/crates/app/src/workbench/quick_access/tests.rs
+++ b/native/crates/app/src/workbench/quick_access/tests.rs
@@ -51,7 +51,7 @@ fn command_palette_runs_an_extension_command_and_remembers_it(cx: &mut TestAppCo
});
cx.run_until_parked();
- cx.simulate_keystrokes("shift-cmd-p");
+ cx.simulate_keystrokes("shift-secondary-p");
let (value, placeholder) = workbench.read_with(cx, |workbench, _| {
let input = workbench.quick_inputs.current().unwrap();
(input.input_box.value.clone(), input.placeholder.clone())
@@ -76,7 +76,7 @@ fn command_palette_runs_an_extension_command_and_remembers_it(cx: &mut TestAppCo
assert_eq!(stored("commandPalette.mru.counter").as_deref(), Some("42"));
assert!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().is_none()));
- cx.simulate_keystrokes("shift-cmd-p");
+ cx.simulate_keystrokes("shift-secondary-p");
let reopened = workbench.read_with(cx, labels);
assert_eq!(reopened[0], "--recently used--Port: Say Hello");
assert!(reopened[1].starts_with("--other commands--"), "{reopened:?}");
@@ -89,7 +89,7 @@ fn command_palette_runs_an_extension_command_and_remembers_it(cx: &mut TestAppCo
});
assert_eq!(row, ("Preferences: Color Theme".to_string(), vec![vec!["⌘".to_string(), "K".to_string()], vec!["⌘".to_string(), "T".to_string()]]));
- cx.simulate_keystrokes("cmd-a backspace");
+ cx.simulate_keystrokes("secondary-a backspace");
cx.simulate_input(">zzzz");
assert_eq!(workbench.read_with(cx, labels), ["No matching commands"]);
cx.simulate_keystrokes("enter");
@@ -166,7 +166,7 @@ fn help_lists_the_providers_and_shows_the_picked_one(cx: &mut TestAppContext) {
})
};
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.simulate_input("?");
let (value, placeholder, rows) = picker(cx);
assert_eq!((value.as_str(), placeholder.as_str()), ("?", "Type '?' to get help on the actions you can take from here."));
@@ -188,7 +188,7 @@ fn help_lists_the_providers_and_shows_the_picked_one(cx: &mut TestAppContext) {
cx.simulate_keystrokes("down enter");
assert_eq!(picker(cx).0, ":", "accept shows the picked provider");
- cx.simulate_keystrokes("escape cmd-p");
+ cx.simulate_keystrokes("escape secondary-p");
cx.simulate_input("?>");
cx.run_until_parked();
assert_eq!(picker(cx).0, ">", "a typed prefix shows its provider");
@@ -266,11 +266,11 @@ fn the_view_picker_groups_views_by_container_and_opens_the_pick(cx: &mut TestApp
]);
cx.simulate_input("explorer");
assert_eq!(workbench.read_with(cx, labels), ["--Side Bar--Explorer", "--Side Bar / Explorer--Open Editors", "No Folder Opened", "Outline", "Timeline"], "the container's label matches its views");
- cx.simulate_keystrokes("cmd-a backspace");
+ cx.simulate_keystrokes("secondary-a backspace");
cx.simulate_input("view zzzz");
assert_eq!(workbench.read_with(cx, labels), ["No matching views"]);
- cx.simulate_keystrokes("cmd-a backspace");
+ cx.simulate_keystrokes("secondary-a backspace");
cx.simulate_input("view proble");
cx.simulate_keystrokes("enter");
cx.run_until_parked();
diff --git a/native/crates/app/src/workbench/quick_input_view/tests.rs b/native/crates/app/src/workbench/quick_input_view/tests.rs
index 5a3bde71a63..ba16516845f 100644
--- a/native/crates/app/src/workbench/quick_input_view/tests.rs
+++ b/native/crates/app/src/workbench/quick_input_view/tests.rs
@@ -26,7 +26,7 @@ fn dragging_the_header_moves_the_quick_input_and_a_double_click_puts_it_back(cx:
workbench
});
cx.run_until_parked();
- cx.simulate_keystrokes("shift-cmd-p");
+ cx.simulate_keystrokes("shift-secondary-p");
let bounds = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.quick_inputs.bounds.get());
let start = bounds(cx);
@@ -79,7 +79,7 @@ fn the_quick_input_stays_open_while_the_window_is_inactive(cx: &mut TestAppConte
});
cx.update(|window, _| window.activate_window());
cx.run_until_parked();
- cx.simulate_keystrokes("shift-cmd-p");
+ cx.simulate_keystrokes("shift-secondary-p");
let shown = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.quick_inputs.visible.is_some());
assert!(shown(cx));
@@ -118,7 +118,7 @@ fn the_word_highlight_stops_while_the_quick_input_has_the_focus(cx: &mut TestApp
let highlights = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().highlights.len());
assert_eq!(highlights(cx), 2);
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
assert_eq!(highlights(cx), 0, "onDidBlurEditorWidget");
cx.deactivate_window();
cx.update(|window, _| window.activate_window());
@@ -129,7 +129,7 @@ fn the_word_highlight_stops_while_the_quick_input_has_the_focus(cx: &mut TestApp
// A picked command that shows another quick input (Compare Active File With...): the editor had the focus back
// for a moment, so upstream's query, 50 ms later, still highlights.
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
workbench.update_in(cx, |workbench, window, cx| {
let id = workbench.quick_inputs.visible.unwrap();
workbench.hide_quick_input_by_id(id, window, cx);
@@ -144,7 +144,7 @@ fn the_word_highlight_stops_while_the_quick_input_has_the_focus(cx: &mut TestApp
cx.simulate_keystrokes("escape");
// A picked command edits before GPUI reports the restored focus; the edit stops upstream's pending query.
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
workbench.update_in(cx, |workbench, window, cx| {
workbench.editors.active_mut().unwrap().type_text("x");
window.focus(&workbench.editor_focus.clone(), cx);
@@ -154,7 +154,7 @@ fn the_word_highlight_stops_while_the_quick_input_has_the_focus(cx: &mut TestApp
// A window deactivation keeps the DOM focus: the highlights stay, and the reactivation runs no query, so an
// edit made meanwhile (a dialog's action) leaves them off.
- cx.simulate_keystrokes("cmd-z");
+ cx.simulate_keystrokes("secondary-z");
workbench.update(cx, |workbench, _| workbench.editors.active_mut().unwrap().refresh_highlights());
assert_eq!(highlights(cx), 2);
cx.deactivate_window();
diff --git a/native/crates/app/src/workbench/quick_open/tests.rs b/native/crates/app/src/workbench/quick_open/tests.rs
index 0b1ee431bd9..20cdbb63127 100644
--- a/native/crates/app/src/workbench/quick_open/tests.rs
+++ b/native/crates/app/src/workbench/quick_open/tests.rs
@@ -84,7 +84,7 @@ fn quick_open_shows_the_rows_of_the_reference(cx: &mut TestAppContext) {
cx.run_until_parked();
let mut mismatches = Vec::new();
for (query, expected) in reference {
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.simulate_input(query);
cx.run_until_parked();
let rows = workbench.read_with(cx, reference_rows);
@@ -114,7 +114,7 @@ fn quick_open_lists_history_and_files_and_opens_at_the_line(cx: &mut TestAppCont
});
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.run_until_parked();
let placeholder = workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().unwrap().placeholder.clone());
assert_eq!(placeholder.as_deref(), Some("Search files by name (append : to go to line or @ to go to symbol), or paste a link"));
@@ -136,7 +136,7 @@ fn quick_open_lists_history_and_files_and_opens_at_the_line(cx: &mut TestAppCont
assert_eq!(workbench.read_with(cx, labels), ["--file results--main.ts", "util.ts", "notes.txt"], "a value given before the files load");
cx.simulate_keystrokes("escape");
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.simulate_input("main.ts:2:3");
cx.run_until_parked();
assert_eq!(workbench.read_with(cx, labels), ["--file results--main.ts"]);
@@ -151,7 +151,7 @@ fn quick_open_lists_history_and_files_and_opens_at_the_line(cx: &mut TestAppCont
let stored = storage.lock().unwrap().get("history.entries").map(str::to_owned).unwrap();
assert!(stored.starts_with(&format!(r#"[{{"editor":{{"resource":"file://{}/src/main.ts""#, folder.display())), "{stored}");
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.run_until_parked();
assert_eq!(workbench.read_with(cx, labels), ["--recently opened--main.ts", "guide.md"]);
cx.simulate_input("gui");
@@ -182,7 +182,7 @@ fn the_description_follows_the_highlighted_name_s_exact_width(cx: &mut TestAppCo
workbench
});
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.simulate_input("util");
cx.run_until_parked();
let left = |selector: &'static str, cx: &mut gpui::VisualTestContext| f32::from(cx.debug_bounds(selector).unwrap().origin.x);
@@ -202,7 +202,7 @@ fn the_row_label_is_a_22px_line(cx: &mut TestAppContext) {
workbench
});
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-p");
+ cx.simulate_keystrokes("secondary-p");
cx.simulate_input("util");
cx.run_until_parked();
assert_eq!(cx.debug_bounds("quick-input-label").unwrap().size.height, gpui::px(22.));
diff --git a/native/crates/app/src/workbench/readonly/tests.rs b/native/crates/app/src/workbench/readonly/tests.rs
index 19b272c9d5b..c007a2e3367 100644
--- a/native/crates/app/src/workbench/readonly/tests.rs
+++ b/native/crates/app/src/workbench/readonly/tests.rs
@@ -106,7 +106,7 @@ fn an_edit_in_a_read_only_editor_shows_why_and_escape_closes_it(cx: &mut TestApp
cx.run_until_parked();
assert!(!visible(cx), "leaveEditorMessage");
- cx.simulate_keystrokes("cmd-backspace");
+ cx.simulate_keystrokes("secondary-backspace");
cx.run_until_parked();
assert!(!visible(cx), "deleteAllLeft has precondition writable: nothing runs, nothing shows");
cx.simulate_keystrokes("delete");
diff --git a/native/crates/app/src/workbench/search_actions/tests.rs b/native/crates/app/src/workbench/search_actions/tests.rs
index 29760f3d443..ad5d6e8d39d 100644
--- a/native/crates/app/src/workbench/search_actions/tests.rs
+++ b/native/crates/app/src/workbench/search_actions/tests.rs
@@ -107,14 +107,14 @@ fn the_message_words_take_their_exact_width(cx: &mut TestAppContext) {
#[gpui::test]
fn typing_searches_after_the_debounce_and_an_invalid_regex_does_not(cx: &mut TestAppContext) {
let (dir, workbench, cx) = search("search-type", cx);
- cx.simulate_keystrokes("cmd-shift-f");
+ cx.simulate_keystrokes("secondary-shift-f");
cx.simulate_input("beta");
assert!(workbench.read_with(cx, |workbench, _| workbench.search.result.is_empty()), "the search waits for the debounce");
cx.executor().advance_clock(Duration::from_millis(300));
cx.run_until_parked();
assert_eq!(result_files(&workbench, &dir, cx), [("a.txt".to_string(), 1)]);
- cx.simulate_keystrokes("alt-cmd-r");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "alt-cmd-r" } else { "alt-r" });
cx.simulate_input("(");
cx.executor().advance_clock(Duration::from_millis(300));
cx.run_until_parked();
@@ -144,13 +144,13 @@ fn replacing_one_match_keeps_the_others_and_dismiss_drops_a_file(cx: &mut TestAp
workbench.search.focused = Some(second.clone());
window.focus(&workbench.search.focus.clone(), cx);
});
- cx.simulate_keystrokes("shift-cmd-1");
+ cx.simulate_keystrokes("shift-secondary-1");
cx.run_until_parked();
assert_eq!(std::fs::read_to_string(dir.join("a.txt")).unwrap(), "alpha beta\nOmega\n");
assert_eq!(result_files(&workbench, &dir, cx), [("a.txt".to_string(), 1), ("sub/b.txt".to_string(), 2)]);
workbench.update_in(cx, |workbench, _, _| workbench.search.focused = Some(RowKey::File(dir.join("sub/b.txt"))));
- cx.simulate_keystrokes("cmd-backspace");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
assert_eq!(result_files(&workbench, &dir, cx), [("a.txt".to_string(), 1)]);
assert_eq!(message(&workbench, cx), "1 result in 1 file - [Open in editor]");
std::fs::remove_dir_all(dir).unwrap();
@@ -250,16 +250,16 @@ fn find_in_files_seeds_the_query_from_the_editor_word(cx: &mut TestAppContext) {
let (dir, workbench, cx) = search("search-seed", cx);
workbench.update_in(cx, |workbench, window, cx| workbench.open_file(dir.join("a.txt"), true, window, cx));
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-shift-f");
+ cx.simulate_keystrokes("secondary-shift-f");
let query = workbench.read_with(cx, |workbench, _| workbench.search.value(SearchField::Query).to_string());
assert_eq!(query, "", "search.seedWithNearestWord is off by default");
workbench.update(cx, |workbench, _| workbench.settings.lock().unwrap().update_value_derived("search.seedWithNearestWord", Some(&json!(true))).unwrap());
- cx.simulate_keystrokes("cmd-shift-f");
+ cx.simulate_keystrokes("secondary-shift-f");
let query = workbench.read_with(cx, |workbench, _| workbench.search.value(SearchField::Query).to_string());
assert_eq!(query, "", "nothing is seeded while the focus is in the Search view");
workbench.update_in(cx, |workbench, window, cx| workbench.open_file(dir.join("a.txt"), true, window, cx));
cx.run_until_parked();
- cx.simulate_keystrokes("cmd-shift-f");
+ cx.simulate_keystrokes("secondary-shift-f");
let query = workbench.read_with(cx, |workbench, _| workbench.search.value(SearchField::Query).to_string());
assert_eq!(query, "alpha");
std::fs::remove_dir_all(dir).unwrap();
@@ -382,7 +382,7 @@ fn new_search_editor_runs_its_query_with_context_lines(cx: &mut TestAppContext)
#[gpui::test]
fn the_command_palette_opens_a_new_search_editor(cx: &mut TestAppContext) {
let (_dir, workbench, cx) = search("search-palette-editor", cx);
- cx.simulate_keystrokes("cmd-shift-p");
+ cx.simulate_keystrokes("secondary-shift-p");
cx.simulate_input("New Search Editor");
cx.run_until_parked();
cx.simulate_keystrokes("enter");
@@ -404,14 +404,14 @@ fn search_editor_keys_select_matches_delete_file_results_and_focus_the_query(cx:
let (_dir, workbench, cx) = search("search-editor-keys", cx);
run(&workbench, "search.action.openNewEditor", vec![json!({ "query": "alpha", "contextLines": 0, "triggerSearch": true })], cx);
workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.editor_focus, cx));
- cx.simulate_keystrokes("cmd-shift-l");
+ cx.simulate_keystrokes("secondary-shift-l");
let selections = workbench.read_with(cx, |workbench, _| workbench.editors.active().unwrap().selections.len());
assert_eq!(selections, 4);
let (_, _, text) = active_editor(&workbench, cx);
let line = text.lines().position(|line| line == "sub/b.txt:").unwrap();
workbench.update(cx, |workbench, _| workbench.editors.active_mut().unwrap().set_selections(vec![crate::editor::Selection::caret(crate::editor::Position::new(line + 1, 3))]));
- cx.simulate_keystrokes("cmd-shift-backspace");
+ cx.simulate_keystrokes("secondary-shift-backspace");
let (_, _, text) = active_editor(&workbench, cx);
assert_eq!(text, "4 results - 2 files\n\na.txt:\n 1: alpha beta\n 2: Alpha\n\n");
diff --git a/native/crates/app/src/workbench/themes/tests.rs b/native/crates/app/src/workbench/themes/tests.rs
index c946e20a5ae..2def5ea969c 100644
--- a/native/crates/app/src/workbench/themes/tests.rs
+++ b/native/crates/app/src/workbench/themes/tests.rs
@@ -51,7 +51,7 @@ fn the_picker_previews_the_focused_theme_writes_the_accepted_one_and_escape_rest
let sent = || messages.try_iter().filter(|message| !["$activateByEvent", "$initializeIsConnectionMetered"].contains(&message.method)).map(|message| (message.method, message.args)).collect::<Vec<(&str, Vec<Value>)>>();
let user_settings = || std::fs::read_to_string(dir.join("User/settings.json")).ok();
- cx.simulate_keystrokes("cmd-k cmd-t");
+ cx.simulate_keystrokes("secondary-k secondary-t");
assert_eq!(
workbench.read_with(cx, rows),
[
@@ -98,7 +98,7 @@ fn the_picker_previews_the_focused_theme_writes_the_accepted_one_and_escape_rest
assert_eq!(sent(), [("$onColorThemeChange", vec![json!("dark")]), ("$acceptSyntaxHighlightingThemeChanged", vec![])]);
assert_eq!(user_settings(), None, "restoring the current theme writes nothing");
- cx.simulate_keystrokes("cmd-k cmd-t");
+ cx.simulate_keystrokes("secondary-k secondary-t");
cx.simulate_input("quiet");
cx.simulate_keystrokes("enter");
cx.run_until_parked();
@@ -110,7 +110,7 @@ fn the_picker_previews_the_focused_theme_writes_the_accepted_one_and_escape_rest
assert_eq!(methods, ["$onColorThemeChange", "$acceptSyntaxHighlightingThemeChanged", "$acceptConfigurationChanged"]);
// Picking the default again removes the user value (`updateValue` without a target).
- cx.simulate_keystrokes("cmd-k cmd-t");
+ cx.simulate_keystrokes("secondary-k secondary-t");
cx.simulate_input("dark 2026");
cx.simulate_keystrokes("enter");
assert_eq!(theme_id(cx), "Dark 2026");
diff --git a/native/crates/app/src/workbench/variable_menu.rs b/native/crates/app/src/workbench/variable_menu.rs
index 091c2aa4a16..d06afb45aaf 100644
--- a/native/crates/app/src/workbench/variable_menu.rs
+++ b/native/crates/app/src/workbench/variable_menu.rs
@@ -637,7 +637,7 @@ pub(super) mod tests {
click("scope/Local/x", cx);
cx.run_until_parked();
host.try_iter().for_each(drop);
- cx.simulate_keystrokes("cmd-c");
+ cx.simulate_keystrokes("secondary-c");
cx.run_until_parked();
let request = sent_request(&host, "evaluate");
assert_eq!(request["arguments"], json!({ "expression": "obj.x", "frameId": 9, "context": "variables" }));
@@ -647,12 +647,12 @@ pub(super) mod tests {
assert_eq!(stop_editing(cx), Some(Editing::Variable { session: "s".into(), parent_reference: 4, name: "x".into(), watch: false }));
click(format!("watch/{id}").leak(), cx);
- cx.simulate_keystrokes("cmd-alt-c");
+ cx.simulate_keystrokes("secondary-alt-c");
assert_eq!(clipboard(cx).as_deref(), Some("a + b"));
cx.simulate_keystrokes("enter");
assert_eq!(stop_editing(cx), Some(Editing::Watch(id)));
workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.debug_view.list_focus[WATCH_VIEW], cx));
- cx.simulate_keystrokes("cmd-backspace");
+ cx.simulate_keystrokes(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
assert!(workbench.read_with(cx, |workbench, _| workbench.debug.model.watch_expressions.is_empty()));
}