Quellcode durchsuchen

Fixes branch/status tooltips

main
Eric Amodio vor 4 Jahren
Ursprung
Commit
bef246c7c1
3 geänderte Dateien mit 15 neuen und 10 gelöschten Zeilen
  1. +4
    -1
      src/git/models/status.ts
  2. +4
    -3
      src/views/nodes/branchNode.ts
  3. +7
    -6
      src/views/nodes/branchTrackingStatusNode.ts

+ 4
- 1
src/git/models/status.ts Datei anzeigen

@ -199,9 +199,9 @@ export class GitStatus {
state: { ahead: number; behind: number },
options: { empty?: string; expand?: boolean; prefix?: string; separator?: string; suffix?: string } = {},
): string {
const { expand = false, prefix = '', separator = ' ', suffix = '' } = options;
if (upstream == null || (state.behind === 0 && state.ahead === 0)) return options.empty ?? '';
const { expand, prefix = '', separator = ' ', suffix = '' } = options;
if (expand) {
let status = '';
if (state.behind) {
@ -209,6 +209,9 @@ export class GitStatus {
}
if (state.ahead) {
status += `${status.length === 0 ? '' : separator}${Strings.pluralize('commit', state.ahead)} ahead`;
if (suffix.endsWith(upstream)) {
status += ' of';
}
}
return `${prefix}${status}${suffix}`;
}

+ 4
- 3
src/views/nodes/branchNode.ts Datei anzeigen

@ -213,10 +213,11 @@ export class BranchNode
GlyphChars.Space
} ${this.branch.tracking}`;
tooltip += ` is tracking ${this.branch.tracking}\n${this.branch.getTrackingStatus({
empty: 'up-to-date',
tooltip += ` is ${this.branch.getTrackingStatus({
empty: `up to date with ${this.branch.tracking}`,
expand: true,
separator: '\n',
separator: ', ',
suffix: ` ${this.branch.tracking}`,
})}`;
if (this.branch.state.ahead || this.branch.state.behind) {

+ 7
- 6
src/views/nodes/branchTrackingStatusNode.ts Datei anzeigen

@ -129,10 +129,10 @@ export class BranchTrackingStatusNode extends ViewNode implement
switch (this.upstreamType) {
case 'ahead':
label = `${Strings.pluralize('commit', this.status.state.ahead)} ahead`;
tooltip = `${this.branch.name} is ${label} of ${this.status.upstream}`;
if (!this.isReposView) {
label = `${this.root ? `${this.branch.name} is ` : ''}${label} of ${this.status.upstream}`;
}
tooltip = `${label} of ${this.status.upstream}`;
collapsibleState = !this.isReposView
? TreeItemCollapsibleState.Expanded
@ -146,10 +146,10 @@ export class BranchTrackingStatusNode extends ViewNode implement
case 'behind':
label = `${Strings.pluralize('commit', this.status.state.behind)} behind`;
tooltip = `${this.branch.name} is ${label} ${this.status.upstream}`;
if (!this.isReposView) {
label = `${this.root ? `${this.branch.name} is ` : ''}${label} ${this.status.upstream}`;
}
tooltip = `${label} ${this.status.upstream}`;
collapsibleState = TreeItemCollapsibleState.Collapsed;
contextValue = this.root
@ -161,10 +161,10 @@ export class BranchTrackingStatusNode extends ViewNode implement
case 'same':
label = `${this.branch.name} is up to date`;
tooltip = `${label} with ${this.status.upstream}`;
if (!this.isReposView) {
label += ` with ${this.status.upstream}`;
}
tooltip = `${label} with ${this.status.upstream}`;
collapsibleState = TreeItemCollapsibleState.None;
contextValue = this.root ? ContextValues.StatusSameAsUpstream : undefined;
@ -185,9 +185,10 @@ export class BranchTrackingStatusNode extends ViewNode implement
const item = new TreeItem(label, collapsibleState);
item.id = this.id;
item.contextValue = contextValue;
item.description = lastFetched
? `Last fetched ${Dates.getFormatter(new Date(lastFetched)).fromNow()}`
: undefined;
if (lastFetched) {
item.description = `Last fetched ${Dates.getFormatter(new Date(lastFetched)).fromNow()}`;
tooltip += `\n${item.description}`;
}
item.iconPath = new ThemeIcon(icon);
item.tooltip = tooltip;

Laden…
Abbrechen
Speichern