Skip to content

Commit 68c25d5

Browse files
committed
Expands remote in Remotes view if its the only one
1 parent 5525314 commit 68c25d5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/views/nodes/remoteNode.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class RemoteNode extends ViewNode<'remote', ViewsWithRemotes> {
2020
protected override readonly parent: ViewNode,
2121
public readonly repo: Repository,
2222
public readonly remote: GitRemote,
23+
private readonly _options?: { expand?: boolean },
2324
) {
2425
super('remote', uri, view, parent);
2526

@@ -83,7 +84,10 @@ export class RemoteNode extends ViewNode<'remote', ViewsWithRemotes> {
8384
}
8485

8586
async getTreeItem(): Promise<TreeItem> {
86-
const item = new TreeItem(this.remote.name, TreeItemCollapsibleState.Collapsed);
87+
const item = new TreeItem(
88+
this.remote.name,
89+
this._options?.expand ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed,
90+
);
8791
item.id = this.id;
8892
item.description = getRemoteUpstreamDescription(this.remote);
8993

src/views/nodes/remotesNode.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ export class RemotesNode extends CacheableChildrenViewNode<'remotes', ViewsWithR
3232
async getChildren(): Promise<ViewNode[]> {
3333
if (this.children == null) {
3434
const remotes = await this.repo.git.remotes.getRemotes({ sort: true });
35-
if (remotes.length === 0) {
35+
if (!remotes.length) {
3636
return [new MessageNode(this.view, this, 'No remotes could be found')];
3737
}
3838

39-
this.children = remotes.map(r => new RemoteNode(this.uri, this.view, this, this.repo, r));
39+
const expand = remotes.length === 1;
40+
this.children = remotes.map(
41+
r => new RemoteNode(this.uri, this.view, this, this.repo, r, { expand: expand }),
42+
);
4043
}
4144

4245
return this.children;

0 commit comments

Comments
 (0)