Skip to content

Visual Studio Code, rebuilt in Rust

Rust

fix(views): key a moved view's hidden state by its current container

rokartur9074c37668ec
diff --git a/native/crates/app/src/workbench/view_locations.rs b/native/crates/app/src/workbench/view_locations.rs
index 84be169f43b..80ff60407ac 100644
--- a/native/crates/app/src/workbench/view_locations.rs
+++ b/native/crates/app/src/workbench/view_locations.rs
@@ -532,17 +532,18 @@ impl Workbench {
/// `visibleViewDescriptors`: a panel view whose `when` does not hold (Test Results without results) is left out.
pub(super) fn movable_view_shown(&self, view: &MovableView) -> bool {
let has_folder = self.folder.as_ref().is_some_and(|tree| !tree.workspace.folders.is_empty());
+ // viewContainerModel.ts: a view's hidden state is in the state of the container it is in now.
+ let container = pane_container(self.view_container(view)).key();
match view.id {
FILE_VIEW => has_folder,
EMPTY_VIEW => !has_folder,
- // shortcut: their hidden state stays under the Explorer's key after a move, upstream keys it by the container.
- OPEN_EDITORS_VIEW | OUTLINE_VIEW | TIMELINE_VIEW => !self.view_hidden("explorer", view.id),
+ OPEN_EDITORS_VIEW | OUTLINE_VIEW | TIMELINE_VIEW => !self.view_hidden(container, view.id),
SCM_HISTORY_VIEW => self.active_scm_provider().is_some_and(|provider| provider.has_history_provider),
- SCM_REPOSITORIES_VIEW => !self.scm.model.providers.is_empty() && !self.view_hidden("scm", view.id),
+ SCM_REPOSITORIES_VIEW => !self.scm.model.providers.is_empty() && !self.view_hidden(container, view.id),
VARIABLES_VIEW | WATCH_VIEW | CALL_STACK_VIEW | LOADED_SCRIPTS_VIEW | BREAKPOINTS_VIEW => self.debug_views().iter().any(|(id, _)| *id == view.id),
id => match (self.panel.views.iter().find(|panel_view| panel_view.view_id == id), self.tree_views.views.iter().find(|tree_view| tree_view.id == id)) {
(Some(panel_view), _) => (panel_view.visible)(self),
- (None, Some(tree_view)) => self.shown_views_of(&tree_view.container).contains(&id),
+ (None, Some(tree_view)) => tree_view.when.as_ref().is_none_or(|when| when.evaluate(&self.context_keys)) && !self.view_hidden(container, id),
(None, None) => true,
},
}
diff --git a/native/crates/app/src/workbench/view_locations/tests.rs b/native/crates/app/src/workbench/view_locations/tests.rs
index 93c38349334..3271b2ace60 100644
--- a/native/crates/app/src/workbench/view_locations/tests.rs
+++ b/native/crates/app/src/workbench/view_locations/tests.rs
@@ -224,6 +224,28 @@ fn outline_moved_into_problems_lies_beside_it_in_the_bottom_panel(cx: &mut TestA
workbench.update(cx, |workbench, cx| workbench.hide_panel(cx));
}
+#[gpui::test]
+fn a_moved_view_is_hidden_by_the_state_of_the_container_it_is_in(cx: &mut TestAppContext) {
+ let profile = Arc::new(Mutex::new(Storage::in_memory()));
+ let (workbench, cx) = open(profile.clone(), cx);
+ let shown = |workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.movable_view_shown(&workbench.movable_view(OUTLINE_VIEW).unwrap()));
+ workbench.update(cx, |workbench, cx| {
+ workbench.toggle_view_visibility("explorer", OUTLINE_VIEW, cx);
+ workbench.move_view_to_container(OUTLINE_VIEW, SCM_CONTAINER, cx);
+ });
+ // viewContainerModel.ts `add`: Source Control has no state for Outline, which is not `hideByDefault`.
+ assert!(shown(&workbench, cx));
+ workbench.update(cx, |workbench, cx| workbench.toggle_view_visibility("scm", OUTLINE_VIEW, cx));
+ assert!(!shown(&workbench, cx));
+
+ workbench.update(cx, |workbench, cx| {
+ workbench.move_view_to_container(OUTLINE_VIEW, MARKERS_CONTAINER_ID, cx);
+ workbench.toggle_view_visibility(pane_container(MARKERS_CONTAINER_ID).key(), OUTLINE_VIEW, cx);
+ });
+ assert!(!shown(&workbench, cx));
+ assert!(profile.lock().unwrap().get("workbench.panel.markers.hidden").is_some());
+}
+
#[gpui::test]
fn a_header_dropped_on_another_container_takes_the_drop_position(cx: &mut TestAppContext) {
let profile = Arc::new(Mutex::new(Storage::in_memory()));
diff --git a/native/crates/app/src/workbench/view_visibility.rs b/native/crates/app/src/workbench/view_visibility.rs
index 84e53dd3a08..d26f2b0bbec 100644
--- a/native/crates/app/src/workbench/view_visibility.rs
+++ b/native/crates/app/src/workbench/view_visibility.rs
@@ -33,6 +33,10 @@ pub(super) fn container_storage_id(container: &str) -> String {
"test" => "workbench.view.extension.test.state".into(),
super::extensions_view::VIEWLET_ID => format!("{}.state", super::extensions_view::VIEWLET_ID),
generated if super::view_locations::is_generated_container(generated) => format!("{generated}.state"),
+ // The panel containers' `storageId`s (markers.contribution.ts, output.contribution.ts, ...).
+ super::problems_view::MARKERS_CONTAINER_ID | super::output_view::OUTPUT_VIEW_ID | super::terminal_view::TERMINAL_VIEW_ID | super::debug_console::DEBUG_PANEL_ID | super::refactor_preview::REFACTOR_PREVIEW_ID => container.into(),
+ super::comments_view::COMMENTS_VIEW_ID => "Comments".into(),
+ super::testing_view::TEST_RESULTS_VIEW_ID => format!("{}.state", super::testing_view::TEST_RESULTS_VIEW_ID),
other => format!("workbench.view.extension.{other}.state"),
}
}
diff --git a/port/ledger.md b/port/ledger.md
index 48b63a426a1..c2ce430cf7d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -456,7 +456,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/services/userDataProfile | workbench service | M10 | verified | | one app-wide `UserDataProfilesService` (a gpui Global in app/src/user_data_profile.rs) for every window of the process: profile windows open in this process, a transient profile lives while a window runs it (userDataProfilesHandler.ts cleanup on close), and `onDidChangeProfiles` reaches every window (cargo test -p app workbench::user_data_profile: profile_windows_open_in_this_process, every_window_sees_a_profile_another_window_creates_and_removes); userDataProfileManagement.ts `switchProfile`, `removeProfile` and `changeCurrentProfile` (configuration, keybindings, global state and user extensions move to the profile's files, the extension host restarts, workbench/extension_host_restart.rs) in workbench/user_data_profile.rs; the configuration layers of a profile (`ApplicationConfiguration`, PROFILE_SCOPES, `workbench.settings.applyToAllProfiles`) with configurationService.test.ts's Profiles suite (cargo test -p config profile_tests); the settings, keybindings, tasks, snippets, globalState and extensions resources and the `.code-profile` template of userDataProfileImportExportService.ts as app/src/profile_template.rs (cargo test -p app profile_template); a template's extensions install the way extensionsResource.ts `apply` does, one publisher trust dialog for all of them and an error naming the ones that failed (cargo test -p app template_extensions_ask_for_publisher_trust_once); per-profile extensions.json (cargo test -p exthost extension_management); `createTroubleshootProfile` is removed with contrib/issue, its only caller (issueTroubleshoot.ts); profile templates from `profileTemplatesUrl` have no source, the product.json has none |
| workbench/services/userDataSync | workbench service | | removed | | no sign-in/AI by decision (port/notes.md); not ported |
| workbench/services/utilityProcess | workbench service | | verified | | no utility process workers: the file watcher worker, the one kept client, is files/src/watcher.rs on an FSEvents thread (platform/files; api-tests `vscode API - workspace-watcher` passes in the milestone 20 whole-suite run); localTranscription is AI, removed (port/notes.md milestone 20) |
-| workbench/services/views | workbench service | M11 | ported | [3 S] view_locations.rs:538: a moved view's hidden state stays under the Explorer's key, upstream keys it by its container <br> [3 S] view_containers.rs:92: an extension container's "View: Show <title>" (viewsService.ts `registerOpenViewContainerAction`, f1) is not in the Command Palette <br> [3 M] view_containers.rs:5: `viewsContainers.panel`: an extension's panel container gets no panel tab and its views do not draw | view containers of `viewsContainers.activitybar` and the tree views of every container (workbench/view_containers.rs): activity bar items while a view's `when` holds, `workbench.view.extension.<id>`, `<view id>.focus`, `<view id>.active`, merged single views, view_panes.rs panes for the views of an extension container and of Testing (`PaneContainer::Contributed`: cargo test -p app view_containers::; ui-pair port/fixtures/ui-pair/contributed-panes.json with port/fixtures/extensions/contributed-panes, the Port Panes and Testing side bars as the reference), treeView.ts `noDataProviderMessage` (cargo test -p app tree_view::), contributed views of scm and debug as panes of those containers; the Explorer's ViewDescriptorsState (view_panes.rs); ui-pair port/results/references-view.md; `visibility` (`hidden` views stay out until the Views submenu of the Explorer's "..." shows them, `collapsed`; workbench/view_visibility.rs: cargo test -p app view_visibility); the Explorer container's ViewDescriptorsState (view_panes.rs); moving views (workbench/view_locations.rs, verified): `views.customizations` viewLocations and generated containers `workbench.views.service.<location>.<uuid>` with their activity bar items and panel tabs, View: Move View, Move Focused View, Reset Focused View Location, a view header dropped on another container's pane (at its position), on the activity bar or on a panel's title (a new entry), `focusedView`; the folder view, Open Editors, Outline, Timeline, Source Control's Changes, Search, the debug views and the panel's views move into any built-in container or a new entry and back, the moved view opens focused, the picker lists only visible views (shortcut in view_locations.rs: a moved view's hidden state stays under its old container's key); cargo test -p app (2594 passed); ui-pair port/fixtures/ui-pair/m11/move-view.json, port/results/move-view.md (8 steps match, Ports removed by decision); verified: ui-pair port/results/references-view.md (milestone 11 verification) |
+| workbench/services/views | workbench service | M11 | ported | [3 S] view_containers.rs:92: an extension container's "View: Show <title>" (viewsService.ts `registerOpenViewContainerAction`, f1) is not in the Command Palette <br> [3 M] view_containers.rs:5: `viewsContainers.panel`: an extension's panel container gets no panel tab and its views do not draw | view containers of `viewsContainers.activitybar` and the tree views of every container (workbench/view_containers.rs): activity bar items while a view's `when` holds, `workbench.view.extension.<id>`, `<view id>.focus`, `<view id>.active`, merged single views, view_panes.rs panes for the views of an extension container and of Testing (`PaneContainer::Contributed`: cargo test -p app view_containers::; ui-pair port/fixtures/ui-pair/contributed-panes.json with port/fixtures/extensions/contributed-panes, the Port Panes and Testing side bars as the reference), treeView.ts `noDataProviderMessage` (cargo test -p app tree_view::), contributed views of scm and debug as panes of those containers; the Explorer's ViewDescriptorsState (view_panes.rs); ui-pair port/results/references-view.md; `visibility` (`hidden` views stay out until the Views submenu of the Explorer's "..." shows them, `collapsed`; workbench/view_visibility.rs: cargo test -p app view_visibility); the Explorer container's ViewDescriptorsState (view_panes.rs); moving views (workbench/view_locations.rs, verified): `views.customizations` viewLocations and generated containers `workbench.views.service.<location>.<uuid>` with their activity bar items and panel tabs, View: Move View, Move Focused View, Reset Focused View Location, a view header dropped on another container's pane (at its position), on the activity bar or on a panel's title (a new entry), `focusedView`; the folder view, Open Editors, Outline, Timeline, Source Control's Changes, Search, the debug views and the panel's views move into any built-in container or a new entry and back, the moved view opens focused, the picker lists only visible views, a moved view's hidden state is in its current container's state (cargo test -p app a_moved_view_is_hidden); cargo test -p app (2594 passed); ui-pair port/fixtures/ui-pair/m11/move-view.json, port/results/move-view.md (8 steps match, Ports removed by decision); verified: ui-pair port/results/references-view.md (milestone 11 verification) |
| workbench/services/workingCopy | workbench service | M8 | verified | | the text file and untitled working copies are the editor models (dirty state, save, revert, the window's edited dot of `onDidChangeDirty`): cargo test -p app untitled (30), lifecycle (3); WorkingCopyFileService create, move, copy, delete with participants: cargo test -p files operations (12); WorkingCopyHistoryService and its tracker for saves into User/History, entries following renames and folder moves (`moveEntries`): cargo test -p app local_history (10); WorkingCopyBackupService and the backup tracker with hot exit (backups.rs, workbench/backup_tracker.rs), a backup of a deleted file restoring as an orphaned model (`doResolveFromBackup`), modified scratchpads backing up: cargo test -p app backup (19); the working copies of editable custom documents (MainThreadCustomEditorModel, workbench/custom_documents.rs: `$onDidEdit` edits for undo and redo with `$disposeEdits`, `$onContentChange`, dirty tabs, `$onSave`, Save As with `$onSaveAs` and the editor moved to the target, `$revert`, `$backup` into a `vscode-custom-editor` backup restored with its backup id): cargo test -p app custom_documents (3), and port/fixtures/extensions/custom-document-tests (FIXTURE=custom-document-tests port/tools/webview-check: 4/4 in the reference and 4/4 in the port). Notebook working copies are the contrib/notebook row's; their backups are typed (`hashIdentifier` with a type id, backups.rs: cargo test -p app backups::, the upstream typed hashes) and the shutdown joins backups still being written |
| workbench/services/workspaces | workbench service | M12 | ported | [3 L] workspace_editing.rs:243, :379: enterWorkspace reopens the window where upstream switches in place (L); the Remove Folder picker has no ROOT_FOLDER icons (S) | workspace_trust.rs: WorkspaceTrustManagementService (uriTrustInfo in shared storage, longest trusted parent, empty window memento, parent folder trust) and WorkspaceTrustRequestService: cargo test -p app workspace_trust; workbench/workspace_editing.rs: abstractWorkspaceEditingService.ts addFolders, removeFolders, updateFolders, saveAndEnterWorkspace, enterWorkspace (shortcut in port/notes.md: the window reopens in place), duplicate workspace: cargo test -p app folders_added_and_removed_in_a_workspace_reach_its_file_the_explorer_settings_and_host workspace_editing; ui-pair port/fixtures/ui-pair/m12/workspace-folders.json, verified at port-m12b-verify |
| workbench/contrib/accessibility | workbench contribution | M19 | verified | | workbench/accessible_view.rs and workbench/accessibility.rs: accessible view and accessibility help (Alt+F2, Alt+F1 with the editor, hover, view help providers, the hover's and a workbench hover's accessible view, Escape from the latter focusing the hover again, a focused contributed tree or webview view's `accessibilityHelpContent`, a webview view the `focusedView` while its webview has the keyboard; Alt+F6, Alt+H, Alt+K, Alt+A, Alt+]/[), notification aria labels with the verbosity hint, unfocused editor dimming, Toggle Screen Reader Accessibility Mode, status entry; cargo test -p app accessib (alt_f1_shows_the_editor_help..., alt_f1_in_a_contributed_view..., alt_f1_in_a_webview_view..., dimming), cargo test -p app content_hover (the hover's accessible view), port/tools/a11y-check reads the help text area (port/notes.md milestone 19) |