@@ -58,6 +58,7 @@ import {
5858 OtherStudioAction ,
5959 contextSourceControlMenu ,
6060 mainSourceControlMenu ,
61+ StudioActions ,
6162} from "./commands/studio" ;
6263import { addServerNamespaceToWorkspace , pickServerAndNamespace } from "./commands/addServerNamespaceToWorkspace" ;
6364import { jumpToTagAndOffset , openErrorLocation } from "./commands/jumpToTagAndOffset" ;
@@ -153,6 +154,7 @@ import {
153154} from "./utils/documentIndex" ;
154155import { WorkspaceNode , NodeBase } from "./explorer/nodes" ;
155156import { showPlanWebview } from "./commands/showPlanPanel" ;
157+ import { isfsConfig } from "./utils/FileProviderUtil" ;
156158
157159const packageJson = vscode . extensions . getExtension ( extensionId ) . packageJSON ;
158160const extensionVersion = packageJson . version ;
@@ -708,6 +710,25 @@ async function systemModeWarning(wsFolders: readonly vscode.WorkspaceFolder[]):
708710 }
709711}
710712
713+ /**
714+ * Fire the `OpenedDocument` UserAction for any workspace folders
715+ * that are showing the contents of a server-side project.
716+ * This must be done because technically a project is a "document".
717+ */
718+ async function fireOpenProjectUserAction ( wsFolders : readonly vscode . WorkspaceFolder [ ] ) : Promise < void > {
719+ if ( ! wsFolders || wsFolders . length == 0 ) return ;
720+ for ( const wsFolder of wsFolders ) {
721+ if ( notIsfs ( wsFolder . uri ) ) return ;
722+ const { project } = isfsConfig ( wsFolder . uri ) ;
723+ if ( ! project ) return ;
724+ const api = new AtelierAPI ( wsFolder . uri ) ;
725+ if ( ! api . active ) return ;
726+ new StudioActions ( ) . fireProjectUserAction ( api , project , OtherStudioAction . OpenedDocument ) . catch ( ( ) => {
727+ // Swallow error because showing it is more disruptive than using a potentially outdated project definition
728+ } ) ;
729+ }
730+ }
731+
711732/**
712733 * Set when clause context keys so the ObjectScript Explorer and
713734 * Projects Explorer views are correctly shown or hidden depending
@@ -941,6 +962,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
941962 // Warn about SystemMode
942963 systemModeWarning ( vscode . workspace . workspaceFolders ) ;
943964
965+ // Fire OpenedDocument UserAction for folders showing the contents of a server-side project
966+ fireOpenProjectUserAction ( vscode . workspace . workspaceFolders ) ;
967+
944968 iscIcon = vscode . Uri . joinPath ( context . extensionUri , "images" , "fileIcon.svg" ) ;
945969
946970 // Index documents in all local workspace folders
@@ -1531,6 +1555,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
15311555 for ( const r of e . removed ) removeIndexOfWorkspaceFolder ( r ) ;
15321556 // Show or hide explorer views as needed
15331557 setExplorerContextKeys ( ) ;
1558+ // Fire OpenedDocument UserAction for added folders showing the contents of a server-side project
1559+ fireOpenProjectUserAction ( e . added ) ;
15341560 } ) ,
15351561 vscode . commands . registerCommand ( "vscode-objectscript.importXMLFiles" , importXMLFiles ) ,
15361562 vscode . commands . registerCommand ( "vscode-objectscript.exportToXMLFile" , exportDocumentsToXMLFile ) ,
0 commit comments