From b7b276796b4bd064746115cfb1517cd776eac668 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 27 Mar 2023 01:27:21 -0400 Subject: [PATCH] Replaces enums with types --- src/annotations/annotations.ts | 14 +++---- src/annotations/fileAnnotationController.ts | 14 +++---- src/constants.ts | 55 +++++++++++++++++++--------- src/git/models/issue.ts | 13 ++++--- src/git/models/pullRequest.ts | 17 +++++++-- src/plus/subscription/subscriptionService.ts | 5 ++- src/views/nodes/branchNode.ts | 7 ++-- src/views/nodes/branchTrackingStatusNode.ts | 14 +++++-- src/views/nodes/commitNode.ts | 5 ++- src/views/nodes/fileRevisionAsCommitNode.ts | 5 ++- src/views/nodes/mergeStatusNode.ts | 5 ++- src/views/nodes/rebaseStatusNode.ts | 5 ++- src/views/viewDecorationProvider.ts | 37 ++++++++++--------- src/views/worktreesView.ts | 5 ++- 14 files changed, 126 insertions(+), 75 deletions(-) diff --git a/src/annotations/annotations.ts b/src/annotations/annotations.ts index 8e263ba..2da000c 100644 --- a/src/annotations/annotations.ts +++ b/src/annotations/annotations.ts @@ -9,8 +9,8 @@ import type { import { OverviewRulerLane, ThemeColor, Uri, window } from 'vscode'; import type { Config } from '../config'; import { HeatmapLocations } from '../config'; -import type { CoreConfiguration } from '../constants'; -import { Colors, GlyphChars } from '../constants'; +import type { Colors, CoreConfiguration } from '../constants'; +import { GlyphChars } from '../constants'; import type { CommitFormatOptions } from '../git/formatters/commitFormatter'; import { CommitFormatter } from '../git/formatters/commitFormatter'; import type { GitCommit } from '../git/models/commit'; @@ -202,10 +202,10 @@ export function getGutterRenderOptions( } return { - backgroundColor: new ThemeColor(Colors.GutterBackgroundColor), + backgroundColor: new ThemeColor('gitlens.gutterBackgroundColor' satisfies Colors), borderStyle: borderStyle, borderWidth: borderWidth, - color: new ThemeColor(Colors.GutterForegroundColor), + color: new ThemeColor('gitlens.gutterForegroundColor' satisfies Colors), fontWeight: 'normal', fontStyle: 'normal', height: '100%', @@ -214,7 +214,7 @@ export function getGutterRenderOptions( avatars ? ';padding: 0 0 0 18px' : '' }`, width: width, - uncommittedColor: new ThemeColor(Colors.GutterUncommittedForegroundColor), + uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor' satisfies Colors), }; } @@ -241,8 +241,8 @@ export function getInlineDecoration( return { renderOptions: { after: { - backgroundColor: new ThemeColor(Colors.TrailingLineBackgroundColor), - color: new ThemeColor(Colors.TrailingLineForegroundColor), + backgroundColor: new ThemeColor('gitlens.trailingLineBackgroundColor' satisfies Colors), + color: new ThemeColor('gitlens.trailingLineForegroundColor' satisfies Colors), contentText: pad(message.replace(/ /g, GlyphChars.Space), 1, 1), fontWeight: 'normal', fontStyle: 'normal', diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index c4648de..387b425 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -21,7 +21,7 @@ import { workspace, } from 'vscode'; import { AnnotationsToggleMode, BlameHighlightLocations, ChangesLocations, FileAnnotationType } from '../config'; -import { Colors } from '../constants'; +import type { Colors, CoreColors } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; import { configuration } from '../system/configuration'; @@ -591,7 +591,7 @@ export class FileAnnotationController implements Disposable { gutterIconSize: 'contain', overviewRulerLane: OverviewRulerLane.Left, overviewRulerColor: locations.includes(ChangesLocations.Scrollbar) - ? new ThemeColor('editorOverviewRuler.addedForeground') + ? new ThemeColor('editorOverviewRuler.addedForeground' satisfies CoreColors) : undefined, }); @@ -612,7 +612,7 @@ export class FileAnnotationController implements Disposable { gutterIconSize: 'contain', overviewRulerLane: OverviewRulerLane.Left, overviewRulerColor: locations.includes(ChangesLocations.Scrollbar) - ? new ThemeColor('editorOverviewRuler.modifiedForeground') + ? new ThemeColor('editorOverviewRuler.modifiedForeground' satisfies CoreColors) : undefined, }); @@ -629,7 +629,7 @@ export class FileAnnotationController implements Disposable { gutterIconSize: 'contain', overviewRulerLane: OverviewRulerLane.Left, overviewRulerColor: locations.includes(ChangesLocations.Scrollbar) - ? new ThemeColor('editorOverviewRuler.deletedForeground') + ? new ThemeColor('editorOverviewRuler.deletedForeground' satisfies CoreColors) : undefined, }); } @@ -643,7 +643,7 @@ export class FileAnnotationController implements Disposable { const { locations } = highlight; // TODO@eamodio: Read from the theme color when the API exists - const gutterHighlightColor = '#00bcf2'; // new ThemeColor(Colors.LineHighlightOverviewRulerColor) + const gutterHighlightColor = '#00bcf2'; // new ThemeColor('gitlens.lineHighlightOverviewRulerColor' satisfies Colors) const gutterHighlightUri = locations.includes(BlameHighlightLocations.Gutter) ? Uri.parse( `data:image/svg+xml,${encodeURIComponent( @@ -658,10 +658,10 @@ export class FileAnnotationController implements Disposable { isWholeLine: true, overviewRulerLane: OverviewRulerLane.Right, backgroundColor: locations.includes(BlameHighlightLocations.Line) - ? new ThemeColor(Colors.LineHighlightBackgroundColor) + ? new ThemeColor('gitlens.lineHighlightBackgroundColor' satisfies Colors) : undefined, overviewRulerColor: locations.includes(BlameHighlightLocations.Scrollbar) - ? new ThemeColor(Colors.LineHighlightOverviewRulerColor) + ? new ThemeColor('gitlens.lineHighlightOverviewRulerColor' satisfies Colors) : undefined, }); } diff --git a/src/constants.ts b/src/constants.ts index 9ced13a..071d584 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -55,23 +55,44 @@ export const enum CharCode { z = 122, } -export const enum Colors { - GutterBackgroundColor = 'gitlens.gutterBackgroundColor', - GutterForegroundColor = 'gitlens.gutterForegroundColor', - GutterUncommittedForegroundColor = 'gitlens.gutterUncommittedForegroundColor', - TrailingLineBackgroundColor = 'gitlens.trailingLineBackgroundColor', - TrailingLineForegroundColor = 'gitlens.trailingLineForegroundColor', - LineHighlightBackgroundColor = 'gitlens.lineHighlightBackgroundColor', - LineHighlightOverviewRulerColor = 'gitlens.lineHighlightOverviewRulerColor', - ClosedAutolinkedIssueIconColor = 'gitlens.closedAutolinkedIssueIconColor', - ClosedPullRequestIconColor = 'gitlens.closedPullRequestIconColor', - OpenAutolinkedIssueIconColor = 'gitlens.openAutolinkedIssueIconColor', - OpenPullRequestIconColor = 'gitlens.openPullRequestIconColor', - MergedPullRequestIconColor = 'gitlens.mergedPullRequestIconColor', - UnpublishedChangesIconColor = 'gitlens.unpublishedChangesIconColor', - UnpublishedCommitIconColor = 'gitlens.unpublishedCommitIconColor', - UnpulledChangesIconColor = 'gitlens.unpulledChangesIconColor', -} +export type Colors = + | 'gitlens.closedAutolinkedIssueIconColor' + | 'gitlens.closedPullRequestIconColor' + | 'gitlens.decorations.addedForegroundColor' + | 'gitlens.decorations.branchAheadForegroundColor' + | 'gitlens.decorations.branchBehindForegroundColor' + | 'gitlens.decorations.branchDivergedForegroundColor' + | 'gitlens.decorations.branchMissingUpstreamForegroundColor' + | 'gitlens.decorations.branchUpToDateForegroundColor' + | 'gitlens.decorations.branchUnpublishedForegroundColor' + | 'gitlens.decorations.copiedForegroundColor' + | 'gitlens.decorations.deletedForegroundColor' + | 'gitlens.decorations.ignoredForegroundColor' + | 'gitlens.decorations.modifiedForegroundColor' + | 'gitlens.decorations.renamedForegroundColor' + | 'gitlens.decorations.untrackedForegroundColor' + | 'gitlens.decorations.worktreeView.hasUncommittedChangesForegroundColor' + | 'gitlens.gutterBackgroundColor' + | 'gitlens.gutterForegroundColor' + | 'gitlens.gutterUncommittedForegroundColor' + | 'gitlens.lineHighlightBackgroundColor' + | 'gitlens.lineHighlightOverviewRulerColor' + | 'gitlens.mergedPullRequestIconColor' + | 'gitlens.openAutolinkedIssueIconColor' + | 'gitlens.openPullRequestIconColor' + | 'gitlens.trailingLineBackgroundColor' + | 'gitlens.trailingLineForegroundColor' + | 'gitlens.unpublishedChangesIconColor' + | 'gitlens.unpublishedCommitIconColor' + | 'gitlens.unpulledChangesIconColor'; + +export type CoreColors = + | 'editorOverviewRuler.addedForeground' + | 'editorOverviewRuler.deletedForeground' + | 'editorOverviewRuler.modifiedForeground' + | 'list.foreground' + | 'list.warningForeground' + | 'statusBarItem.warningBackground'; export const enum Commands { ActionPrefix = 'gitlens.action.', diff --git a/src/git/models/issue.ts b/src/git/models/issue.ts index acf39b9..cfc0d01 100644 --- a/src/git/models/issue.ts +++ b/src/git/models/issue.ts @@ -1,5 +1,5 @@ import { ColorThemeKind, ThemeColor, ThemeIcon, window } from 'vscode'; -import { Colors } from '../../constants'; +import type { Colors } from '../../constants'; import type { RemoteProviderReference } from './remoteProvider'; export const enum IssueOrPullRequestType { @@ -115,15 +115,18 @@ export function getIssueOrPullRequestMarkdownIcon(issue: IssueOrPullRequest): st export function getIssueOrPullRequestThemeIcon(issue: IssueOrPullRequest): ThemeIcon { if (issue.type === IssueOrPullRequestType.PullRequest) { if (issue.closed) { - return new ThemeIcon('git-pull-request', new ThemeColor(Colors.MergedPullRequestIconColor)); + return new ThemeIcon( + 'git-pull-request', + new ThemeColor('gitlens.mergedPullRequestIconColor' satisfies Colors), + ); } - return new ThemeIcon('git-pull-request', new ThemeColor(Colors.OpenPullRequestIconColor)); + return new ThemeIcon('git-pull-request', new ThemeColor('gitlens.openPullRequestIconColor' satisfies Colors)); } if (issue.closed) { - return new ThemeIcon('pass', new ThemeColor(Colors.ClosedAutolinkedIssueIconColor)); + return new ThemeIcon('pass', new ThemeColor('gitlens.closedAutolinkedIssueIconColor' satisfies Colors)); } - return new ThemeIcon('issues', new ThemeColor(Colors.OpenAutolinkedIssueIconColor)); + return new ThemeIcon('issues', new ThemeColor('gitlens.openAutolinkedIssueIconColor' satisfies Colors)); } export function serializeIssue(value: IssueShape): IssueShape { diff --git a/src/git/models/pullRequest.ts b/src/git/models/pullRequest.ts index e0f4e3d..9bf8e1e 100644 --- a/src/git/models/pullRequest.ts +++ b/src/git/models/pullRequest.ts @@ -1,6 +1,6 @@ import { ColorThemeKind, ThemeColor, ThemeIcon, window } from 'vscode'; import { DateStyle } from '../../config'; -import { Colors } from '../../constants'; +import type { Colors } from '../../constants'; import { Container } from '../../container'; import { formatDate, fromNow } from '../../system/date'; import { memoize } from '../../system/decorators/memoize'; @@ -154,11 +154,20 @@ export class PullRequest implements PullRequestShape { static getThemeIcon(pullRequest: PullRequest): ThemeIcon { switch (pullRequest.state) { case PullRequestState.Open: - return new ThemeIcon('git-pull-request', new ThemeColor(Colors.OpenPullRequestIconColor)); + return new ThemeIcon( + 'git-pull-request', + new ThemeColor('gitlens.openPullRequestIconColor' satisfies Colors), + ); case PullRequestState.Closed: - return new ThemeIcon('git-pull-request-closed', new ThemeColor(Colors.ClosedPullRequestIconColor)); + return new ThemeIcon( + 'git-pull-request-closed', + new ThemeColor('gitlens.closedPullRequestIconColor' satisfies Colors), + ); case PullRequestState.Merged: - return new ThemeIcon('git-merge', new ThemeColor(Colors.MergedPullRequestIconColor)); + return new ThemeIcon( + 'git-merge', + new ThemeColor('gitlens.mergedPullRequestIconColor' satisfies Colors), + ); default: return new ThemeIcon('git-pull-request'); } diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 1fd68c4..5b1d902 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -22,6 +22,7 @@ import { } from 'vscode'; import { fetch, getProxyAgent } from '@env/fetch'; import { getPlatform } from '@env/platform'; +import type { CoreColors } from '../../constants'; import { Commands } from '../../constants'; import type { Container } from '../../container'; import { setContext } from '../../context'; @@ -1040,7 +1041,9 @@ export class SubscriptionService implements Disposable { if (account?.verified === false) { this._statusBarSubscription.text = `$(warning) ${effective.name} (Unverified)`; - this._statusBarSubscription.backgroundColor = new ThemeColor('statusBarItem.warningBackground'); + this._statusBarSubscription.backgroundColor = new ThemeColor( + 'statusBarItem.warningBackground' satisfies CoreColors, + ); this._statusBarSubscription.tooltip = new MarkdownString( trial ? `**Please verify your email**\n\nBefore you can start your **${effective.name}** trial, please verify your email address.\n\nClick for details` diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 225c6f7..6739ff2 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -1,7 +1,8 @@ import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode'; import type { ViewShowBranchComparison } from '../../config'; import { ViewBranchesLayout } from '../../config'; -import { Colors, GlyphChars } from '../../constants'; +import type { Colors} from '../../constants'; +import { GlyphChars } from '../../constants'; import { getContext } from '../../context'; import type { GitUri } from '../../git/gitUri'; import type { GitBranch } from '../../git/models/branch'; @@ -426,12 +427,12 @@ export class BranchNode if (this.branch.state.ahead || this.branch.state.behind) { if (this.branch.state.ahead) { contextValue += '+ahead'; - color = new ThemeColor(Colors.UnpublishedChangesIconColor); + color = new ThemeColor('gitlens.unpublishedChangesIconColor' satisfies Colors); iconSuffix = '-green'; } if (this.branch.state.behind) { contextValue += '+behind'; - color = new ThemeColor(Colors.UnpulledChangesIconColor); + color = new ThemeColor('gitlens.unpulledChangesIconColor' satisfies Colors); iconSuffix = this.branch.state.ahead ? '-yellow' : '-red'; } } diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 6d099d3..7a4ab05 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -1,5 +1,5 @@ import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; -import { Colors } from '../../constants'; +import type { Colors } from '../../constants'; import { GitUri } from '../../git/gitUri'; import type { GitBranch, GitTrackingState } from '../../git/models/branch'; import { getRemoteNameFromBranchName } from '../../git/models/branch'; @@ -182,7 +182,10 @@ export class BranchTrackingStatusNode extends ViewNode impleme contextValue = this.root ? ContextValues.StatusAheadOfUpstream : ContextValues.BranchStatusAheadOfUpstream; - icon = new ThemeIcon('cloud-upload', new ThemeColor(Colors.UnpublishedChangesIconColor)); + icon = new ThemeIcon( + 'cloud-upload', + new ThemeColor('gitlens.unpublishedChangesIconColor' satisfies Colors), + ); break; } @@ -203,7 +206,10 @@ export class BranchTrackingStatusNode extends ViewNode impleme contextValue = this.root ? ContextValues.StatusBehindUpstream : ContextValues.BranchStatusBehindUpstream; - icon = new ThemeIcon('cloud-download', new ThemeColor(Colors.UnpulledChangesIconColor)); + icon = new ThemeIcon( + 'cloud-download', + new ThemeColor('gitlens.unpulledChangesIconColor' satisfies Colors), + ); break; } @@ -240,7 +246,7 @@ export class BranchTrackingStatusNode extends ViewNode impleme contextValue = this.root ? ContextValues.StatusNoUpstream : ContextValues.BranchStatusNoUpstream; icon = new ThemeIcon( 'cloud-upload', - remotes.length ? new ThemeColor(Colors.UnpublishedChangesIconColor) : undefined, + remotes.length ? new ThemeColor('gitlens.unpublishedChangesIconColor' satisfies Colors) : undefined, ); break; diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 8d4a4b0..2cd61f6 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -2,7 +2,8 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands'; import { ViewFilesLayout } from '../../config'; -import { Colors, Commands } from '../../constants'; +import type { Colors} from '../../constants'; +import { Commands } from '../../constants'; import { getContext } from '../../context'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import type { GitBranch } from '../../git/models/branch'; @@ -176,7 +177,7 @@ export class CommitNode extends ViewRefNode { item.contextValue = ContextValues.Merge; item.description = this.status?.hasConflicts ? pluralize('conflict', this.status.conflicts.length) : undefined; item.iconPath = this.status?.hasConflicts - ? new ThemeIcon('warning', new ThemeColor('list.warningForeground')) - : new ThemeIcon('debug-pause', new ThemeColor('list.foreground')); + ? new ThemeIcon('warning', new ThemeColor('list.warningForeground' satisfies CoreColors)) + : new ThemeIcon('debug-pause', new ThemeColor('list.foreground' satisfies CoreColors)); const markdown = new MarkdownString( `${`Merging ${ diff --git a/src/views/nodes/rebaseStatusNode.ts b/src/views/nodes/rebaseStatusNode.ts index 5587da6..c8c4fa8 100644 --- a/src/views/nodes/rebaseStatusNode.ts +++ b/src/views/nodes/rebaseStatusNode.ts @@ -2,6 +2,7 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import type { DiffWithPreviousCommandArgs } from '../../commands'; import { ViewFilesLayout } from '../../config'; +import type { CoreColors } from '../../constants'; import { Commands } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; @@ -93,8 +94,8 @@ export class RebaseStatusNode extends ViewNode { item.contextValue = ContextValues.Rebase; item.description = this.status?.hasConflicts ? pluralize('conflict', this.status.conflicts.length) : undefined; item.iconPath = this.status?.hasConflicts - ? new ThemeIcon('warning', new ThemeColor('list.warningForeground')) - : new ThemeIcon('debug-pause', new ThemeColor('list.foreground')); + ? new ThemeIcon('warning', new ThemeColor('list.warningForeground' satisfies CoreColors)) + : new ThemeIcon('debug-pause', new ThemeColor('list.foreground' satisfies CoreColors)); const markdown = new MarkdownString( `${`Rebasing ${ diff --git a/src/views/viewDecorationProvider.ts b/src/views/viewDecorationProvider.ts index 34c943a..065a1a0 100644 --- a/src/views/viewDecorationProvider.ts +++ b/src/views/viewDecorationProvider.ts @@ -1,5 +1,6 @@ import type { CancellationToken, Event, FileDecoration, FileDecorationProvider, Uri } from 'vscode'; import { Disposable, EventEmitter, ThemeColor, window } from 'vscode'; +import type { Colors } from '../constants'; import { GlyphChars } from '../constants'; import { GitBranchStatus } from '../git/models/branch'; @@ -56,43 +57,43 @@ export class ViewFileDecorationProvider implements FileDecorationProvider, Dispo case '!': return { badge: 'I', - color: new ThemeColor('gitlens.decorations.ignoredForegroundColor'), + color: new ThemeColor('gitlens.decorations.ignoredForegroundColor' satisfies Colors), tooltip: 'Ignored', }; case '?': return { badge: 'U', - color: new ThemeColor('gitlens.decorations.untrackedForegroundColor'), + color: new ThemeColor('gitlens.decorations.untrackedForegroundColor' satisfies Colors), tooltip: 'Untracked', }; case 'A': return { badge: 'A', - color: new ThemeColor('gitlens.decorations.addedForegroundColor'), + color: new ThemeColor('gitlens.decorations.addedForegroundColor' satisfies Colors), tooltip: 'Added', }; case 'C': return { badge: 'C', - color: new ThemeColor('gitlens.decorations.copiedForegroundColor'), + color: new ThemeColor('gitlens.decorations.copiedForegroundColor' satisfies Colors), tooltip: 'Copied', }; case 'D': return { badge: 'D', - color: new ThemeColor('gitlens.decorations.deletedForegroundColor'), + color: new ThemeColor('gitlens.decorations.deletedForegroundColor' satisfies Colors), tooltip: 'Deleted', }; case 'M': return { badge: 'M', - // color: new ThemeColor('gitlens.decorations.modifiedForegroundColor'), + // color: new ThemeColor('gitlens.decorations.modifiedForegroundColor' satisfies Colors), tooltip: 'Modified', }; case 'R': return { badge: 'R', - color: new ThemeColor('gitlens.decorations.renamedForegroundColor'), + color: new ThemeColor('gitlens.decorations.renamedForegroundColor' satisfies Colors), tooltip: 'Renamed', }; default: @@ -107,37 +108,37 @@ export class ViewFileDecorationProvider implements FileDecorationProvider, Dispo case GitBranchStatus.Ahead: return { badge: '▲', - color: new ThemeColor('gitlens.decorations.branchAheadForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchAheadForegroundColor' satisfies Colors), tooltip: 'Ahead', }; case GitBranchStatus.Behind: return { badge: '▼', - color: new ThemeColor('gitlens.decorations.branchBehindForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchBehindForegroundColor' satisfies Colors), tooltip: 'Behind', }; case GitBranchStatus.Diverged: return { badge: '▼▲', - color: new ThemeColor('gitlens.decorations.branchDivergedForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchDivergedForegroundColor' satisfies Colors), tooltip: 'Diverged', }; case GitBranchStatus.MissingUpstream: return { badge: '!', - color: new ThemeColor('gitlens.decorations.branchMissingUpstreamForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchMissingUpstreamForegroundColor' satisfies Colors), tooltip: 'Missing Upstream', }; case GitBranchStatus.UpToDate: return { badge: '', - color: new ThemeColor('gitlens.decorations.branchUpToDateForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchUpToDateForegroundColor' satisfies Colors), tooltip: 'Up to Date', }; case GitBranchStatus.Unpublished: return { badge: '▲+', - color: new ThemeColor('gitlens.decorations.branchUnpublishedForegroundColor'), + color: new ThemeColor('gitlens.decorations.branchUnpublishedForegroundColor' satisfies Colors), tooltip: 'Unpublished', }; default: @@ -153,19 +154,19 @@ export class ViewFileDecorationProvider implements FileDecorationProvider, Dispo let color; switch (status as GitBranchStatus) { case GitBranchStatus.Ahead: - color = new ThemeColor('gitlens.decorations.branchAheadForegroundColor'); + color = new ThemeColor('gitlens.decorations.branchAheadForegroundColor' satisfies Colors); break; case GitBranchStatus.Behind: - color = new ThemeColor('gitlens.decorations.branchBehindForegroundColor'); + color = new ThemeColor('gitlens.decorations.branchBehindForegroundColor' satisfies Colors); break; case GitBranchStatus.Diverged: - color = new ThemeColor('gitlens.decorations.branchDivergedForegroundColor'); + color = new ThemeColor('gitlens.decorations.branchDivergedForegroundColor' satisfies Colors); break; case GitBranchStatus.UpToDate: - color = new ThemeColor('gitlens.decorations.branchUpToDateForegroundColor'); + color = new ThemeColor('gitlens.decorations.branchUpToDateForegroundColor' satisfies Colors); break; case GitBranchStatus.Unpublished: - color = new ThemeColor('gitlens.decorations.branchUnpublishedForegroundColor'); + color = new ThemeColor('gitlens.decorations.branchUnpublishedForegroundColor' satisfies Colors); break; } diff --git a/src/views/worktreesView.ts b/src/views/worktreesView.ts index 1d8c01d..e018388 100644 --- a/src/views/worktreesView.ts +++ b/src/views/worktreesView.ts @@ -2,6 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable, TreeViewV import { ProgressLocation, ThemeColor, TreeItem, TreeItemCollapsibleState, window } from 'vscode'; import type { WorktreesViewConfig } from '../config'; import { ViewFilesLayout, ViewShowBranchComparison } from '../config'; +import type { Colors} from '../constants'; import { Commands } from '../constants'; import type { Container } from '../container'; import { PlusFeatures } from '../features'; @@ -112,7 +113,9 @@ export class WorktreesView extends ViewBase