@@ -121,18 +121,30 @@ export class ArchiveTreeProvider implements vscode.TreeDataProvider<ArchiveTreeI
121121
122122 try {
123123 const entries = await vscode . workspace . fs . readDirectory ( element . resourceUri ) ;
124- const isProjectRoot = element . contextValue === 'archiveRoot' ;
124+ const isProjectRoot = element . contextValue === 'archiveRoot' || element . contextValue === 'archiveProjectDir' || element . contextValue === 'archiveProjectDirActive' ;
125125
126- // Find the project root path for this element
127- let projectRootPath = element . resourceUri . fsPath ;
128- if ( ! isProjectRoot ) {
126+ // Find the workspace root path for hasMultipleMods
127+ let workspaceRootPath = element . resourceUri . fsPath ;
128+ if ( element . contextValue !== 'archiveRoot' ) {
129129 const matchedRoot = this . roots . find ( r => element . resourceUri . fsPath . startsWith ( r . fsPath ) ) ;
130130 if ( matchedRoot ) {
131- projectRootPath = matchedRoot . fsPath ;
131+ workspaceRootPath = matchedRoot . fsPath ;
132132 }
133133 }
134+
135+ // Find the project root for TKMM options
136+ let tkmmProjectRoot = element . resourceUri . fsPath ;
137+ if ( element . contextValue === 'tkmmOptionsRoot' ) {
138+ tkmmProjectRoot = path . dirname ( element . resourceUri . fsPath ) ;
139+ } else if ( element . contextValue === 'tkmmOptionGroup' ) {
140+ tkmmProjectRoot = path . dirname ( path . dirname ( element . resourceUri . fsPath ) ) ;
141+ } else if ( element . contextValue === 'tkmmOption' || element . contextValue === 'tkmmOptionActive' ) {
142+ tkmmProjectRoot = path . dirname ( path . dirname ( path . dirname ( element . resourceUri . fsPath ) ) ) ;
143+ } else if ( ! isProjectRoot ) {
144+ tkmmProjectRoot = workspaceRootPath ;
145+ }
134146
135- const activeTkmmOption = getActiveTkmmOption ( this . context , projectRootPath ) ;
147+ const activeTkmmOption = getActiveTkmmOption ( this . context , tkmmProjectRoot ) ;
136148
137149 const children = await Promise . all ( entries
138150 . sort ( compareEntriesFoldersFirstKeepingArchivesMixed )
@@ -147,7 +159,7 @@ export class ArchiveTreeProvider implements vscode.TreeDataProvider<ArchiveTreeI
147159 contextValue = 'tkmmOptionGroup' ;
148160 } else if ( element . contextValue === 'tkmmOptionGroup' && isDirectory ) {
149161 contextValue = 'tkmmOption' ;
150- } else if ( isDirectory && this . hasMultipleMods . has ( projectRootPath ) && contextValue === 'archiveDir' ) {
162+ } else if ( isDirectory && this . hasMultipleMods . has ( workspaceRootPath ) && contextValue === 'archiveDir' ) {
151163 // Check if this directory is a valid mod folder (has romfs/exefs/.tkproj)
152164 let isModFolder = false ;
153165 try {
@@ -163,7 +175,7 @@ export class ArchiveTreeProvider implements vscode.TreeDataProvider<ArchiveTreeI
163175 // Ignore
164176 }
165177 if ( isModFolder ) {
166- const currentLogicalRoot = this . logicalRoots . get ( projectRootPath ) ;
178+ const currentLogicalRoot = this . logicalRoots . get ( workspaceRootPath ) ;
167179 if ( currentLogicalRoot && currentLogicalRoot === childUri . fsPath ) {
168180 contextValue = 'archiveProjectDirActive' ;
169181 } else {
0 commit comments