Bladeren bron

Adds clear to branch compare node

Adds hide menus for branch compare nodes
Moves branch comparison node under branch node
main
Eric Amodio 4 jaren geleden
bovenliggende
commit
95ede42502
6 gewijzigde bestanden met toevoegingen van 109 en 11 verwijderingen
  1. +57
    -4
      package.json
  2. +22
    -6
      src/views/commitsView.ts
  3. +9
    -1
      src/views/nodes/branchNode.ts
  4. +11
    -0
      src/views/nodes/compareBranchNode.ts
  5. +4
    -0
      src/views/nodes/viewNode.ts
  6. +6
    -0
      src/views/viewCommands.ts

+ 57
- 4
package.json Bestand weergeven

@ -3169,7 +3169,7 @@
},
{
"command": "gitlens.views.setComparisonToTwoDot",
"title": "Switch to Two-dot Comparison",
"title": "Toggle Comparison Type (Two-dot)",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-compare-twodot.svg",
@ -3178,7 +3178,7 @@
},
{
"command": "gitlens.views.setComparisonToThreeDot",
"title": "Switch to Three-dot Comparison",
"title": "Toggle Comparison Type (Three-dot)",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-compare-threedot.svg",
@ -3262,7 +3262,7 @@
},
{
"command": "gitlens.views.setBranchComparisonToWorking",
"title": "Switch to Working Tree Comparison",
"title": "Toggle Comparison Source (Working Tree)",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-compare-ref-working.svg",
@ -3271,11 +3271,17 @@
},
{
"command": "gitlens.views.setBranchComparisonToBranch",
"title": "Switch to Branch Comparison",
"title": "Toggle Comparison Source (Branch)",
"category": "GitLens",
"icon": "$(compare-changes)"
},
{
"command": "gitlens.views.clearNode",
"title": "Clear",
"category": "GitLens",
"icon": "$(close)"
},
{
"command": "gitlens.views.dismissNode",
"title": "Dismiss",
"category": "GitLens",
@ -3415,6 +3421,16 @@
"category": "GitLens"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOn",
"title": "Show Branch Comparison",
"category": "GitLens"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOff",
"title": "Hide Branch Comparison",
"category": "GitLens"
},
{
"command": "gitlens.views.compare.clear",
"title": "Clear Results",
"category": "GitLens",
@ -4552,6 +4568,10 @@
"when": "false"
},
{
"command": "gitlens.views.clearNode",
"when": "false"
},
{
"command": "gitlens.views.dismissNode",
"when": "false"
},
@ -4644,6 +4664,14 @@
"when": "false"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOn",
"when": "false"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOff",
"when": "false"
},
{
"command": "gitlens.views.compare.clear",
"when": "false"
},
@ -5701,6 +5729,16 @@
"group": "1_gitlens@0"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOn",
"when": "view =~ /^gitlens\\.views\\.commits/ && !config.gitlens.views.commits.showBranchComparison",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOff",
"when": "view =~ /^gitlens\\.views\\.commits/ && config.gitlens.views.commits.showBranchComparison",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.contributors.setFilesLayoutToList",
"when": "view =~ /^gitlens\\.views\\.contributors/ && config.gitlens.views.contributors.files.layout == auto",
"group": "navigation@13"
@ -6555,6 +6593,11 @@
"group": "inline@1"
},
{
"command": "gitlens.views.clearNode",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)/",
"group": "inline@99"
},
{
"command": "gitlens.views.setBranchComparisonToWorking",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+branch\\b)/",
"group": "inline@2"
@ -6585,6 +6628,16 @@
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOff",
"when": "viewItem =~ /gitlens:compare:branch\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.views.clearNode",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.views.setComparisonToTwoDot",
"when": "viewItem =~ /gitlens:compare:results\\b(?=.*?\\b\\+threedot\\b)/",
"group": "inline@2"

+ 22
- 6
src/views/commitsView.ts Bestand weergeven

