Skip to content

Commit 798fab6

Browse files
committed
Refactor file synchronization logic to ensure the Workspace view correctly preserves checked files that are not currently open in the editor when the Open Editors view triggers a state change
1 parent 7ad0267 commit 798fab6

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

‎packages/vscode/src/context/providers/open-editors-provider.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@ export class OpenEditorsProvider
382382
}
383383
}
384384

385-
// Force a complete tree refresh by clearing the file token count cache
386-
this._file_token_counts.clear()
387-
388385
// Fire the event with undefined to force full tree refresh
389386
this._on_did_change_tree_data.fire(undefined)
390387

‎packages/vscode/src/context/shared-file-state.ts‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,22 @@ export class SharedFileState {
9797
}
9898
}
9999
} else if (this.synchronizing_provider === 'openEditors') {
100-
for (const file of open_editors_checked_files) {
101-
if (!workspace_checked_files.includes(file)) {
102-
await this.update_file_check_state_in_workspace(file, true)
103-
this.unchecked_in_workspace.delete(file)
104-
}
105-
}
106-
107-
for (const file of open_editor_paths) {
108-
if (
109-
!open_editors_checked_files.includes(file) &&
110-
workspace_checked_files.includes(file)
111-
) {
112-
await this.update_file_check_state_in_workspace(file, false)
113-
this.unchecked_in_workspace.add(file)
114-
}
115-
}
100+
const open_editor_paths_set = new Set(open_editor_paths)
101+
102+
// Preserve checked state for files that are not open in editors
103+
const preserved_workspace_checked_files = workspace_checked_files.filter(
104+
(file) => !open_editor_paths_set.has(file)
105+
)
106+
107+
// Combine with checked files from open editors
108+
const new_workspace_checked_files = [
109+
...preserved_workspace_checked_files,
110+
...open_editors_checked_files
111+
]
112+
113+
await this.workspace_provider.set_checked_files(
114+
new_workspace_checked_files
115+
)
116116
}
117117
// If no specific provider triggered the sync, do a full sync
118118
else {

0 commit comments

Comments
 (0)