Skip to content

Commit 0cfc992

Browse files
committed
Fix using workspace name as label for non-root repos
1 parent 94ee94c commit 0cfc992

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/StashNode/NodeFactory.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ export default class NodeFactory {
2121
// May be undefined if the directory is not part of the workspace,
2222
// this happens on upper directories by negative search depth setting.
2323
const wsFolder = workspace.getWorkspaceFolder(Uri.file(path))
24+
// In a root dir, the received path is contained in the workspace's path.
25+
const isRoot = wsFolder?.uri.fsPath.includes(path) ?? false
26+
console.log(`createRepositoryNode() ${path}`, wsFolder?.uri)
2427

2528
return new RepositoryNode(
2629
dirname(path),
2730
basename(path),
28-
wsFolder?.name,
31+
// wsFolder is defined when isRoot is true but TS cannot infer that so add a ?
32+
isRoot ? wsFolder?.name : undefined,
2933
)
3034
}
3135

0 commit comments

Comments
 (0)