File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,11 +24,27 @@ export function duplicate_workspace_command(
2424 vscode . workspace . workspaceFolders ?. map ( ( folder ) => folder . uri . fsPath ) ??
2525 [ ]
2626
27+ const open_editors : { path : string ; view_column ?: number } [ ] = [ ]
28+ for ( const tab_group of vscode . window . tabGroups . all ) {
29+ for ( const tab of tab_group . tabs ) {
30+ if (
31+ tab . input instanceof vscode . TabInputText &&
32+ tab . input . uri . scheme == 'file'
33+ ) {
34+ open_editors . push ( {
35+ path : tab . input . uri . fsPath ,
36+ view_column : tab_group . viewColumn
37+ } )
38+ }
39+ }
40+ }
41+
2742 const context_to_save : DuplicateWorkspaceContext = {
2843 checked_files,
2944 checked_websites,
3045 workspace_root_folders,
31- timestamp : Date . now ( )
46+ timestamp : Date . now ( ) ,
47+ open_editors
3248 }
3349
3450 const api_edit_format = context . workspaceState . get (
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ export type DuplicateWorkspaceContext = {
7777 checked_websites : string [ ]
7878 timestamp : number
7979 workspace_root_folders : string [ ]
80+ open_editors ?: { path : string ; view_column ?: number } [ ]
8081}
8182
8283export type HistoryEntry = {
Original file line number Diff line number Diff line change @@ -61,6 +61,23 @@ const restore_duplicated_workspace_context = async (
6161 CONTEXT_CHECKED_URLS_STATE_KEY ,
6262 duplicated_context . checked_websites
6363 )
64+ if ( duplicated_context . open_editors ) {
65+ for ( const editor_info of duplicated_context . open_editors ) {
66+ try {
67+ const uri = vscode . Uri . file ( editor_info . path )
68+ const document = await vscode . workspace . openTextDocument ( uri )
69+ await vscode . window . showTextDocument ( document , {
70+ viewColumn : editor_info . view_column ,
71+ preview : false
72+ } )
73+ } catch ( error ) {
74+ console . error (
75+ `Failed to restore open editor for ${ editor_info . path } :` ,
76+ error
77+ )
78+ }
79+ }
80+ }
6481 }
6582 }
6683
You can’t perform that action at this time.
0 commit comments