@ -8,7 +8,7 @@ import {
TreeItemCollapsibleState,
window,
} from 'vscode';
import { CommitsViewConfig, configuration, ViewFilesLayout } from '../configuration';
import { CommitsViewConfig, configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration';
import { CommandContext, GlyphChars, setCommandContext } from '../constants';
import { Container } from '../container';
import {
@ -22,6 +22,7 @@ import {
import { GitUri } from '../git/gitUri';
import {
BranchNode,
BranchTrackingStatusNode,
CompareBranchNode,
ContextValues,
MessageNode,
@ -32,7 +33,6 @@ import {
} from './nodes';
import { debug, gate } from '../system';
import { ViewBase } from './viewBase';
import { BranchTrackingStatusNode } from './nodes/branchTrackingStatusNode';
export class CommitsRepositoryNode extends SubscribeableViewNode<CommitsView> {
protected splatted = true;
@ -66,15 +66,12 @@ export class CommitsRepositoryNode extends SubscribeableViewNode {
this.children = [
new BranchNode(this.uri, this.view, this, branch, true, {
expanded: true,
showComparison: this.view.config.showBranchComparison,
showCurrent: false,
showTracking: true,
authors: authors,
}),
];
if (this.view.config.showBranchComparison !== false) {
this.children.push(new CompareBranchNode(this.uri, this.view, this, branch));
}
}
const [branch, ...rest] = this.children;
@ -271,6 +268,16 @@ export class CommitsView extends ViewBase {
);
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,
);
}
protected filterConfigurationChanged(e: ConfigurationChangeEvent) {
@ -367,6 +374,15 @@ export class CommitsView extends ViewBase {
return configuration.updateEffective('views', this.configKey, 'avatars', enabled);
}
private setShowBranchComparison(enabled: boolean) {
return configuration.updateEffective(
'views',
this.configKey,
'showBranchComparison',
enabled ? ViewShowBranchComparison.Working : false,
);
}
private setMyCommitsOnly(enabled: boolean) {
void setCommandContext(CommandContext.ViewsCommitsMyCommitsOnly, enabled);
this.state.myCommitsOnly = enabled;

+ 9
- 1
src/views/nodes/branchNode.ts Bestand weergeven

@ -5,7 +5,8 @@ import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
import { CommitNode } from './commitNode';
import { CommitsView } from '../commitsView';
import { LoadMoreNode, MessageNode } from './common';
import { ViewBranchesLayout } from '../../configuration';
import { CompareBranchNode } from './compareBranchNode';
import { ViewBranchesLayout, ViewShowBranchComparison } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { BranchDateFormatting, GitBranch, GitBranchReference, GitLog, GitRemoteType } from '../../git/git';
@ -28,6 +29,7 @@ export class BranchNode
private _children: ViewNode[] | undefined;
private readonly options: {
expanded: boolean;
showComparison: false | ViewShowBranchComparison;
showCurrent: boolean;
showTracking: boolean;
authors?: string[];
@ -44,6 +46,7 @@ export class BranchNode
options?: {
expanded?: boolean;
showComparison?: false | ViewShowBranchComparison;
showCurrent?: boolean;
showTracking?: boolean;
authors?: string[];
@ -53,6 +56,7 @@ export class BranchNode
this.options = {
expanded: false,
showComparison: false,
// Hide the current branch checkmark when the node is displayed as a root under the repository node
showCurrent: !this.root,
// Don't show tracking info the node is displayed as a root under the repository node
@ -131,6 +135,10 @@ export class BranchNode
new BranchTrackingStatusNode(this.view, this, this.branch, status, 'none', this.root),
);
}
if (this.options.showComparison !== false && this.view instanceof CommitsView) {
children.push(new CompareBranchNode(this.uri, this.view, this, this.branch));
}
}
const log = await this.getLog();

+ 11
- 0
src/views/nodes/compareBranchNode.ts Bestand weergeven

@ -134,6 +134,17 @@ export class CompareBranchNode extends ViewNode
}
@log()
async clear() {
if (this._compareWith == null) return;
this._compareWith = undefined;
await this.updateCompareWith(undefined);
this._children = undefined;
this.view.triggerNodeChange(this);
}
@log()
async setComparisonNotation(comparisonNotation: '...' | '..') {
if (this._compareWith !== undefined) {
await this.updateCompareWith({ ...this._compareWith, notation: comparisonNotation });

+ 4
- 0
src/views/nodes/viewNode.ts Bestand weergeven

@ -136,6 +136,10 @@ export abstract class ViewRefFileNode extends ViewRef
}
}
export function nodeSupportsClearing(node: ViewNode): node is ViewNode & { clear(): void | Promise<void> } {
return typeof (node as ViewNode & { clear(): void | Promise<void> }).clear === 'function';
}
export function nodeSupportsConditionalDismissal(node: ViewNode): node is ViewNode & { canDismiss(): boolean } {
return typeof (node as ViewNode & { canDismiss(): boolean }).canDismiss === 'function';
}

+ 6
- 0
src/views/viewCommands.ts Bestand weergeven

@ -28,6 +28,7 @@ import {
FileHistoryNode,
FolderNode,
LineHistoryNode,
nodeSupportsClearing,
PageableViewNode,
PagerNode,
RemoteNode,
@ -85,6 +86,11 @@ export class ViewCommands {
this,
);
commands.registerCommand(
'gitlens.views.clearNode',
(node: ViewNode) => nodeSupportsClearing(node) && node.clear(),
this,
);
commands.registerCommand(
'gitlens.views.dismissNode',
(node: ViewNode) => viewSupportsNodeDismissal(node.view) && node.view.dismissNode(node),
this,

Laden…
Annuleren
Opslaan