Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(windows): open Finder documents in the dock context as upstream

rokartur120c96aa296e
diff --git a/native/crates/app/src/launch.rs b/native/crates/app/src/launch.rs
index e90bfcd3c07..6d711081b77 100644
--- a/native/crates/app/src/launch.rs
+++ b/native/crates/app/src/launch.rs
@@ -86,7 +86,7 @@ pub fn handle_launches(mut launches: UnboundedReceiver<Launch>, cx: &mut App) {
cx.spawn(async move |cx| {
while let Some(launch) = launches.next().await {
let _ = cx.update(|cx| match launch {
- Launch::Open { args, cwd } => crate::workbench::host::start_open_window(args, cwd, cx),
+ Launch::Open { args, cwd } => crate::workbench::host::start_open_window(args, cwd, false, cx),
Launch::Status(reply) => drop(reply.send(main_diagnostics(cx))),
});
}
diff --git a/native/crates/app/src/main.rs b/native/crates/app/src/main.rs
index e88ddaca31a..876a5d841d6 100644
--- a/native/crates/app/src/main.rs
+++ b/native/crates/app/src/main.rs
@@ -257,28 +257,10 @@ fn main() -> anyhow::Result<()> {
false => Arc::new(Mutex::new(open_shared_storage(flag_value("--shared-data-dir").map(PathBuf::from))?)),
};
let cli_profile = CliProfile::from_args(&args);
- // windowsMainService.ts: a start without paths, or any start with `preserve`, opens the last session's windows;
- // app.ts: one with a forced profile opens only its new empty window.
- let restored = match (development.is_some() || cli_profile.is_forced() || screenshot.is_some() || export_default_keybindings.is_some() || open_url.is_some(), positional.is_empty()) {
- (true, _) => Vec::new(),
- (false, no_paths) => {
- let user_settings = Settings::load(Registry::with_extensions(&[]), user_data.join("User"), None);
- let setting = user_settings.get_value(Some("window.restoreWindows"), &Overrides::default()).and_then(|value| value.as_str().map(str::to_owned)).unwrap_or_else(|| "all".into());
- let restore_fullscreen = user_settings.get_value(Some("window.restoreFullscreen"), &Overrides::default()) == Some(json!(true));
- let (last_active, opened) = windows_state::load(&user_data);
- let mut windows = match no_paths || setting == "preserve" {
- true => windows_state::to_restore(&setting, last_active, opened),
- false => Vec::new(),
- };
- // windowsStateHandler.ts `getNewWindowState`: fullscreen comes back only with `window.restoreFullscreen`.
- for ui in windows.iter_mut().filter_map(|window| window.ui.as_mut()).filter(|ui| ui.mode == windows_state::FULLSCREEN && !restore_fullscreen) {
- ui.mode = windows_state::NORMAL;
- }
- windows
- }
- };
+ // app.ts: a start with a forced profile opens only its new empty window.
+ let restores = !(development.is_some() || cli_profile.is_forced() || screenshot.is_some() || export_default_keybindings.is_some() || open_url.is_some());
let app = AppState { args: args.clone(), runtime, user_data, app_root, builtins, user_extensions_folder: extensions_folder, shared_storage };
- let startup = (!positional.is_empty() || restored.is_empty()).then(|| WindowRequest { workspace, files, development, open_url, screenshot, screenshot_keys, screenshot_input, export_default_keybindings, profile: cli_profile, ..WindowRequest::default() });
+ let startup = WindowRequest { workspace, files, development, open_url, screenshot, screenshot_keys, screenshot_input, export_default_keybindings, profile: cli_profile, ..WindowRequest::default() };
let application = application();
// A click on the Dock icon without a window opens an empty one, as `app.on('activate')` does in app.ts.
application.on_reopen(|cx| {
@@ -294,30 +276,32 @@ fn main() -> anyhow::Result<()> {
application.run(move |cx: &mut App| {
perf::mark("code/mainAppReady");
workbench::accessibility::watch_assistive_apps(cx);
- // app.ts `macOpenFiles`: AppKit sends the launch's documents before `applicationDidFinishLaunching:`; they replace the
- // last session's windows and open from the task, as effects deferred from this callback never run.
- let launch_urls: Vec<Vec<String>> = std::iter::from_fn(|| urls.try_next().ok().flatten()).collect();
+ // app.ts `macOpenFiles`: AppKit sends the launch's documents before `applicationDidFinishLaunching:`; they take the
+ // startup window's place and open from the task, as effects deferred from this callback never run.
+ let launch_urls: Vec<Vec<String>> = std::iter::from_fn(|| urls.try_recv().ok()).collect();
let opens_documents = no_cli_paths && launch_urls.iter().flatten().any(|url| url.starts_with("file:"));
+ let restored = match restores {
+ true => last_session_windows(&app.user_data, !no_cli_paths, opens_documents),
+ false => Vec::new(),
+ };
+ let opens_startup = !opens_documents && (!no_cli_paths || restored.is_empty());
cx.spawn(async move |cx| {
let mut opened_urls = futures::StreamExt::chain(futures::stream::iter(launch_urls), urls);
while let Some(opened) = futures::StreamExt::next(&mut opened_urls).await {
+ let opened = workbench::url_handler::with_following_documents(opened, &mut opened_urls, cx).await;
cx.update(|cx| workbench::url_handler::open_system_urls(opened, cx));
}
})
.detach();
cx.set_global(user_data_profile::UserDataProfilesService::load(&app.user_data, &app.user_extensions_folder));
cx.set_global(app);
- if !opens_documents {
- for window in restored {
- let workspace = window.workspace.clone().or(window.folder.clone()).map(Workspace::open);
- open_window_or_log(WindowRequest { workspace, backup_folder: window.backup_path, ui: window.ui, ..WindowRequest::default() }, cx);
- }
- if let Some(startup) = startup
- && let Err(error) = open_window(startup, cx)
- {
- eprintln!("{error:#}");
- std::process::exit(1);
- }
+ for window in restored {
+ let workspace = window.workspace.clone().or(window.folder.clone()).map(Workspace::open);
+ open_window_or_log(WindowRequest { workspace, backup_folder: window.backup_path, ui: window.ui, ..WindowRequest::default() }, cx);
+ }
+ if opens_startup && let Err(error) = open_window(startup, cx) {
+ eprintln!("{error:#}");
+ std::process::exit(1);
}
// app.ts `resolveShellEnvironment(..., notifyOnError: true)` once the first window opened: to the focused one.
if let Some(message) = shell_env_error
@@ -874,6 +858,41 @@ fn icon_theme_follows_workbench_icon_theme() {
std::fs::remove_dir_all(&user_home).unwrap();
}
+/// windowsMainService.ts `getPathsToOpen` at startup: the last session's windows open for a start without paths, and
+/// next to the command line's paths or the documents Finder hands the app with `window.restoreWindows` `preserve`.
+fn last_session_windows(user_data: &Path, cli_paths: bool, opens_documents: bool) -> Vec<windows_state::WindowState> {
+ let user_settings = Settings::load(Registry::with_extensions(&[]), user_data.join("User"), None);
+ let setting = user_settings.get_value(Some("window.restoreWindows"), &Overrides::default()).and_then(|value| value.as_str().map(str::to_owned)).unwrap_or_else(|| "all".into());
+ if (cli_paths || opens_documents) && setting != "preserve" {
+ return Vec::new();
+ }
+ let restore_fullscreen = user_settings.get_value(Some("window.restoreFullscreen"), &Overrides::default()) == Some(json!(true));
+ let (last_active, opened) = windows_state::load(user_data);
+ let mut windows = windows_state::to_restore(&setting, last_active, opened);
+ // windowsStateHandler.ts `getNewWindowState`: fullscreen comes back only with `window.restoreFullscreen`.
+ for ui in windows.iter_mut().filter_map(|window| window.ui.as_mut()).filter(|ui| ui.mode == windows_state::FULLSCREEN && !restore_fullscreen) {
+ ui.mode = windows_state::NORMAL;
+ }
+ windows
+}
+
+#[test]
+fn a_finder_launch_restores_the_last_session_only_with_preserve() {
+ let user_data = std::env::temp_dir().join(format!("vsrustium-finder-launch-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&user_data);
+ std::fs::create_dir_all(user_data.join("User/globalStorage")).unwrap();
+ std::fs::create_dir_all(user_data.join("folder")).unwrap();
+ let folder = windows_state::WindowState { folder: Some(user_data.join("folder")), ..Default::default() };
+ windows_state::save(&user_data, Some(&folder), &[]);
+ let restored_with = |setting: &str| {
+ std::fs::write(user_data.join("User/settings.json"), format!(r#"{{ "window.restoreWindows": "{setting}" }}"#)).unwrap();
+ last_session_windows(&user_data, false, true)
+ };
+ assert_eq!(restored_with("preserve"), [folder]);
+ assert_eq!(restored_with("all"), []);
+ std::fs::remove_dir_all(&user_data).unwrap();
+}
+
/// windowsMainService.ts `open` with `addRecentlyOpened`: the window's folder or workspace and its file.
fn add_recently_opened<'a>(shared: &mut storage::Storage, workspace: Option<&Workspace>, files: impl Iterator<Item = &'a Path>) {
let mut opened = Vec::new();
diff --git a/native/crates/app/src/workbench/host.rs b/native/crates/app/src/workbench/host.rs
index 25550b98c96..fb43d910a38 100644
--- a/native/crates/app/src/workbench/host.rs
+++ b/native/crates/app/src/workbench/host.rs
@@ -219,8 +219,9 @@ impl Workbench {
/// comes to the front (the macOS default of `window.openWithoutArgumentsInNewWindow`), or an empty window opens with
/// `on` or `--new-window`. With paths, windowsMainService.ts `open`: `--add` folders join the last active window,
/// files open there (or in the first folder's window), folders and workspaces in new windows unless `--reuse-window`,
-/// `--wait` or `window.openFoldersInNewWindow` keep the first one in the last active window.
-pub(crate) fn start_open_window(args: Vec<String>, cwd: PathBuf, cx: &mut App) {
+/// `--wait` or `window.openFoldersInNewWindow` keep the first one in the last active window. `from_dock` is the
+/// `DOCK` context of Finder and the Dock, where files open in a new window too.
+pub(crate) fn start_open_window(args: Vec<String>, cwd: PathBuf, from_dock: bool, cx: &mut App) {
let parsed = match crate::argv::parse_and_validate(&args[1..]) {
Ok((parsed, _)) => parsed,
Err(error) => return eprintln!("[windows] {error}"),
@@ -257,7 +258,12 @@ pub(crate) fn start_open_window(args: Vec<String>, cwd: PathBuf, cx: &mut App) {
(_, _, Some(value)) if value == "on" || value == "off" => value == "on",
_ => !parsed.flag("wait"),
};
- let files_in_new_window = (new_window && !reuse_window) || (!reuse_window && setting("window.openFilesInNewWindow", cx).is_some_and(|value| value == "on"));
+ let files_in_new_window = match (new_window, reuse_window, setting("window.openFilesInNewWindow", cx)) {
+ (_, true, _) => false,
+ (true, _, _) => true,
+ (_, _, Some(value)) if value == "on" || value == "off" => value == "on",
+ _ => from_dock,
+ };
let mut files = Some(files).filter(|files| !files.is_empty() || files.wait_marker.is_some());
for (index, path) in workspaces.into_iter().enumerate() {
let reuse = index == 0 && !folder_in_new_window;
diff --git a/native/crates/app/src/workbench/url_handler.rs b/native/crates/app/src/workbench/url_handler.rs
index b20a83ea7e6..be8c12e2a8c 100644
--- a/native/crates/app/src/workbench/url_handler.rs
+++ b/native/crates/app/src/workbench/url_handler.rs
@@ -68,8 +68,22 @@ impl Workbench {
}
}
+/// app.ts `open-file`: Electron hands the documents one by one, so the ones that follow within 100 ms open together.
+pub(crate) async fn with_following_documents(mut urls: Vec<String>, following: &mut (impl futures::Stream<Item = Vec<String>> + Unpin), cx: &gpui::AsyncApp) -> Vec<String> {
+ if !urls.iter().any(|url| url.starts_with("file:")) {
+ return urls;
+ }
+ loop {
+ let timeout = cx.background_executor().timer(Duration::from_millis(100));
+ match futures::future::select(futures::StreamExt::next(following), timeout).await {
+ futures::future::Either::Left((Some(more), _)) => urls.extend(more),
+ _ => return urls,
+ }
+ }
+}
+
/// app.ts `open-file`: the documents Finder or the Dock hands the app open as the command line's paths would
-/// (`start_open_window`), any other url as `open-url`.
+/// (`start_open_window` in the `DOCK` context), any other url as `open-url`.
pub(crate) fn open_system_urls(urls: Vec<String>, cx: &mut gpui::App) {
let mut args = vec![String::new()];
for url in urls {
@@ -80,7 +94,7 @@ pub(crate) fn open_system_urls(urls: Vec<String>, cx: &mut gpui::App) {
}
}
if args.len() > 1 {
- super::host::start_open_window(args, PathBuf::from("/"), cx);
+ super::host::start_open_window(args, PathBuf::from("/"), true, cx);
}
}
@@ -319,6 +333,57 @@ mod tests {
std::fs::remove_dir_all(dir).unwrap();
}
+ /// windowsMainService.ts `shouldOpenNewWindow`: on macOS `window.openFilesInNewWindow` `default` opens the files of
+ /// the `DOCK` context in a new window, `off` (its default value) in the last active one.
+ #[gpui::test]
+ fn a_file_from_finder_opens_in_a_new_window_with_open_files_in_new_window_default(cx: &mut gpui::TestAppContext) {
+ let app_root = std::path::Path::new(env!("VSCODE_SRC")).to_path_buf();
+ let theme = crate::theme::load_theme(&[exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap()], "Dark Modern").unwrap();
+ let dir = std::env::temp_dir().join(format!("vsrustium-finder-file-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(dir.join("User")).unwrap();
+ let file = dir.join("notes.txt");
+ std::fs::write(&file, "one\n").unwrap();
+ let settings = std::sync::Arc::new(std::sync::Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), dir.join("User"), None)));
+ let (workbench, cx) = cx.add_window_view(|_, cx| Workbench::new(theme, app_root.clone(), None, crate::languages::Languages::new(&[]), settings, crate::host_sync::HostSync::new(std::sync::mpsc::channel().0), cx));
+ let open_from_finder = |cx: &mut gpui::VisualTestContext| {
+ cx.cx.update(|cx| open_system_urls(vec![format!("file://{}", file.display())], cx));
+ cx.run_until_parked();
+ };
+ workbench.update(cx, |workbench, _| workbench.update_setting("window.openFilesInNewWindow", json!("default")));
+ open_from_finder(cx);
+ assert_eq!(cx.cx.update(|cx| cx.windows().len()), 2, "a new window opens the file");
+ assert!(workbench.read_with(cx, |workbench, _| workbench.editors.active().is_none()));
+ workbench.update(cx, |workbench, _| workbench.update_setting("window.openFilesInNewWindow", json!("off")));
+ cx.cx.update(|cx| cx.windows().into_iter().find(|handle| handle.downcast::<Workbench>().is_some_and(|handle| handle.entity(cx).is_ok_and(|other| other != workbench))).unwrap().update(cx, |_, window, _| window.remove_window()).unwrap());
+ open_from_finder(cx);
+ assert_eq!(cx.cx.update(|cx| cx.windows().len()), 1);
+ assert_eq!(workbench.read_with(cx, |workbench, _| workbench.editors.active().map(|editor| editor.document().path.clone())), Some(file));
+ std::fs::remove_dir_all(dir).unwrap();
+ }
+
+ /// app.ts `open-file`: documents that follow within 100 ms open with the first; a later one on its own.
+ #[gpui::test]
+ fn documents_that_follow_within_100_ms_open_together(cx: &mut gpui::TestAppContext) {
+ let (sender, mut following) = futures::channel::mpsc::unbounded::<Vec<String>>();
+ sender.unbounded_send(vec!["file:///b".into()]).unwrap();
+ let burst = cx.spawn(|cx| async move {
+ let first = with_following_documents(vec!["file:///a".into()], &mut following, &cx).await;
+ let next = futures::StreamExt::next(&mut following).await.unwrap();
+ (first, next)
+ });
+ cx.run_until_parked();
+ cx.executor().advance_clock(Duration::from_millis(50));
+ sender.unbounded_send(vec!["file:///c".into()]).unwrap();
+ cx.run_until_parked();
+ cx.executor().advance_clock(Duration::from_millis(100));
+ cx.run_until_parked();
+ sender.unbounded_send(vec!["file:///d".into()]).unwrap();
+ let (first, next) = cx.foreground_executor().block_test(burst);
+ assert_eq!(first, ["file:///a", "file:///b", "file:///c"]);
+ assert_eq!(next, ["file:///d"]);
+ }
+
/// app.ts `handleProtocolUrl`: `windowId=_blank` opens the file in a new window (`forceNewWindow`), at its line.
#[gpui::test]
fn a_file_url_for_a_new_window_opens_the_file_there(cx: &mut gpui::TestAppContext) {
diff --git a/port/ledger.md b/port/ledger.md
index a9e8e28e921..67e6e057737 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -227,7 +227,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| platform/keyboardLayout | src/vs/platform | M9 | verified | | keyboard_layout.rs: layout info and raw mapping as native-keymap reads them, Developer: Inspect Key Mappings (JSON) (cargo test -p app keyboard_layout inspect_key_mappings; output byte-identical to native-keymap on the Studio); keyboard_mapper.rs MacLinuxKeyboardMapper: cargo test -p app keyboard_mapper (dumpDebugInfo byte-identical to mac_de_ch, mac_en_us, mac_zh_hant, mac_zh_hant2; the macOS resolve cases); Developer: Inspect Key Mappings with the installed scan-code mapper's tables as `_dumpDebugInfo` (cargo test -p app inspect_key_mappings_shows_the_scan_code_mapper_tables); the picker is web-only |
| platform/label | src/vs/platform | M12 | verified | | the ILabelService interface; the file scheme labels are workbench/services/label; verified at port-m12b-verify: cargo test -p app path_labels 2/2 |
| platform/languagePacks | src/vs/platform | M18 | verified | | languagepacks.json from `contributes.localizations`, `resolveLanguagePackLanguage`, manifest translations: cargo test -p exthost language_packs; with MS-CEINTL.vscode-language-pack-de installed and `--locale de` the Command Palette shows German titles (port/results/extensions.md) |
-| platform/launch | src/vs/platform | M11 | verified | | launch.rs (main.ts `claimInstance`, launchMainService.ts): the first instance listens on `<user data>/1.147.0-main.sock`; a later start with the same user data sends its arguments and working directory and exits once they are taken (a stale socket is removed); workbench/host.rs `start_open_window`: no paths brings the last active window to the front (`window.openWithoutArgumentsInNewWindow` default on macOS) or opens an empty window (`on`, `--new-window`), folders and workspaces open or focus their window, files open in the last active window; the `file://` urls Finder and the Dock hand the app (app.ts `open-file`, workbench/url_handler.rs `open_system_urls`) open the same way, at launch instead of the last session's windows (port/notes.md "Open from Finder"). The command line: argv.rs (argv.ts `OPTIONS`, minimist, `parseArgs`, `buildHelpMessage`, `buildVersionMessage`, argvHelper.ts `--goto` validation), cli.rs (code/node/cli.ts run by bin/code with `ELECTRON_RUN_AS_NODE`: `-` reads stdin into a 0600 `code-stdin-*` file, `--wait` creates the marker and waits until it is deleted, the app starts through `open -n -g` with `VSCODE_CWD`), workbench/command_line.rs (windowsMainService.ts and window.ts: `--diff`, `--merge`, `--add`, `--goto file:line:col`, `-n`/`-r`, a path that does not exist opens untitled and is created on save, a folder reuses the last active window and keeps its `--wait` marker, `--wait`'s marker deleted once each waited file has an editor closed (not moved) and none is dirty, checked each frame as `onDidChangeDirty`, or when the window closes). `cargo test -p app launch argv:: command_line:: a_workspace_file_from_finder` (url_handler::tests::a_workspace_file_from_finder_opens_a_window_of_its_folders; argv::tests::parses_the_command_line_as_upstream_argv, help_matches_upstream_text, goto_mode_validates_its_arguments; command_line::tests::goto_opens_the_file_at_its_line_and_column, diff_and_merge_open_their_editors, the_wait_marker_is_deleted_once_its_editors_close, the_wait_marker_is_deleted_when_one_of_two_editors_of_its_file_closes, the_wait_marker_waits_for_the_dirty_file_to_be_saved, the_wait_marker_is_deleted_when_the_window_closes, a_missing_file_opens_untitled_and_is_created_on_save); packaged app via a /usr/local/bin-style link to bin/code: `--version` and `--help` print, `--wait a.txt` waits until Cmd+W closes the editor, `echo text | vsrustium -` opens the stdin file, `--wait folder` loads the folder in the last active window and waits until that window closes; verified: ui-pair hot-exit.json `launched` vs the reference (port/results/windows.md, milestone 11 verification): a second start hands docs/guide.md to the running instance |
+| platform/launch | src/vs/platform | M11 | verified | | launch.rs (main.ts `claimInstance`, launchMainService.ts): the first instance listens on `<user data>/1.147.0-main.sock`; a later start with the same user data sends its arguments and working directory and exits once they are taken (a stale socket is removed); workbench/host.rs `start_open_window`: no paths brings the last active window to the front (`window.openWithoutArgumentsInNewWindow` default on macOS) or opens an empty window (`on`, `--new-window`), folders and workspaces open or focus their window, files open in the last active window; the `file://` urls Finder and the Dock hand the app (app.ts `open-file`, workbench/url_handler.rs `open_system_urls`) open the same way in the `DOCK` context: the ones that follow within 100 ms open together, files in a new window with `window.openFilesInNewWindow` `default`, and at launch they take the startup window's place, with the last session's windows only for `window.restoreWindows` `preserve` (main.rs `last_session_windows`). The command line: argv.rs (argv.ts `OPTIONS`, minimist, `parseArgs`, `buildHelpMessage`, `buildVersionMessage`, argvHelper.ts `--goto` validation), cli.rs (code/node/cli.ts run by bin/code with `ELECTRON_RUN_AS_NODE`: `-` reads stdin into a 0600 `code-stdin-*` file, `--wait` creates the marker and waits until it is deleted, the app starts through `open -n -g` with `VSCODE_CWD`), workbench/command_line.rs (windowsMainService.ts and window.ts: `--diff`, `--merge`, `--add`, `--goto file:line:col`, `-n`/`-r`, a path that does not exist opens untitled and is created on save, a folder reuses the last active window and keeps its `--wait` marker, `--wait`'s marker deleted once each waited file has an editor closed (not moved) and none is dirty, checked each frame as `onDidChangeDirty`, or when the window closes). `cargo test -p app launch argv:: command_line:: url_handler a_finder_launch` (url_handler::tests::a_workspace_file_from_finder_opens_a_window_of_its_folders, a_file_from_finder_opens_in_a_new_window_with_open_files_in_new_window_default, documents_that_follow_within_100_ms_open_together; a_finder_launch_restores_the_last_session_only_with_preserve; argv::tests::parses_the_command_line_as_upstream_argv, help_matches_upstream_text, goto_mode_validates_its_arguments; command_line::tests::goto_opens_the_file_at_its_line_and_column, diff_and_merge_open_their_editors, the_wait_marker_is_deleted_once_its_editors_close, the_wait_marker_is_deleted_when_one_of_two_editors_of_its_file_closes, the_wait_marker_waits_for_the_dirty_file_to_be_saved, the_wait_marker_is_deleted_when_the_window_closes, a_missing_file_opens_untitled_and_is_created_on_save); packaged app via a /usr/local/bin-style link to bin/code: `--version` and `--help` print, `--wait a.txt` waits until Cmd+W closes the editor, `echo text | vsrustium -` opens the stdin file, `--wait folder` loads the folder in the last active window and waits until that window closes; verified: ui-pair hot-exit.json `launched` vs the reference (port/results/windows.md, milestone 11 verification): a second start hands docs/guide.md to the running instance |
| platform/layout | src/vs/platform | M11 | verified | | `ILayoutService` as the workbench's part grid (workbench/layout.rs, part_grid.rs): container dimensions and part offsets of the main window; checks as workbench/services/layout (port/results/layout.md "Part positions", "Zen mode and centered layout") |
| platform/lifecycle | src/vs/platform | M11 | verified | | lifecycleMainService quit and window close through workbench/lifecycle.rs, menubar.ts confirmBeforeQuit; cargo test -p app lifecycle; verified: ui-pair hot-exit.json `dirty`, `restored` vs the reference (port/results/windows.md, milestone 11 verification) |
| platform/list | src/vs/platform | M9 | verified | | list scrolling, scrollbars, smooth scrolling, sensitivities, scrollByPage, horizontal scrolling, tree indent guides and sticky scroll, type navigation in the Explorer and Keyboard Shortcuts table, listCommands.ts on the Explorer, Search and the table (port/notes.md milestone 9): cargo test -p app menubar list_scroll list_tree type_navigation typing keybindings_editor_view search_actions explorer hover sticky, 135 passed, then list_scroll 5 passed (the_wheel_scrolls_after_a_key_press, scrolling_hides_the_rows_hover); ui-pair Explorer expand and 4 wheel notches: expand, guides, sticky row and its unselected look match the reference; the wheel scrolls the port 282px, the reference 304px (port/notes.md milestone 9 handoff); split_view.rs SplitView (proportional layout, distributeEmptySpace, sash drag with Alt for both sides, sash states) under the Keyboard Shortcuts table's column headers: sash cursors, 300ms hover border, double-click reset to the column weight, tree.tableColumnsBorder fading in on table hover (cargo test -p app split_view keybindings_editor_view; ui-pair drag and reset land on the reference's columns); listWidget and the other lists stay with their views |
diff --git a/port/notes.md b/port/notes.md
index a8d3cac457b..ca73f193e2d 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -948,7 +948,6 @@ Scope as in the M19 Work row of port/ledger.md.
- Windows (`main.rs` `AppState`, `WindowRequest`, `open_window`; `workbench/host.rs`): every window is a GPUI window of the one process with its own settings, storage, trust, extension host thread and workbench, as each reference window has its renderer and host. The menu bar runs its items in the active window, else the frontmost; with none, Quit quits and the other items open an empty window first; a Dock click without windows opens one (`app.on('activate')`). Closing the last window does not quit (macOS).
- Window state (`windows_state.rs`): `windowsState` in `User/globalStorage/storage.json`, the same key and shape as the reference (`lastActiveWindow`, `openedWindows`, `uiState` with `mode`, `display`, bounds). Display ids are the CGDirectDisplayID GPUI reports; bounds are points from the display's top left, so a window on a display that is gone opens centered.
- Launch (`launch.rs`): a Unix socket in the user data folder, one JSON line per second instance (`args`, `cwd`) answered with `ok` once taken. Tools that start the port with their own `--user-data-dir` get their own instance; a start from the checkout with the default `~/.vsrustium` hands its arguments to a running VSRustium.
-- Open from Finder (app.ts `open-file`, `macOpenFiles`; url_handler.rs `open_system_urls`): the files, folders and `.code-workspace` files Finder or the Dock hands the app arrive as `file://` urls through `application:openURLs:` and open through `start_open_window` as the command line's paths. At launch AppKit sends them before `applicationDidFinishLaunching:`, so main.rs drains them first and opens them instead of the last session's windows. Differences: no 100 ms batching (AppKit hands one call per open, Electron one event per path); with `window.openFilesInNewWindow: default` a file stays in the last active window, as from the command line, where upstream's `OpenContext.DOCK` opens a new one; with `window.restoreWindows: preserve` a launch from Finder does not restore the last session's windows.
- Inactive window (workbench.rs `title_bar`, `shell_background`; opener.rs re-renders on activation): `titleBar.inactiveBackground` and `inactiveForeground`, `commandCenter.inactiveBorder`, the title bar contents at 0.6 opacity (titlebarpart.css `.inactive > *`), and the modern UI shell in `modernUI.inactiveShellBackground`; both backgrounds are made opaque over WORKBENCH_BACKGROUND as titlebarPart.ts does.
- Open in this list, each waiting on another owner or a decision: `workbench/contrib/limitIndicator` needs the language status item (milestone 13); `workbench/contrib/modernUI` is drawn always on, while the classic look (`workbench.experimental.modernUI: false`) and the compact density (`window.density.layout`, Layout Density menu) change the part grid (main session). Window zoom (`window.zoomLevel`) is n/a by Artur's decision: GPUI has no window-wide scale outside its test build.
- Editor windows (`workbench/auxiliary_windows.rs`; auxiliaryEditorPart.ts, auxiliaryWindowService.ts, editorParts.ts, editorActions.ts): Move/Copy Editor and Editor Group into New Window (Command Palette, the tab menu's Move/Copy into New Window, View > Editor Layout), New Empty Editor Window, Restore Editors into Main Window. A part is a grid of groups in the workbench's `Editors`; `EditorGroups` holds the active group's part layout in its fields and parks the others' (`PartLayout`, `switch_part`, `in_part`), so the group commands act on the active part. `groups_in_grid_order` is every part's groups, main first. The window is a GPUI window whose root `AuxiliaryWindow` asks the workbench to draw the part (no card), the title bar (command center, Turn On/Off Always on Top, `titleBar.border`) and the part's editor status items. The window that turns active makes its part's most recent group the active one (editorParts.ts `activePart`); the overlays (quick input, menus, dialogs, hovers) draw in the active window; keys reach the workbench of the window they come from (the keystroke interceptor was app-wide: every workbench window took every window's keys). Closing the window (its button, Cmd+Shift+W, Close Group on its last group) moves the editors that would ask (dirty ones) to the main part's active group and closes the others; its last editor closed closes it; the main window takes its editor windows with it. `editorparts.state` (each part's grid and editors, bounds, part MRU) is saved on every editor change and restores at start when the main part restored its state. Compact mode (auxiliaryEditorPart.ts `updateCompact`; Toggle Window Compact Mode, the title's Turn On/Off Compact Mode): the part draws no tabs and no breadcrumbs, the window no status bar, the title bar the window title and a diff's Previous/Next Change (`MenuId.CompactWindowEditorTitle`); a split from it goes to the main part (`getAddGroupLocation`); a second group in the part, or another editor shown while its group has several, ends it; `compact` is stored with the window. Not ported: zoom per window. Tests: `cargo test -p app auxiliary_windows`; ui-pair port/results/auxiliary-windows.md.