Browse Source

Changes `registerCommands` to return Disposable[]

main
Eric Amodio 3 years ago
parent
commit
44f1abed9c
11 changed files with 700 additions and 607 deletions
  1. +72
    -61
      src/views/branchesView.ts
  2. +71
    -61
      src/views/commitsView.ts
  3. +64
    -54
      src/views/contributorsView.ts
  4. +61
    -51
      src/views/fileHistoryView.ts
  5. +31
    -21
      src/views/lineHistoryView.ts
  6. +62
    -51
      src/views/remotesView.ts
  7. +176
    -165
      src/views/repositoriesView.ts
  8. +68
    -54
      src/views/searchAndCompareView.ts
  9. +32
    -29
      src/views/stashesView.ts
  10. +52
    -41
      src/views/tagsView.ts
  11. +11
    -19
      src/views/viewBase.ts

+ 72
- 61
src/views/branchesView.ts View File

@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
ProgressLocation,
TreeItem,
TreeItemCollapsibleState,
@ -149,69 +150,79 @@ export class BranchesView extends ViewBase
return new BranchesViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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) {

+ 71
- 61
src/views/commitsView.ts View File

@ -218,69 +218,79 @@ export class CommitsView extends ViewBase {
return new CommitsViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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) {

+ 64
- 54
src/views/contributorsView.ts View File

@ -140,62 +140,72 @@ export class ContributorsView extends ViewBase
return new ContributorsViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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('contributors');
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('setShowAllBranchesOn'),
() => this.setShowAllBranches(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOff'),
() => this.setShowAllBranches(false),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
commands.registerCommand(
this.getQualifiedCommand('setShowStatisticsOn'),
() => this.setShowStatistics(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowStatisticsOff'),
() => this.setShowStatistics(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('contributors');
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('setShowAllBranchesOn'),
() => this.setShowAllBranches(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOff'),
() => this.setShowAllBranches(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowStatisticsOn'),
() => this.setShowStatistics(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowStatisticsOff'),
() => this.setShowStatistics(false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 61
- 51
src/views/fileHistoryView.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, ConfigurationChangeEvent } from 'vscode';
import { commands, ConfigurationChangeEvent, Disposable } from 'vscode';
import { configuration, FileHistoryViewConfig } from '../configuration';
import { ContextKeys, setContext } from '../constants';
import { Container } from '../container';
@ -30,58 +30,68 @@ export class FileHistoryView extends ViewBase
return this._followCursor ? new LineHistoryTrackerNode(this) : new FileHistoryTrackerNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: Disposable[] {
void Container.viewCommands;
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(this.getQualifiedCommand('changeBase'), () => this.changeBase(), this);
commands.registerCommand(
this.getQualifiedCommand('setCursorFollowingOn'),
() => this.setCursorFollowing(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setCursorFollowingOff'),
() => this.setCursorFollowing(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOn'),
() => this.setRenameFollowing(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOff'),
() => this.setRenameFollowing(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOn'),
() => this.setShowAllBranches(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOff'),
() => this.setShowAllBranches(false),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),
commands.registerCommand(this.getQualifiedCommand('changeBase'), () => this.changeBase(), this),
commands.registerCommand(
this.getQualifiedCommand('setCursorFollowingOn'),
() => this.setCursorFollowing(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setCursorFollowingOff'),
() => this.setCursorFollowing(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOn'),
() => this.setRenameFollowing(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setRenameFollowingOff'),
() => this.setRenameFollowing(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOn'),
() => this.setShowAllBranches(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAllBranchesOff'),
() => this.setShowAllBranches(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 31
- 21
src/views/lineHistoryView.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, ConfigurationChangeEvent } from 'vscode';
import { commands, ConfigurationChangeEvent, Disposable } from 'vscode';
import { configuration, LineHistoryViewConfig } from '../configuration';
import { ContextKeys, setContext } from '../constants';
import { Container } from '../container';
@ -25,28 +25,38 @@ export class LineHistoryView extends ViewBase
return new LineHistoryTrackerNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: Disposable[] {
void Container.viewCommands;
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this);
commands.registerCommand(this.getQualifiedCommand('changeBase'), () => this.changeBase(), this);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),
commands.registerCommand(this.getQualifiedCommand('changeBase'), () => this.changeBase(), this),
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOn'),
() => this.setEditorFollowing(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setEditorFollowingOff'),
() => this.setEditorFollowing(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 62
- 51
src/views/remotesView.ts View File

@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
ProgressLocation,
TreeItem,
TreeItemCollapsibleState,
@ -143,59 +144,69 @@ export class RemotesView extends ViewBase {
return new RemotesViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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', 'remotes');
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('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', 'remotes');
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('setShowBranchPullRequestOn'),
() => this.setShowBranchPullRequest(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchPullRequestOff'),
() => this.setShowBranchPullRequest(false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 176
- 165
src/views/repositoriesView.ts View File

@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
Event,
EventEmitter,
ProgressLocation,
@ -61,173 +62,183 @@ export class RepositoriesView extends ViewBase
return new RepositoriesNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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', 'contributors', 'remotes', 'stashes', 'status', 'tags');
return this.refresh(true);
},
this,
);
commands.registerCommand(
this.getQualifiedCommand('setBranchesLayoutToList'),
() => this.setBranchesLayout(ViewBranchesLayout.List),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setBranchesLayoutToTree'),
() => this.setBranchesLayout(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('setAutoRefreshToOn'),
() => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setAutoRefreshToOff'),
() => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, 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('setBranchesShowBranchComparisonOn'),
() => this.setBranchShowBranchComparison(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setBranchesShowBranchComparisonOff'),
() => this.setBranchShowBranchComparison(false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchesOn'),
() => this.toggleSection('showBranches', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchesOff'),
() => this.toggleSection('showBranches', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowCommitsOn'),
() => this.toggleSection('showCommits', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowCommitsOff'),
() => this.toggleSection('showCommits', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowContributorsOn'),
() => this.toggleSection('showContributors', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowContributorsOff'),
() => this.toggleSection('showContributors', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowRemotesOn'),
() => this.toggleSection('showRemotes', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowRemotesOff'),
() => this.toggleSection('showRemotes', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowStashesOn'),
() => this.toggleSection('showStashes', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowStashesOff'),
() => this.toggleSection('showStashes', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowTagsOn'),
() => this.toggleSection('showTags', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowTagsOff'),
() => this.toggleSection('showTags', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowUpstreamStatusOn'),
() => this.toggleSection('showUpstreamStatus', true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowUpstreamStatusOff'),
() => this.toggleSection('showUpstreamStatus', false),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowSectionOff'),
(
node:
| BranchesNode
| BranchNode
| BranchTrackingStatusNode
| CompareBranchNode
| ContributorsNode
| ReflogNode
| RemotesNode
| StashesNode
| TagsNode,
) => this.toggleSectionByNode(node, 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', 'contributors', 'remotes', 'stashes', 'status', 'tags');
return this.refresh(true);
},
this,
),
commands.registerCommand(
this.getQualifiedCommand('setBranchesLayoutToList'),
() => this.setBranchesLayout(ViewBranchesLayout.List),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setBranchesLayoutToTree'),
() => this.setBranchesLayout(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('setAutoRefreshToOn'),
() => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setAutoRefreshToOff'),
() => this.setAutoRefresh(Container.config.views.repositories.autoRefresh, 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('setBranchesShowBranchComparisonOn'),
() => this.setBranchShowBranchComparison(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setBranchesShowBranchComparisonOff'),
() => this.setBranchShowBranchComparison(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchesOn'),
() => this.toggleSection('showBranches', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowBranchesOff'),
() => this.toggleSection('showBranches', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowCommitsOn'),
() => this.toggleSection('showCommits', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowCommitsOff'),
() => this.toggleSection('showCommits', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowContributorsOn'),
() => this.toggleSection('showContributors', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowContributorsOff'),
() => this.toggleSection('showContributors', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowRemotesOn'),
() => this.toggleSection('showRemotes', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowRemotesOff'),
() => this.toggleSection('showRemotes', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowStashesOn'),
() => this.toggleSection('showStashes', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowStashesOff'),
() => this.toggleSection('showStashes', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowTagsOn'),
() => this.toggleSection('showTags', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowTagsOff'),
() => this.toggleSection('showTags', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowUpstreamStatusOn'),
() => this.toggleSection('showUpstreamStatus', true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowUpstreamStatusOff'),
() => this.toggleSection('showUpstreamStatus', false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowSectionOff'),
(
node:
| BranchesNode
| BranchNode
| BranchTrackingStatusNode
| CompareBranchNode
| ContributorsNode
| ReflogNode
| RemotesNode
| StashesNode
| TagsNode,
) => this.toggleSectionByNode(node, false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 68
- 54
src/views/searchAndCompareView.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, ConfigurationChangeEvent, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { commands, ConfigurationChangeEvent, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { getRepoPathOrPrompt } from '../commands';
import { configuration, SearchAndCompareViewConfig, ViewFilesLayout } from '../configuration';
import { ContextKeys, NamedRef, PinnedItem, PinnedItems, setContext, WorkspaceState } from '../constants';
@ -264,61 +264,75 @@ export class SearchAndCompareView extends ViewBase
return new SearchAndCompareViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: Disposable[] {
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this);
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
);
commands.registerCommand(this.getQualifiedCommand('refresh'), () => 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('setKeepResultsToOn'), () => this.setKeepResults(true), this);
commands.registerCommand(
this.getQualifiedCommand('setKeepResultsToOff'),
() => this.setKeepResults(false),
this,
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
commands.registerCommand(this.getQualifiedCommand('pin'), this.pin, this);
commands.registerCommand(this.getQualifiedCommand('unpin'), this.unpin, this);
commands.registerCommand(this.getQualifiedCommand('swapComparison'), this.swapComparison, this);
commands.registerCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this);
commands.registerCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this);
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOnLeft'),
n => this.setFilesFilter(n, 'left'),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOnRight'),
n => this.setFilesFilter(n, 'right'),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOff'),
n => this.setFilesFilter(n, false),
this,
);
return [
commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this),
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => 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('setKeepResultsToOn'),
() => this.setKeepResults(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setKeepResultsToOff'),
() => this.setKeepResults(false),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOn'),
() => this.setShowAvatars(true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setShowAvatarsOff'),
() => this.setShowAvatars(false),
this,
),
commands.registerCommand(this.getQualifiedCommand('pin'), this.pin, this),
commands.registerCommand(this.getQualifiedCommand('unpin'), this.unpin, this),
commands.registerCommand(this.getQualifiedCommand('swapComparison'), this.swapComparison, this),
commands.registerCommand(this.getQualifiedCommand('selectForCompare'), this.selectForCompare, this),
commands.registerCommand(this.getQualifiedCommand('compareWithSelected'), this.compareWithSelected, this),
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOnLeft'),
n => this.setFilesFilter(n, 'left'),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOnRight'),
n => this.setFilesFilter(n, 'right'),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setFilesFilterOff'),
n => this.setFilesFilter(n, false),
this,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 32
- 29
src/views/stashesView.ts View File

@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
ProgressLocation,
TreeItem,
TreeItemCollapsibleState,
@ -124,37 +125,39 @@ export class StashesView extends ViewBase {
return new StashesViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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('stashes');
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,
);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('stashes');
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,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 52
- 41
src/views/tagsView.ts View File

@ -3,6 +3,7 @@ import {
CancellationToken,
commands,
ConfigurationChangeEvent,
Disposable,
ProgressLocation,
TreeItem,
TreeItemCollapsibleState,
@ -131,49 +132,59 @@ export class TagsView extends ViewBase {
return new TagsViewNode(this);
}
protected registerCommands() {
protected registerCommands() class="o">: 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('tags');
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);
return [
commands.registerCommand(
this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
this,
),
commands.registerCommand(
this.getQualifiedCommand('refresh'),
async () => {
await Container.git.resetCaches('tags');
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,
),
];
}
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {

+ 11
- 19
src/views/viewBase.ts View File

@ -101,7 +101,7 @@ export abstract class ViewBase<
return this._onDidChangeNodeCollapsibleState.event;
}
protected disposable: Disposable | undefined;
protected disposables: Disposable[] = [];
protected root: RootNode | undefined;
protected tree: TreeView<ViewNode> | undefined;
@ -152,16 +152,7 @@ export abstract class ViewBase<
};
}
this.registerCommands();
Container.context.subscriptions.push(
configuration.onDidChange(e => {
if (!this.filterConfigurationChanged(e)) return;
this._config = undefined;
this.onConfigurationChanged(e);
}, this),
);
this.disposables.push(...this.registerCommands());
this.initialize({ showCollapseAll: this.showCollapseAll });
@ -184,7 +175,7 @@ export abstract class ViewBase<
}
dispose() {
this.disposable?.dispose();
Disposable.from(...this.disposables).dispose();
}
private _title: string | undefined;
@ -225,7 +216,7 @@ export abstract class ViewBase<
}
protected abstract getRoot(): RootNode;
protected abstract registerCommands(): void;
protected abstract registerCommands(): Disposable[];
protected onConfigurationChanged(e?: ConfigurationChangeEvent): void {
if (e != null && this.root != null) {
void this.refresh(true);
@ -233,16 +224,17 @@ export abstract class ViewBase<
}
protected initialize(options: { showCollapseAll?: boolean } = {}) {
if (this.disposable != null) {
this.disposable.dispose();
this._onDidChangeTreeData = new EventEmitter<ViewNode>();
}
this.tree = window.createTreeView<ViewNode<View>>(this.id, {
...options,
treeDataProvider: this,
});
this.disposable = Disposable.from(
this.disposables.push(
configuration.onDidChange(e => {
if (!this.filterConfigurationChanged(e)) return;
this._config = undefined;
this.onConfigurationChanged(e);
}, this),
this.tree,
this.tree.onDidChangeVisibility(Functions.debounce(this.onVisibilityChanged, 250), this),
this.tree.onDidCollapseElement(this.onElementCollapsed, this),

Loading…
Cancel
Save