@@ -73,7 +73,7 @@ import {
73
73
} from 'src/features/playground/PlaygroundActions' ;
74
74
75
75
import {
76
- defaultPlaygroundFilePath ,
76
+ getDefaultFilePath ,
77
77
InterpreterOutput ,
78
78
isSourceLanguage ,
79
79
OverallState ,
@@ -181,6 +181,7 @@ const keyMap = { goGreen: 'h u l k' };
181
181
export async function handleHash (
182
182
hash : string ,
183
183
props : PlaygroundProps ,
184
+ workspaceLocation : WorkspaceLocation ,
184
185
dispatch : Dispatch < AnyAction > ,
185
186
fileSystem : FSModule
186
187
) {
@@ -203,40 +204,43 @@ export async function handleHash(
203
204
// For backward compatibility with old share links - 'prgrm' is no longer used.
204
205
const program = qs . prgrm === undefined ? '' : decompressFromEncodedURIComponent ( qs . prgrm ) ;
205
206
206
- // By default, create just the default playground file.
207
+ // By default, create just the default file.
208
+ const defaultFilePath = getDefaultFilePath ( workspaceLocation ) ;
207
209
const files : Record < string , string > =
208
210
qs . files === undefined
209
211
? {
210
- [ defaultPlaygroundFilePath ] : program
212
+ [ defaultFilePath ] : program
211
213
}
212
214
: parseQuery ( decompressFromEncodedURIComponent ( qs . files ) ) ;
213
- await overwriteFilesInWorkspace ( 'playground' , fileSystem , files ) ;
215
+ await overwriteFilesInWorkspace ( workspaceLocation , fileSystem , files ) ;
214
216
215
217
// BrowserFS does not provide a way of listening to changes in the file system, which makes
216
218
// updating the file system view troublesome. To force the file system view to re-render
217
219
// (and thus display the updated file system), we first disable Folder mode.
218
- dispatch ( setFolderMode ( 'playground' , false ) ) ;
220
+ dispatch ( setFolderMode ( workspaceLocation , false ) ) ;
219
221
const isFolderModeEnabled = convertParamToBoolean ( qs . isFolder ) ?? false ;
220
222
// If Folder mode should be enabled, enabling it after disabling it earlier will cause the
221
223
// newly-added files to be shown. Note that this has to take place after the files are
222
224
// already added to the file system.
223
- dispatch ( setFolderMode ( 'playground' , isFolderModeEnabled ) ) ;
225
+ dispatch ( setFolderMode ( workspaceLocation , isFolderModeEnabled ) ) ;
224
226
225
227
// By default, open a single editor tab containing the default playground file.
226
228
const editorTabFilePaths = qs . tabs ?. split ( ',' ) . map ( decompressFromEncodedURIComponent ) ?? [
227
- defaultPlaygroundFilePath
229
+ defaultFilePath
228
230
] ;
229
231
// Remove all editor tabs before populating with the ones from the query string.
230
- dispatch ( removeEditorTabsForDirectory ( 'playground' , WORKSPACE_BASE_PATHS . playground ) ) ;
232
+ dispatch (
233
+ removeEditorTabsForDirectory ( workspaceLocation , WORKSPACE_BASE_PATHS [ workspaceLocation ] )
234
+ ) ;
231
235
// Add editor tabs from the query string.
232
236
editorTabFilePaths . forEach ( filePath =>
233
237
// Fall back on the empty string if the file contents do not exist.
234
- dispatch ( addEditorTab ( 'playground' , filePath , files [ filePath ] ?? '' ) )
238
+ dispatch ( addEditorTab ( workspaceLocation , filePath , files [ filePath ] ?? '' ) )
235
239
) ;
236
240
237
241
// By default, use the first editor tab.
238
242
const activeEditorTabIndex = convertParamToInt ( qs . tabIdx ) ?? 0 ;
239
- dispatch ( updateActiveEditorTabIndex ( 'playground' , activeEditorTabIndex ) ) ;
243
+ dispatch ( updateActiveEditorTabIndex ( workspaceLocation , activeEditorTabIndex ) ) ;
240
244
241
245
const variant : Variant =
242
246
sourceLanguages . find (
@@ -344,7 +348,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
344
348
return ;
345
349
}
346
350
if ( fileSystem !== null ) {
347
- handleHash ( hash , propsRef . current , dispatch , fileSystem ) ;
351
+ handleHash ( hash , propsRef . current , workspaceLocation , dispatch , fileSystem ) ;
348
352
}
349
353
} , [
350
354
dispatch ,
@@ -902,7 +906,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
902
906
const editorContainerProps : NormalEditorContainerProps = {
903
907
..._ . pick ( props , 'editorSessionId' , 'isEditorAutorun' ) ,
904
908
editorVariant : 'normal' ,
905
- baseFilePath : WORKSPACE_BASE_PATHS . playground ,
909
+ baseFilePath : WORKSPACE_BASE_PATHS [ workspaceLocation ] ,
906
910
isFolderModeEnabled,
907
911
activeEditorTabIndex,
908
912
setActiveEditorTabIndex,
@@ -977,7 +981,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
977
981
body : (
978
982
< FileSystemView
979
983
workspaceLocation = "playground"
980
- basePath = { WORKSPACE_BASE_PATHS . playground }
984
+ basePath = { WORKSPACE_BASE_PATHS [ workspaceLocation ] }
981
985
/>
982
986
) ,
983
987
iconName : IconNames . FOLDER_CLOSE ,
@@ -987,7 +991,7 @@ const Playground: React.FC<PlaygroundProps> = ({ workspaceLocation = 'playground
987
991
: [ ] )
988
992
]
989
993
} ;
990
- } , [ isFolderModeEnabled ] ) ;
994
+ } , [ isFolderModeEnabled , workspaceLocation ] ) ;
991
995
992
996
const workspaceProps : WorkspaceProps = {
993
997
controlBarProps : {
0 commit comments