@@ -23,6 +23,10 @@ internal class VSCodeWorkspace
2323 public VSCodeInstance Instance ;
2424 public string Path ;
2525 public VSCodeWorkspaceType VSCodeWorkspaceType ;
26+ public string WorkspaceName = "" ;
27+ public string VSTypeString = "" ;
28+ public string WorkspaceTypeString = "" ;
29+ public DetailsElement [ ] Details = [ ] ;
2630
2731 /// <summary>
2832 /// Initializes a new instance of the <see cref="VSCodeWorkspace"/> class.
@@ -34,72 +38,76 @@ public VSCodeWorkspace(VSCodeInstance instance, string path, VSCodeWorkspaceType
3438 this . Path = path ;
3539 this . Instance = instance ;
3640 this . VSCodeWorkspaceType = vsCodeWorkspaceType ;
41+
42+ SetName ( ) ;
43+ SetVSType ( ) ;
44+ SetWorkspaceType ( ) ;
45+ SetMetadata ( ) ;
3746 }
3847
3948 /// <summary>
40- /// Gets the name of the workspace.
49+ /// Sets the name of the workspace.
4150 /// </summary>
4251 /// <returns>The name of the workspace.</returns>
43- public string GetName ( )
52+ public void SetName ( )
4453 {
45- string workspaceName = "" ;
54+ WorkspaceName = "" ;
4655
4756 // split name by / and get last part
4857 var nameParts = Uri . UnescapeDataString ( Path ) . Split ( '/' ) ;
4958 if ( nameParts . Length == 0 )
5059 {
51- return workspaceName ;
60+ return ;
5261 }
5362
54- workspaceName = nameParts [ nameParts . Length - 1 ] ;
63+ WorkspaceName = nameParts [ nameParts . Length - 1 ] ;
5564
5665 if ( VSCodeWorkspaceType == VSCodeWorkspaceType . Workspace )
5766 {
5867 // remove .code-workspace
59- workspaceName = workspaceName . Replace ( ".code-workspace" , "" ) ;
68+ WorkspaceName = WorkspaceName . Replace ( ".code-workspace" , "" ) ;
6069
6170 // if the workspace name is "workspace", use the folder name instead
62- if ( workspaceName == "workspace" && nameParts . Length >= 2 )
71+ if ( WorkspaceName == "workspace" && nameParts . Length >= 2 )
6372 {
64- workspaceName = nameParts [ nameParts . Length - 2 ] ;
73+ WorkspaceName = nameParts [ nameParts . Length - 2 ] ;
6574 }
6675 }
67-
68- return workspaceName ;
6976 }
7077
7178 /// <summary>
7279 /// Determines the type of the workspace (e.g., Local, WSL, Remote).
7380 /// </summary>
7481 /// <returns>The type of the workspace as a string.</returns>
75- public string GetVSType ( )
82+ public void SetVSType ( )
7683 {
7784 if ( Path . StartsWith ( "vscode-remote://wsl" , System . StringComparison . OrdinalIgnoreCase ) )
7885 {
79- return "WSL" ;
86+ VSTypeString = "WSL" ;
8087 }
8188 else if ( Path . StartsWith ( "vscode-remote://" , System . StringComparison . OrdinalIgnoreCase ) )
8289 {
83- return "Remote" ;
90+ VSTypeString = "Remote" ;
8491 }
85-
86- return "" ;
8792 }
8893
8994 /// <summary>
90- /// Gets the workspace type (e.g., Workspace, Folder).
95+ /// Sets the workspace type (e.g., Workspace, Folder).
9196 /// </summary>
9297 /// <returns>The type of the workspace as a string.</returns>
93- public string GetWorkspaceType ( )
98+ public void SetWorkspaceType ( )
9499 {
95100 switch ( VSCodeWorkspaceType )
96101 {
97102 case VSCodeWorkspaceType . Workspace :
98- return "Workspace" ;
103+ WorkspaceTypeString = "Workspace" ;
104+ break ;
99105 case VSCodeWorkspaceType . Folder :
100- return "Folder" ;
106+ WorkspaceTypeString = "Folder" ;
107+ break ;
101108 default :
102- return "Unknown Type" ;
109+ WorkspaceTypeString = "Unknown Type" ;
110+ break ;
103111 }
104112 }
105113
@@ -108,15 +116,15 @@ public string GetWorkspaceType()
108116 /// Gets the details of the workspace.
109117 /// </summary>
110118 /// <returns>An array of details elements containing information about the workspace.</returns>
111- public DetailsElement [ ] GetMetadata ( )
119+ public void SetMetadata ( )
112120 {
113- var typeTags = new List < Tag > ( ) { new Tag ( GetWorkspaceType ( ) ) } ;
114- if ( GetVSType ( ) != "" )
121+ var typeTags = new List < Tag > ( ) { new Tag ( WorkspaceTypeString ) } ;
122+ if ( VSTypeString != "" )
115123 {
116- typeTags . Add ( new Tag ( GetVSType ( ) ) ) ;
124+ typeTags . Add ( new Tag ( VSTypeString ) ) ;
117125 }
118126
119- return new List < DetailsElement > ( ) {
127+ Details = new List < DetailsElement > ( ) {
120128 new DetailsElement ( )
121129 {
122130 Key = Resource . item_details_target ,
0 commit comments