Skip to content

Commit

Permalink
Changes registerCommands to return Disposable[]
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Oct 31, 2021
1 parent 26ac077 commit 44f1abe
Show file tree
Hide file tree
Showing 11 changed files with 700 additions and 607 deletions.
133 changes: 72 additions & 61 deletions src/views/branchesView.ts
Expand Up @@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
ProgressLocation,
TreeItem,
TreeItemCollapsibleState,
Expand Down Expand Up @@ -149,69 +150,79 @@ export class BranchesView extends ViewBase<BranchesViewNode, BranchesViewConfig>
return new BranchesViewNode(this);
}

protected registerCommands() {
protected registerCommands(): Disposable[] {
void Container.viewCommands;

commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setLayoutToList'),
() => this.setLayout(ViewBranchesLayout.List),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setLayoutToTree'),
() => this.setLayout(ViewBranchesLayout.Tree),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToList'),
() => this.setFilesLayout(ViewFilesLayout.List),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToTree'),
() => this.setFilesLayout(ViewFilesLayout.Tree),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOn'),
() => this.setShowBranchComparison(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOff'),
() => this.setShowBranchComparison(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOn'),
() => this.setShowBranchPullRequest(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOff'),
() => this.setShowBranchPullRequest(false),
this,
);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches');
return this.refresh(true);
},
this,
),
commands.registerCommand(
this.getQualifiedCommand('setLayoutToList'),
() => this.setLayout(ViewBranchesLayout.List),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setLayoutToTree'),
() => this.setLayout(ViewBranchesLayout.Tree),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToList'),
() => this.setFilesLayout(ViewFilesLayout.List),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToTree'),
() => this.setFilesLayout(ViewFilesLayout.Tree),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOn'),
() => this.setShowBranchComparison(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOff'),
() => this.setShowBranchComparison(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOn'),
() => this.setShowBranchPullRequest(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOff'),
() => this.setShowBranchPullRequest(false),
this,
),
];
}

protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {
Expand Down
132 changes: 71 additions & 61 deletions src/views/commitsView.ts
Expand Up @@ -218,69 +218,79 @@ export class CommitsView extends ViewBase<CommitsViewNode, CommitsViewConfig> {
return new CommitsViewNode(this);
}

protected registerCommands() {
protected registerCommands(): Disposable[] {
void Container.viewCommands;

commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches', 'status', 'tags');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToList'),
() => this.setFilesLayout(ViewFilesLayout.List),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToTree'),
() => this.setFilesLayout(ViewFilesLayout.Tree),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setMyCommitsOnlyOn'),
() => this.setMyCommitsOnly(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setMyCommitsOnlyOff'),
() => this.setMyCommitsOnly(false),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOn'),
() => this.setShowBranchComparison(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOff'),
() => this.setShowBranchComparison(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOn'),
() => this.setShowBranchPullRequest(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOff'),
() => this.setShowBranchPullRequest(false),
this,
);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('branches', 'status', 'tags');
return this.refresh(true);
},
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToAuto'),
() => this.setFilesLayout(ViewFilesLayout.Auto),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToList'),
() => this.setFilesLayout(ViewFilesLayout.List),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesLayoutToTree'),
() => this.setFilesLayout(ViewFilesLayout.Tree),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setMyCommitsOnlyOn'),
() => this.setMyCommitsOnly(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setMyCommitsOnlyOff'),
() => this.setMyCommitsOnly(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOn'),
() => this.setShowBranchComparison(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOff'),
() => this.setShowBranchComparison(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOn'),
() => this.setShowBranchPullRequest(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOff'),
() => this.setShowBranchPullRequest(false),
this,
),
];
}

protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {
Expand Down

0 comments on commit 44f1abe

Please sign in to comment.