Skip to content

Visual Studio Code, rebuilt in Rust

Rust

test: press and label keys by the build's OS and build file uris per OS

rokartur264884105e56
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index bad0b6d51c7..76f5b5a81ed 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -2382,13 +2382,13 @@ mod tests {
cx.simulate_keystrokes("down end");
cx.simulate_input("!");
assert_eq!(text(cx), "ab\ncd!");
- cx.simulate_keystrokes("shift-home secondary-c");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-z secondary-z enter tab");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-z secondary-z enter tab"));
assert_eq!(text(cx), "ab\ncd\n ");
- cx.simulate_keystrokes("secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
@@ -2422,12 +2422,12 @@ mod tests {
});
receiver.try_iter().count();
- cx.simulate_keystrokes("secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
}
@@ -2460,7 +2460,7 @@ mod tests {
// wordHighlighter.ts stops the highlights once no code editor has the focus.
// toggleTabFocusMode.ts: Ctrl+M outside macOS.
- let toggle_tab_focus = if cfg!(target_os = "macos") { "ctrl-shift-m tab" } else { "ctrl-m tab" };
+ let toggle_tab_focus = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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");
@@ -2480,7 +2480,7 @@ mod tests {
let file = dir.join("a.txt");
std::fs::write(&file, "abc").unwrap();
let user_file = dir.join("keybindings.json");
- let primary = if cfg!(target_os = "macos") { "cmd" } else { "ctrl" };
+ let primary = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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" }}]"#
@@ -2498,19 +2498,19 @@ mod tests {
cx.simulate_keystrokes("end");
assert_eq!(column(cx), 0, "the user removed the default End binding");
- cx.simulate_keystrokes("secondary-k secondary-e");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k");
- let ctrl_k = if cfg!(target_os = "macos") { "⌘K" } else { "Ctrl+K" };
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k"));
+ let ctrl_k = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "⌘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");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-e"));
assert_eq!(column(cx), 3);
assert_eq!(status(cx), None, "leaving chord mode drops its message");
- cx.simulate_keystrokes("secondary-k x");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k x"));
let message = workbench.read_with(cx, |workbench, _| workbench.status_message.as_ref().map(|(message, _)| message.clone()));
assert_eq!(message, Some(format!("The key combination ({ctrl_k}, X) is not a command.")));
- cx.simulate_keystrokes("secondary-k secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
}
@@ -2535,22 +2535,22 @@ 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("secondary-k secondary-0");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k secondary-0"));
assert_eq!(hidden(cx), [1..4, 5..6], "editor.foldAll");
- cx.simulate_keystrokes("secondary-k secondary-j");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k secondary-j"));
assert!(hidden(cx).is_empty(), "editor.unfoldAll");
// 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-]") };
+ let (fold, unfold) = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { ("alt-cmd-[", "alt-cmd-]") } else { ("ctrl-shift-[", "ctrl-shift-]") };
cx.simulate_keystrokes(fold);
assert_eq!(hidden(cx), [1..4], "editor.fold");
cx.simulate_keystrokes(unfold);
assert!(hidden(cx).is_empty(), "editor.unfold");
- cx.simulate_keystrokes("down secondary-k secondary-[");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("down secondary-k secondary-["));
assert_eq!(hidden(cx), [2..3], "editor.foldRecursively");
- cx.simulate_keystrokes("secondary-k secondary-]");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k secondary-]"));
assert!(hidden(cx).is_empty(), "editor.unfoldRecursively");
- cx.simulate_keystrokes("alt-secondary-down");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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");
@@ -2559,7 +2559,7 @@ mod tests {
cx.simulate_keystrokes("up");
cx.simulate_keystrokes(fold);
receiver.try_iter().count();
- cx.simulate_keystrokes("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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:?}");
@@ -2586,7 +2586,7 @@ mod tests {
// The keys of the pixel-check "folded" window, dispatched like `--screenshot-keys` in main.rs.
cx.update(|window, cx| {
// 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-[" };
+ let keys = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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);
}
@@ -2628,14 +2628,14 @@ mod tests {
})
};
- cx.simulate_keystrokes("right secondary-k secondary-b");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k secondary-b down secondary-k secondary-k");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
}
@@ -2704,24 +2704,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("secondary-/");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-/"));
assert_eq!(lines(cx), ["// let a = 1;", " let b = 2;"], "editor.action.commentLine");
- cx.simulate_keystrokes("secondary-/");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-/"));
assert_eq!(lines(cx), ["let a = 1;", " let b = 2;"], "editor.action.commentLine removes");
- cx.simulate_keystrokes("secondary-a secondary-k secondary-c");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-a secondary-k secondary-c"));
assert_eq!(lines(cx), ["// let a = 1;", "// let b = 2;"], "editor.action.addCommentLine");
- cx.simulate_keystrokes("secondary-k secondary-u");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 secondary-/ shift-alt-a secondary-a secondary-k secondary-c");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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,14 +2750,14 @@ mod tests {
cx.simulate_keystrokes("shift-alt-down");
assert_eq!(lines(cx), ["two", "one", "one", "three"], "editor.action.copyLinesDownAction");
// linesOperations.ts binds joinLines on macOS only.
- match cfg!(target_os = "macos") {
+ match matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) {
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-secondary-k");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("shift-secondary-k"));
assert_eq!(lines(cx), ["two", "one"], "editor.action.deleteLines");
- cx.simulate_keystrokes("secondary-]");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-]"));
assert_eq!(lines(cx), ["two", " one"], "editor.action.indentLines");
std::fs::remove_dir_all(dir).unwrap();
}
@@ -2820,7 +2820,7 @@ mod tests {
cx.simulate_input("a");
cx.simulate_keystrokes("shift-tab");
cx.simulate_input("the");
- cx.simulate_keystrokes("alt-secondary-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/accessible_view.rs b/native/crates/app/src/workbench/accessible_view.rs
index 3ff9c529838..75e13610516 100644
--- a/native/crates/app/src/workbench/accessible_view.rs
+++ b/native/crates/app/src/workbench/accessible_view.rs
@@ -1115,7 +1115,7 @@ mod tests {
assert!(help && view_focused);
assert_eq!(lines[0], "The application is configured to never be optimized for usage with a Screen Reader.");
assert_eq!(lines[2], "You are in a code editor.");
- let (go_to_symbol, alt) = if cfg!(target_os = "macos") { ("Shift+Command+O", "Option") } else { ("Control+Shift+O", "Alt") };
+ let (go_to_symbol, alt) = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { ("Shift+Command+O", "Option") } else { ("Control+Shift+O", "Alt") };
assert!(lines.iter().any(|line| *line == format!("Go to Symbol ({go_to_symbol}) to quickly navigate between symbols in the current file.")), "{lines:#?}");
assert!(lines.iter().any(|line| line.contains("(unassigned keybinding)")));
assert_eq!(*lines.last().unwrap(), format!("Configure keybindings for commands that already have assignments ({alt}+A)."));
@@ -1136,7 +1136,7 @@ mod tests {
let item = workbench.notifications.model.item(key).unwrap().clone();
workbench.notification_aria_label(&item, window)
});
- assert_eq!(label, "Warning: Disk is full, notification, Inspect the response in the accessible view with Option+F2");
+ assert_eq!(label, format!("Warning: Disk is full, notification, Inspect the response in the accessible view with {alt}+F2"));
cx.run_until_parked();
let outcome = workbench.update_in(cx, |workbench, window, cx| workbench.execute_command("notifications.focusToasts", Vec::new(), window, cx));
drop(outcome);
diff --git a/native/crates/app/src/workbench/activity_bar_menu.rs b/native/crates/app/src/workbench/activity_bar_menu.rs
index 2cca20e05cd..f75c38b8cd7 100644
--- a/native/crates/app/src/workbench/activity_bar_menu.rs
+++ b/native/crates/app/src/workbench/activity_bar_menu.rs
@@ -599,7 +599,7 @@ mod tests {
let item = |title: &str, checked: bool, keybinding: Option<&str>| (title.to_owned(), true, checked, keybinding.map(str::to_owned));
let separator = ("---".to_owned(), false, false, None);
let rest = [separator.clone(), item("Accounts", false, None), separator, item("Activity Bar Position >", false, None), item("Activity Bar Size >", false, None), item("Move Primary Side Bar Right", false, None)];
- let keys = if cfg!(target_os = "macos") { ["⇧⌘E", "⇧⌘F", "⌃⇧G", "⇧⌘D", "⇧⌘X"] } else { ["Ctrl+Shift+E", "Ctrl+Shift+F", "Ctrl+Shift+G", "Ctrl+Shift+D", "Ctrl+Shift+X"] };
+ let keys = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { ["⇧⌘E", "⇧⌘F", "⌃⇧G", "⇧⌘D", "⇧⌘X"] } else { ["Ctrl+Shift+E", "Ctrl+Shift+F", "Ctrl+Shift+G", "Ctrl+Shift+D", "Ctrl+Shift+X"] };
let containers = [item("Explorer", true, Some(keys[0])), item("Search", true, Some(keys[1])), item("Source Control", true, Some(keys[2])), item("Run and Debug", true, Some(keys[3])), item("Extensions", true, Some(keys[4]))];
assert_eq!(right_click_activity_bar(&workbench, cx), [containers.as_slice(), rest.as_slice()].concat());
@@ -608,7 +608,7 @@ mod tests {
});
cx.update(|window, cx| drop(window.draw(cx)));
assert!(cx.debug_bounds("workbench.view.search").is_none(), "an unpinned container leaves the bar");
- assert_eq!(right_click_activity_bar(&workbench, cx)[1], item("Search", false, Some("⇧⌘F")));
+ assert_eq!(right_click_activity_bar(&workbench, cx)[1], item("Search", false, Some(keys[1])));
for id in ["workbench.view.scm", "workbench.view.debug", "workbench.view.extensions"] {
workbench.update_in(cx, |workbench, window, cx| {
diff --git a/native/crates/app/src/workbench/auxiliary_windows/tests.rs b/native/crates/app/src/workbench/auxiliary_windows/tests.rs
index 8ed959d345d..54a0945de87 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("secondary-w");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/backup_tracker/tests.rs b/native/crates/app/src/workbench/backup_tracker/tests.rs
index bdb9c76f153..85ddca18264 100644
--- a/native/crates/app/src/workbench/backup_tracker/tests.rs
+++ b/native/crates/app/src/workbench/backup_tracker/tests.rs
@@ -122,7 +122,7 @@ fn a_backup_of_a_deleted_file_restores_as_an_orphaned_model(cx: &mut TestAppCont
let (workbench, vcx) = open(cx, &dir, "{}");
let home = workbench.read_with(vcx, |workbench, _| workbench.lifecycle.backups.home.clone().unwrap());
let gone = dir.join("folder/gone.txt");
- let resource = crate::uri::Uri::new("file", "", &gone.to_string_lossy(), "", "").unwrap();
+ let resource = crate::uri::Uri::file(&gone.to_string_lossy());
backups::write(&home, &resource, "", Some(&json!({ "mtime": 1, "ctime": 1, "size": 1, "etag": "x", "orphaned": true })), b"kept").unwrap();
let (restored, vcx) = open(cx, &dir, "{}");
@@ -230,7 +230,7 @@ fn notebook_data(source: &str) -> Value {
fn a_dirty_notebook_backs_up_through_its_serializer_and_opens_from_its_backup(cx: &mut TestAppContext) {
let dir = scratch();
std::fs::write(dir.join("folder/a.tnb"), "saved").unwrap();
- let uri = crate::uri::Uri::new("file", "", &dir.join("folder/a.tnb").to_string_lossy(), "", "").unwrap();
+ let uri = crate::uri::Uri::file(&dir.join("folder/a.tnb").to_string_lossy());
let key = crate::notebook::uri_string(&uri.to_json());
let home;
{
diff --git a/native/crates/app/src/workbench/breadcrumbs/tests.rs b/native/crates/app/src/workbench/breadcrumbs/tests.rs
index 062386eac8c..eb2a3fd078f 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("secondary-shift-;");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-shift-; escape");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-shift-.");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 secondary-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-shift-.");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 d203ea13344..0a7649570ea 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("secondary-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 b7483668307..16747be3902 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("secondary-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 d5195ab5e11..ba18b0c04f3 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("secondary-f a n n");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-down");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/custom_documents/tests.rs b/native/crates/app/src/workbench/custom_documents/tests.rs
index 80f74f8a7e5..08980d3edbd 100644
--- a/native/crates/app/src/workbench/custom_documents/tests.rs
+++ b/native/crates/app/src/workbench/custom_documents/tests.rs
@@ -51,7 +51,7 @@ fn register_provider(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestCon
}
fn resource(dir: &Path) -> Value {
- Uri::new("file", "", &dir.join("folder/a.bin").to_string_lossy(), "", "").unwrap().to_json()
+ Uri::file(&dir.join("folder/a.bin").to_string_lossy()).to_json()
}
/// The next message to `method`, the ones before it dropped (their calls cancelled).
@@ -394,7 +394,7 @@ fn reopen_as_text_turns_an_inline_custom_diff_into_the_text_diff(cx: &mut TestAp
let extension = json!({ "id": "port.test", "location": { "scheme": "file", "path": "/ext" } });
let args = [extension, json!("test.text"), json!({}), json!({ "supportsInlineDiff": true }), json!(false)];
let side = |name: &str| crate::diff_editor::Side { scheme: "file".into(), path: dir.join("folder").join(name) };
- let modified = Uri::new("file", "", &dir.join("folder/b.txt").to_string_lossy(), "", "").unwrap().to_json();
+ let modified = Uri::file(&dir.join("folder/b.txt").to_string_lossy()).to_json();
workbench.update_in(cx, |workbench, window, cx| {
drop(workbench.handle_custom_editors_request("$registerTextEditorProvider", &args, window, cx));
drop(workbench.open_custom_editor("test.text".into(), modified, Some((side("a.txt"), None)), json!({}), window, cx));
@@ -422,7 +422,7 @@ fn the_modal_header_of_a_custom_diff_offers_reopen_as_text(cx: &mut TestAppConte
let extension = json!({ "id": "port.test", "location": { "scheme": "file", "path": "/ext" } });
let args = [extension, json!("test.text"), json!({}), json!({ "supportsInlineDiff": true }), json!(false)];
let side = |name: &str| crate::diff_editor::Side { scheme: "file".into(), path: dir.join("folder").join(name) };
- let modified = Uri::new("file", "", &dir.join("folder/b.txt").to_string_lossy(), "", "").unwrap().to_json();
+ let modified = Uri::file(&dir.join("folder/b.txt").to_string_lossy()).to_json();
workbench.update_in(cx, |workbench, window, cx| {
workbench.update_setting("workbench.editor.useModal", json!("all"));
drop(workbench.handle_custom_editors_request("$registerTextEditorProvider", &args, window, cx));
diff --git a/native/crates/app/src/workbench/debug_hover/tests.rs b/native/crates/app/src/workbench/debug_hover/tests.rs
index 53c931a1a90..9e5bf5a7f3c 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("secondary-alt-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-alt-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-alt-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 3d60ca9c447..cd2634bf227 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("secondary-k secondary-k");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k secondary-k");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-u enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 a7740608354..0e984fda32f 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("secondary-\\");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-\\");
- cx.simulate_keystrokes("secondary-\\");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-\\"));
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-\\");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-\\");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 4fa17e178f1..1fb1159835d 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("secondary-k shift-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k shift-enter");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 ff1eb73b4ea..dcdd50ae83b 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("secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/diff_editor_view/tests.rs b/native/crates/app/src/workbench/editor_view/diff_editor_view/tests.rs
index 449babe75c9..711b6e9c7a6 100644
--- a/native/crates/app/src/workbench/editor_view/diff_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/editor_view/diff_editor_view/tests.rs
@@ -39,7 +39,7 @@ fn char_ranges_fill_the_line_break_only_for_model_decorations() {
}
fn file_uri(path: &Path) -> Value {
- json!({ "scheme": "file", "path": path.to_string_lossy() })
+ crate::editor::uri_value("file", path)
}
fn tab_operations(receiver: &Receiver<HostMessage>) -> Vec<Value> {
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 cd47d621ef8..63c1a8673c5 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
@@ -36,7 +36,7 @@ fn workbench_with_folder<'a>(name: &str, folder: bool, cx: &'a mut TestAppContex
}
fn file_uri(path: &Path) -> Value {
- json!({ "scheme": "file", "path": path.to_string_lossy() })
+ crate::editor::uri_value("file", path)
}
fn run(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext, command: &str, args: Vec<Value>) {
@@ -71,7 +71,7 @@ fn open_merge_editor_resets_the_conflict_and_accepts_incoming(cx: &mut TestAppCo
let opened = receiver.try_iter().filter(|message| message.method == "$acceptTabOperation").map(|message| message.args[0].clone()).filter(|operation| operation["kind"] == 0).last().unwrap();
assert_eq!(opened["tabDto"]["input"]["kind"], 3);
- assert_eq!(opened["tabDto"]["input"]["result"]["path"], json!(dir.join("result.txt").to_string_lossy()));
+ assert_eq!(opened["tabDto"]["input"]["result"]["path"], file_uri(&dir.join("result.txt"))["path"]);
run(&workbench, cx, "merge.goToNextUnhandledConflict", Vec::new());
run(&workbench, cx, "merge.toggleActiveConflictInput1", Vec::new());
@@ -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-secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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-secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("shift-secondary-t"));
assert_eq!(focus(cx), (Some(Input::Two), json!(false)));
- cx.simulate_keystrokes("shift-secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("shift-secondary-t"));
assert_eq!(focus(cx), (Some(Input::One), json!(false)));
std::fs::remove_dir_all(dir).unwrap();
}
@@ -339,7 +339,7 @@ fn a_long_result_path_is_cut_before_the_conflict_counter(cx: &mut TestAppContext
assert!(path.right() <= counter.left(), "the path {path:?} ends before the counter {counter:?}");
assert!(counter.right() <= width, "the counter {counter:?} stays in the window {width:?}");
let shown = workbench.read_with(cx, |workbench, _| workbench.merge_result_path(workbench.merge_result().unwrap()));
- assert_eq!(shown, format!("{}/result.txt", "a".repeat(200)), "the path is relative to the folder");
+ assert_eq!(shown, Path::new(&"a".repeat(200)).join("result.txt").display().to_string(), "the path is relative to the folder");
std::fs::remove_dir_all(dir).unwrap();
}
diff --git a/native/crates/app/src/workbench/editor_view/multi_diff_editor_view/tests.rs b/native/crates/app/src/workbench/editor_view/multi_diff_editor_view/tests.rs
index 8fe7b13e170..b3c84976809 100644
--- a/native/crates/app/src/workbench/editor_view/multi_diff_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/editor_view/multi_diff_editor_view/tests.rs
@@ -28,7 +28,7 @@ fn workbench_in<'a>(name: &str, cx: &'a mut TestAppContext) -> (PathBuf, gpui::E
}
fn file_uri(path: &Path) -> Value {
- json!({ "scheme": "file", "path": path.to_string_lossy() })
+ crate::editor::uri_value("file", path)
}
#[gpui::test]
@@ -317,9 +317,10 @@ fn every_file_side_asks_for_its_commenting_ranges(cx: &mut TestAppContext) {
workbench.handle_comments_request("$updateCommentingRanges", &[json!(1)], window, cx);
});
cx.run_until_parked();
- let asked: Vec<Value> = receiver.try_iter().filter(|message| message.method == "$provideCommentingRanges").map(|message| message.args[1]["path"].clone()).collect();
+ // fsPath: a model keyed by its URI string comes back with a lowercase drive letter on Windows.
+ let asked: Vec<String> = receiver.try_iter().filter(|message| message.method == "$provideCommentingRanges").map(|message| crate::uri::json_fs_path(&message.args[1])).collect();
for side in [a, b, c] {
- assert!(asked.contains(&side["path"]), "{asked:?} has {side}");
+ assert!(asked.contains(&crate::uri::json_fs_path(&side)), "{asked:?} has {side}");
}
std::fs::remove_dir_all(dir).unwrap();
}
@@ -450,8 +451,8 @@ fn a_file_side_is_a_code_editor_that_takes_the_press_typing_and_find(cx: &mut Te
cx.simulate_input("x");
cx.run_until_parked();
assert_eq!(line("b.txt", cx), "TWOx");
- let changed: Vec<Value> = receiver.try_iter().filter(|message| message.method == "$acceptModelChanged").map(|message| message.args[0]["path"].clone()).collect();
- assert_eq!(changed, [json!(dir.join("b.txt"))], "the host sees the edit of the file, not of the multi diff tab");
+ let changed: Vec<String> = receiver.try_iter().filter(|message| message.method == "$acceptModelChanged").map(|message| crate::uri::json_fs_path(&message.args[0])).collect();
+ assert_eq!(changed, [crate::uri::json_fs_path(&file_uri(&dir.join("b.txt")))], "the host sees the edit of the file, not of the multi diff tab");
assert_eq!(tab(cx), (true, false), "the edit makes the tab dirty and pins it");
let tabs = |cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.editors.iter().map(|tab| (tab.document().path.clone(), tab.preview)).collect::<Vec<_>>());
assert_eq!(tabs(cx).len(), 1);
diff --git a/native/crates/app/src/workbench/explorer_actions/tests.rs b/native/crates/app/src/workbench/explorer_actions/tests.rs
index efaf2f4f323..1aa8a63bd14 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("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-c secondary-v");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-v");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-v"));
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy 2.txt", "c copy.txt", "c.txt", "sub"]);
- cx.simulate_keystrokes("secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-z"));
cx.run_until_parked();
assert_eq!(names(&dir), ["c copy.txt", "c.txt", "sub"]);
- cx.simulate_keystrokes("shift-secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-x");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-v");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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(if cfg!(target_os = "macos") { "alt-cmd-backspace" } else { "shift-delete" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "alt-cmd-backspace" } else { "shift-delete" });
cx.run_until_parked();
assert_eq!(names(&dir), ["c.txt", "sub"]);
- cx.simulate_keystrokes("secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-v");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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");
@@ -306,7 +306,7 @@ fn copy_path_copies_the_selected_items_paths(cx: &mut TestAppContext) {
let clipboard = |cx: &mut VisualTestContext| cx.read_from_clipboard().and_then(|item| item.text()).unwrap();
select(&workbench, &dir.join("sub"), cx);
// 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") };
+ let (copy_path, copy_relative_path) = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { ("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(copy_relative_path);
@@ -762,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("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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");
@@ -772,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(if cfg!(target_os = "macos") { "up cmd-down" } else { "up enter" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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("secondary-left");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-left"));
assert_eq!(rows(&workbench, cx), ["sub", "a.txt"], "cmd-left collapses every folder");
std::fs::remove_dir_all(&dir).unwrap();
}
@@ -828,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-secondary-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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.
@@ -848,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-secondary-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/extension_features/tests.rs b/native/crates/app/src/workbench/extension_features/tests.rs
index fe5f56dce98..c4dfd92a772 100644
--- a/native/crates/app/src/workbench/extension_features/tests.rs
+++ b/native/crates/app/src/workbench/extension_features/tests.rs
@@ -86,7 +86,11 @@ fn commands_list_their_keybindings_and_menus_with_the_implicit_command_palette()
assert_eq!(rows[1][3], markdown("`commandPalette`&nbsp;`editor/title`"));
let Cell::Keybindings(keybindings) = &rows[1][2] else { panic!("the keybindings cell") };
assert_eq!(keybindings.len(), 1);
- let platform_key = if cfg!(target_os = "macos") { "⌘" } else if cfg!(windows) { "Alt" } else { "Shift" };
+ let platform_key = match crate::keybindings::OS {
+ crate::keybindings::Os::Macintosh => "⌘",
+ crate::keybindings::Os::Windows => "Alt",
+ crate::keybindings::Os::Linux => crate::keybindings::ui_modifier_labels(crate::keybindings::OS).0[1],
+ };
assert!(keybindings[0][0].contains(&platform_key.to_owned()), "the platform's key wins: {keybindings:?}");
assert_eq!(rows[2][1], text(""));
}
diff --git a/native/crates/app/src/workbench/file_compare/tests.rs b/native/crates/app/src/workbench/file_compare/tests.rs
index 8bac46630a9..c283bff66fe 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("secondary-k d");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 068e0541a0b..965b91253b7 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("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/host/tests.rs b/native/crates/app/src/workbench/host/tests.rs
index 5a5ac8a9266..5d9e800ed2e 100644
--- a/native/crates/app/src/workbench/host/tests.rs
+++ b/native/crates/app/src/workbench/host/tests.rs
@@ -47,7 +47,7 @@ fn launch_vs_code_opens_an_extension_development_window_with_the_debug_flags(cx:
assert_eq!((response["command"].clone(), response["success"].clone()), (json!("launchVSCode"), json!(true)));
let opened: Vec<_> = vcx.windows().into_iter().filter_map(|handle| handle.downcast::<Workbench>()).filter_map(|handle| handle.read_with(vcx, |workbench, _| workbench.development.clone().map(|development| (development.extension_path, workbench.extension_host_debug.clone()))).ok().flatten()).collect();
let env = [("A".to_owned(), "1".to_owned())].into_iter().collect();
- assert_eq!(opened, [(PathBuf::from("/tmp/ext"), ExtensionHostDebug { port: Some(9229), break_on_start: true, debug_id: Some("s".into()), env })]);
+ assert_eq!(opened, [(std::path::absolute("/tmp/ext").unwrap(), ExtensionHostDebug { port: Some(9229), break_on_start: true, debug_id: Some("s".into()), env })]);
}
/// debugService.ts `onDidEndAdapter` (#3905): the end of a 'Run Without Debugging' extension host session closes its
diff --git a/native/crates/app/src/workbench/host_requests/tests.rs b/native/crates/app/src/workbench/host_requests/tests.rs
index 77e4afa6495..d90b97dd4ae 100644
--- a/native/crates/app/src/workbench/host_requests/tests.rs
+++ b/native/crates/app/src/workbench/host_requests/tests.rs
@@ -28,7 +28,7 @@ fn open(workbench: &gpui::Entity<Workbench>, args: Vec<Value>, cx: &mut VisualTe
}
fn file_uri(path: &Path) -> Value {
- json!({ "scheme": "file", "path": path.to_string_lossy() })
+ crate::editor::uri_value("file", path)
}
#[gpui::test]
diff --git a/native/crates/app/src/workbench/hover/tests.rs b/native/crates/app/src/workbench/hover/tests.rs
index a9e40da7bf8..7ac1a89f97e 100644
--- a/native/crates/app/src/workbench/hover/tests.rs
+++ b/native/crates/app/src/workbench/hover/tests.rs
@@ -165,11 +165,11 @@ fn title_bar_end(width: Pixels) -> Pixels {
width - px(if cfg!(windows) { 138. } else { 0. })
}
-const TOGGLE_PANEL: &str = if cfg!(target_os = "macos") { "Toggle Panel (⌘J)" } else { "Toggle Panel (Ctrl+J)" };
-const TOGGLE_SECONDARY_SIDE_BAR: &str = if cfg!(target_os = "macos") { "Toggle Secondary Side Bar (⌥⌘B)" } else { "Toggle Secondary Side Bar (Ctrl+Alt+B)" };
+const TOGGLE_PANEL: &str = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "Toggle Panel (⌘J)" } else { "Toggle Panel (Ctrl+J)" };
+const TOGGLE_SECONDARY_SIDE_BAR: &str = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "Toggle Secondary Side Bar (⌥⌘B)" } else { "Toggle Secondary Side Bar (Ctrl+Alt+B)" };
/// toggleTabFocusMode.ts: Ctrl+Shift+M on macOS, Ctrl+M elsewhere.
-const TOGGLE_TAB_FOCUS: &str = if cfg!(target_os = "macos") { "ctrl-shift-m" } else { "ctrl-m" };
+const TOGGLE_TAB_FOCUS: &str = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "ctrl-shift-m" } else { "ctrl-m" };
fn wait(cx: &mut gpui::VisualTestContext, ms: u64) {
cx.executor().advance_clock(Duration::from_millis(ms));
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 61ed61c6486..d7eca4525f5 100644
--- a/native/crates/app/src/workbench/keybindings_editor_view/tests.rs
+++ b/native/crates/app/src/workbench/keybindings_editor_view/tests.rs
@@ -66,7 +66,11 @@ fn the_row_menu_enables_what_the_keybinding_allows() {
#[test]
fn copy_writes_the_user_settings_form_with_the_when_only_when_set() {
// usLayoutResolvedKeybinding.ts `_getUserSettingsLabel`: the Meta key is `cmd`, `win` or `meta` by OS.
- let meta = if cfg!(target_os = "macos") { "cmd" } else if cfg!(windows) { "win" } else { "meta" };
+ let meta = match crate::keybindings::OS {
+ crate::keybindings::Os::Macintosh => "cmd",
+ crate::keybindings::Os::Windows => "win",
+ crate::keybindings::Os::Linux => "meta",
+ };
assert_eq!(copied_entry(&entry("cmd+k cmd+s", "", true, "Save")), format!("{{\n \"key\": \"{meta}+k {meta}+s\",\n \"command\": \"workbench.action.files.save\"\n}}"));
assert!(copied_entry(&entry("cmd+s", "editorFocus", true, "Save")).ends_with("\"when\": \"editorFocus\"\n}"));
}
@@ -97,7 +101,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("secondary-k secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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());
@@ -192,7 +196,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("secondary-k secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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");
@@ -200,13 +204,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("secondary-down");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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");
@@ -223,7 +227,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("secondary-k secondary-j");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
@@ -232,7 +236,7 @@ fn keys_define_a_keybinding_that_lands_in_keybindings_json(cx: &mut TestAppConte
assert_eq!(workbench.read_with(cx, |workbench, _| workbench.keybindings_editor.entries[0].row.keybinding.clone()), parse_keybinding("cmd+k cmd+j"));
// 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.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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);
@@ -254,7 +258,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(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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.
@@ -266,8 +270,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("secondary-k secondary-s");
- cx.simulate_keystrokes("secondary-shift-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k secondary-s"));
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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.
@@ -281,8 +285,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("secondary-k secondary-s");
- cx.simulate_keystrokes("secondary-shift-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-k secondary-s"));
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-shift-p"));
assert!(workbench.read_with(cx, |workbench, _| workbench.quick_inputs.current().is_some()));
}
@@ -291,7 +295,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("secondary-k secondary-s");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/local_history_actions/tests.rs b/native/crates/app/src/workbench/local_history_actions/tests.rs
index 0483fe05465..6b2986d7996 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("secondary-a");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 b8095f11344..899123acad0 100644
--- a/native/crates/app/src/workbench/menubar/tests.rs
+++ b/native/crates/app/src/workbench/menubar/tests.rs
@@ -36,7 +36,7 @@ fn command<'a>(menubar: &'a Menubar, menu: &str, id: &str) -> &'a MenuAction {
/// 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") {
+ if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) {
titles.push("Preferences");
}
titles
@@ -233,7 +233,7 @@ fn open_recent_lists_folders_then_files_before_more(cx: &mut TestAppContext) {
});
workbench.read(cx).menubar(window)
});
- let (folder, file) = (Path::new("/tmp/a&b").display().to_string(), Path::new("/tmp/one.txt").display().to_string());
+ let (folder, file) = (crate::uri::Uri::file("/tmp/a&b").fs_path(), crate::uri::Uri::file("/tmp/one.txt").fs_path());
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);
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 eb4b9a5fa21..6d1004a767f 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("secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-w");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 87b8f611c1d..53464a37f70 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("secondary-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-down");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 f6b68d9959c..962c3b77cca 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-secondary-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 c1929a1b006..7f7a25c0e21 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("secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-j");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-j");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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-secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k z");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k z");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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-secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-b");
+ window_cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/preferences/tests.rs b/native/crates/app/src/workbench/preferences/tests.rs
index 75d8a62c663..0e1057c97d0 100644
--- a/native/crates/app/src/workbench/preferences/tests.rs
+++ b/native/crates/app/src/workbench/preferences/tests.rs
@@ -91,7 +91,7 @@ fn an_open_settings_file_marks_its_unknown_settings_until_it_closes(cx: &mut Tes
assert_eq!(markers(&workbench, cx), Vec::new(), "the renderer waits 200ms");
cx.executor().advance_clock(std::time::Duration::from_millis(200));
cx.run_until_parked();
- let resource = crate::editor::uri_string(files::user_data::SCHEME, &dir.join("User/settings.json"));
+ let resource = crate::editor::uri_string(files::user_data::SCHEME, &dir.join("User").join("settings.json"));
assert_eq!(markers(&workbench, cx), vec![(resource, "Unknown Configuration Setting".to_string(), 3, 31)]);
run(&workbench, cx, "workbench.action.closeActiveEditor", vec![]);
@@ -130,7 +130,8 @@ fn the_default_keybindings_file_lists_the_defaults_then_the_unbound_commands(cx:
});
assert_eq!(name, "Default Keybindings");
assert_eq!(lines[..2], ["// Override key bindings by placing them into your key bindings file.", "["]);
- assert!(lines.contains(&"{ \"key\": \"cmd+,\", \"command\": \"workbench.action.openSettings\" },".to_string()));
+ let key = format!("\"{}\",", if cfg!(windows) { "ctrl+," } else { "cmd+," });
+ assert!(lines.contains(&format!("{{ \"key\": {key:<25}\"command\": \"workbench.action.openSettings\" }},")), "{lines:#?}");
let when = lines.iter().position(|line| line.trim_start().starts_with("\"when\": ")).unwrap();
assert!(lines[when].starts_with(" \"when\": \"") && lines[when - 1].ends_with(","));
let unbound = lines.iter().position(|line| line == "// Here are other available commands: ").unwrap();
diff --git a/native/crates/app/src/workbench/quick_access/tests.rs b/native/crates/app/src/workbench/quick_access/tests.rs
index 5c8a6bb7e71..08d50d5d27e 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-secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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-secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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:?}");
@@ -87,10 +87,10 @@ fn command_palette_runs_an_extension_command_and_remembers_it(cx: &mut TestAppCo
let item = &input.rows[input.order[0]].item;
(item.label.clone(), item.keybinding.clone())
});
- let primary = if cfg!(target_os = "macos") { "⌘" } else { "Ctrl" };
+ let primary = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "⌘" } else { "Ctrl" };
assert_eq!(row, ("Preferences: Color Theme".to_string(), vec![vec![primary.to_string(), "K".to_string()], vec![primary.to_string(), "T".to_string()]]));
- cx.simulate_keystrokes("secondary-a backspace");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-a backspace"));
cx.simulate_input(">zzzz");
assert_eq!(workbench.read_with(cx, labels), ["No matching commands"]);
cx.simulate_keystrokes("enter");
@@ -167,11 +167,11 @@ fn help_lists_the_providers_and_shows_the_picked_one(cx: &mut TestAppContext) {
})
};
- cx.simulate_keystrokes("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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."));
- let keys = if cfg!(target_os = "macos") {
+ let keys = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) {
[r#"[["⌘", "P"]]"#, r#"[["⌃", "G"]]"#, r#"[["⇧", "⌘", "O"]]"#, r#"[["⌘", "T"]]"#, r#"[["⇧", "⌘", "P"]]"#, r#"[["⌥", "⌘", "Tab"]]"#]
} else {
[r#"[["Ctrl", "P"]]"#, r#"[["Ctrl", "G"]]"#, r#"[["Ctrl", "Shift", "O"]]"#, r#"[["Ctrl", "T"]]"#, r#"[["Ctrl", "Shift", "P"]]"#, r#"[["Ctrl", "K"], ["Ctrl", "P"]]"#]
@@ -194,7 +194,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 secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("escape secondary-p"));
cx.simulate_input("?>");
cx.run_until_parked();
assert_eq!(picker(cx).0, ">", "a typed prefix shows its provider");
@@ -272,11 +272,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("secondary-a backspace");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-a backspace"));
cx.simulate_input("view zzzz");
assert_eq!(workbench.read_with(cx, labels), ["No matching views"]);
- cx.simulate_keystrokes("secondary-a backspace");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 ba16516845f..30da300775b 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-secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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-secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-z");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 20cdbb63127..c2eb7123b72 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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 c007a2e3367..59613b27463 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("secondary-backspace");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/repl_notebook/tests.rs b/native/crates/app/src/workbench/repl_notebook/tests.rs
index 25db47fbce1..45a12a5b8cf 100644
--- a/native/crates/app/src/workbench/repl_notebook/tests.rs
+++ b/native/crates/app/src/workbench/repl_notebook/tests.rs
@@ -69,7 +69,7 @@ fn a_notebook_shown_as_repl_executes_its_last_cell(cx: &mut TestAppContext) {
workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), dir.join("User/keybindings.json")));
assert_eq!(hint(cx), Some(vec!["Enter".to_owned()]));
workbench.update(cx, |workbench, _| workbench.update_setting("interactiveWindow.executeWithShiftEnter", json!(true)));
- let shift = if cfg!(target_os = "macos") { "⇧" } else { "Shift" };
+ let shift = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "⇧" } else { "Shift" };
assert_eq!(hint(cx), Some(vec![shift.to_owned(), "Enter".to_owned()]));
workbench.update(cx, |workbench, _| workbench.update_setting("interactiveWindow.executeWithShiftEnter", json!(false)));
diff --git a/native/crates/app/src/workbench/search_actions/tests.rs b/native/crates/app/src/workbench/search_actions/tests.rs
index ad5d6e8d39d..6f25b61c2c3 100644
--- a/native/crates/app/src/workbench/search_actions/tests.rs
+++ b/native/crates/app/src/workbench/search_actions/tests.rs
@@ -61,7 +61,7 @@ fn message(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext) -> S
fn result_files(workbench: &gpui::Entity<Workbench>, dir: &Path, cx: &mut VisualTestContext) -> Vec<(String, usize)> {
workbench.read_with(cx, |workbench, _| {
- workbench.search.result.files.iter().map(|file| (file.path.strip_prefix(dir).unwrap().to_string_lossy().into_owned(), file.matches.len())).collect()
+ workbench.search.result.files.iter().map(|file| (file.path.strip_prefix(dir).unwrap().to_string_lossy().replace('\\', "/"), file.matches.len())).collect()
})
}
@@ -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("secondary-shift-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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(if cfg!(target_os = "macos") { "alt-cmd-r" } else { "alt-r" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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-secondary-1");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "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("secondary-shift-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-shift-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-shift-f");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
@@ -361,7 +361,8 @@ fn open_in_editor_serializes_the_results_into_a_search_editor(cx: &mut TestAppCo
run(&workbench, "search.action.openInEditor", Vec::new(), cx);
let (scheme, name, text) = active_editor(&workbench, cx);
assert_eq!((scheme.as_str(), name.as_str()), ("search-editor", "Search: alphabet"));
- assert_eq!(text, "1 result - 1 file\n\nsub/b.txt:\n 1: alphabet alpha\n");
+ // searchEditorSerialization.ts labels files relative with the OS separator.
+ assert_eq!(text, format!("1 result - 1 file\n\n{}:\n 1: alphabet alpha\n", Path::new("sub").join("b.txt").display()));
let ranges = workbench.read_with(cx, |workbench, _| workbench.search_editors.values().next().unwrap().match_ranges.clone());
assert_eq!(ranges.len(), 1);
assert!(workbench.read_with(cx, |workbench, _| !workbench.editors.active().unwrap().is_dirty()));
@@ -382,7 +383,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("secondary-shift-p");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("secondary-shift-p"));
cx.simulate_input("New Search Editor");
cx.run_until_parked();
cx.simulate_keystrokes("enter");
@@ -404,14 +405,15 @@ 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("secondary-shift-l");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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();
+ let header = format!("{}:", Path::new("sub").join("b.txt").display());
+ let line = text.lines().position(|line| line == header).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("secondary-shift-backspace");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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 2def5ea969c..b9743a69cb8 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("secondary-k secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-k secondary-t");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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/timeline_view/tests.rs b/native/crates/app/src/workbench/timeline_view/tests.rs
index 32b578d39b1..74585f90885 100644
--- a/native/crates/app/src/workbench/timeline_view/tests.rs
+++ b/native/crates/app/src/workbench/timeline_view/tests.rs
@@ -37,7 +37,7 @@ fn answer(request: &mut HostMessage, items: Value) {
}
fn file_uri(path: &Path) -> Value {
- json!({ "$mid": 1, "scheme": "file", "authority": "", "path": path.to_string_lossy(), "query": "", "fragment": "" })
+ crate::uri::Uri::file(&path.to_string_lossy()).to_json()
}
fn titles(actions: Vec<MenuAction>) -> Vec<String> {
@@ -100,7 +100,7 @@ fn the_workspace_timeline_shows_without_an_editor_and_pins(cx: &mut TestAppConte
});
cx.run_until_parked();
let requests = timeline_requests(&receiver);
- assert_eq!(requests.last().unwrap().args[1]["path"], json!(dir.join("a.txt").to_string_lossy()));
+ assert_eq!(requests.last().unwrap().args[1]["path"], file_uri(&dir.join("a.txt"))["path"]);
workbench.update_in(cx, |workbench, window, cx| {
assert!(!workbench.timeline.model.workspace);
assert!(title_menu(workbench, window).contains(&"Pin Workspace Timeline".to_string()));
diff --git a/native/crates/app/src/workbench/title_bar_actions/tests.rs b/native/crates/app/src/workbench/title_bar_actions/tests.rs
index e78c5ee2faa..91c5515037f 100644
--- a/native/crates/app/src/workbench/title_bar_actions/tests.rs
+++ b/native/crates/app/src/workbench/title_bar_actions/tests.rs
@@ -79,7 +79,7 @@ fn the_title_bar_menus_toggle_the_command_center_and_the_layout_controls(cx: &mu
let rows = input.order.iter().map(|row| &input.rows[*row]);
(input.input_box.value.clone(), rows.map(|row| format!("{}|{}|{:?}", row.item.label, row.item.description.clone().unwrap_or_default(), row.item.keybinding)).collect::<Vec<_>>())
});
- let (go_to_file, commands, symbols) = if cfg!(target_os = "macos") {
+ let (go_to_file, commands, symbols) = if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) {
(r#"[["⌘", "P"]]"#, r#"[["⇧", "⌘", "P"]]"#, r#"[["⇧", "⌘", "O"]]"#)
} else {
(r#"[["Ctrl", "P"]]"#, r#"[["Ctrl", "Shift", "P"]]"#, r#"[["Ctrl", "Shift", "O"]]"#)
diff --git a/native/crates/app/src/workbench/variable_menu.rs b/native/crates/app/src/workbench/variable_menu.rs
index d06afb45aaf..bf39476764e 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("secondary-c");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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("secondary-alt-c");
+ cx.simulate_keystrokes(&crate::keybindings::primary_keys("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(if cfg!(target_os = "macos") { "cmd-backspace" } else { "delete" });
+ cx.simulate_keystrokes(if matches!(crate::keybindings::OS, crate::keybindings::Os::Macintosh) { "cmd-backspace" } else { "delete" });
assert!(workbench.read_with(cx, |workbench, _| workbench.debug.model.watch_expressions.is_empty()));
}