4EverM
4 September 2023 20:21
#1
By default, the theia open workspace dialog provide “.theia-workspace" and " .code-workspace” file format.
I want to add my custom workspace file format like “*.custom-workspace”, but i can’t find any code about that. Can someone give me some guidance? Thanks a lot.
msujew
5 September 2023 07:14
#2
Hey @4EverM ,
you can customize your workspace file extension in the WorkspaceFileService .
4EverM
6 September 2023 09:21
#3
I have cheked the code of WorkspaceFileService and extend the WorkspaceFileService
and export CustomWorkspaceFileService
.
Here are some of my attempts.
/// hello-world/src/common/custom-workspace-file-service.ts
import {injectable} from "@theia/core/shared/inversify";
import {THEIA_EXT, VSCODE_EXT, WorkspaceFileService, WorkspaceFileType} from "@theia/workspace/lib/common/workspace-file-service"
export const CUSTOM_EXT = "custom-workspace";
@injectable()
export class CustomWorkspaceFileService extends WorkspaceFileService {
getWorkspaceFileTypes(): WorkspaceFileType[] {
return [
{
name: 'Theia',
extension: THEIA_EXT
},
{
name: 'Visual Studio Code',
extension: VSCODE_EXT
},
{
name: 'Custom',
extension: CUSTOM_EXT
}
];
}
}
But, i don’t know what the next step is ? Can you type some sample code?
msujew
6 September 2023 09:51
#4
All you need to do now is to rebind the service in your frontend application module:
rebind(WorkspaceFileService).to(CustomWorkspaceFileService).inSingletonScope();