Skip to content

Commit 5bf36f1

Browse files
committed
fix(worktree): handle undefined main folder path in getRootItems
- Updated getRootItems method to return an empty array if the main folder path is undefined, preventing potential errors when accessing the path.
1 parent 93a84b1 commit 5bf36f1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/core/treeView/views/worktree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ export class WorktreeDataProvider
102102
private async getRootItems(): Promise<WorkspaceMainGitFolderItem[] | WorktreeItem[]> {
103103
const mainFolders = WorkspaceState.get('mainFolders', []);
104104
if (this.checkOnlyOneMainFolder()) {
105-
const mainFolderPath = mainFolders[0]?.path;
105+
const mainFolderPath = mainFolders[0]?.path || void 0;
106+
if (!mainFolderPath) return [];
106107
const data = await this.getWorktreeListWithCache(mainFolderPath);
107108
const worktreeItems = data.map((item) => {
108109
return new WorktreeItem(item, vscode.TreeItemCollapsibleState.None);

0 commit comments

Comments
 (0)