diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts index 06122be..ea58260 100644 --- a/src/views/nodes/branchNode.ts +++ b/src/views/nodes/branchNode.ts @@ -11,8 +11,14 @@ import { CommitNode } from './commitNode'; import { MessageNode, ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class BranchNode extends ViewRefNode implements PageableViewNode { + static key = ':branch'; + static getId(repoPath: string, name: string, root: boolean): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${name})${root ? ':root' : ''}`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -35,9 +41,7 @@ export class BranchNode extends ViewRefNode implements Pageabl } get id(): string { - return `gitlens:repository(${this.branch.repoPath})${this._root ? ':root' : ''}:branch(${this.branch.name})${ - this.branch.current ? '+current' : '' - }${this.branch.remote ? '+remote' : ''}${this.branch.starred ? '+starred' : ''}`; + return BranchNode.getId(this.branch.repoPath, this.branch.name, this._root); } get current(): boolean { diff --git a/src/views/nodes/branchOrTagFolderNode.ts b/src/views/nodes/branchOrTagFolderNode.ts index ae5fe43..932cab3 100644 --- a/src/views/nodes/branchOrTagFolderNode.ts +++ b/src/views/nodes/branchOrTagFolderNode.ts @@ -6,8 +6,15 @@ import { View } from '../viewBase'; import { BranchNode } from './branchNode'; import { TagNode } from './tagNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class BranchOrTagFolderNode extends ViewNode { + static getId(repoPath: string, key: string | undefined, type: string, relativePath: string | undefined): string { + return `${RepositoryNode.getId(repoPath)}:${ + key === undefined ? type : `${key}:${type}` + }-folder(${relativePath})`; + } + constructor( view: View, parent: ViewNode, @@ -27,9 +34,7 @@ export class BranchOrTagFolderNode extends ViewNode { } get id(): string { - return `gitlens:repository(${this.repoPath})${this._key === undefined ? '' : `:${this._key}`}:${ - this.type - }-folder(${this.relativePath})`; + return BranchOrTagFolderNode.getId(this.repoPath, this._key, this.type, this.relativePath); } getChildren(): ViewNode[] { diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index 74e546d..e9bb315 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -8,6 +8,7 @@ import { CommitNode } from './commitNode'; import { ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; +import { BranchNode } from './branchNode'; export interface BranchTrackingStatus { ref: string; @@ -17,6 +18,11 @@ export interface BranchTrackingStatus { } export class BranchTrackingStatusNode extends ViewNode implements PageableViewNode { + static key = ':status:upstream'; + static getId(repoPath: string, name: string, root: boolean, upstream: string, direction: string): string { + return `${BranchNode.getId(repoPath, name, root)}${this.key}(${upstream}|${direction})`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -34,9 +40,13 @@ export class BranchTrackingStatusNode extends ViewNode implements } get id(): string { - return `gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${ - this.status.ref - }):status:upstream:(${this.status.upstream}):${this.direction}`; + return BranchTrackingStatusNode.getId( + this.status.repoPath, + this.status.ref, + this._root, + this.status.upstream!, + this.direction + ); } get repoPath(): string { diff --git a/src/views/nodes/branchesNode.ts b/src/views/nodes/branchesNode.ts index 493feec..15c1a82 100644 --- a/src/views/nodes/branchesNode.ts +++ b/src/views/nodes/branchesNode.ts @@ -8,8 +8,14 @@ import { RepositoriesView } from '../repositoriesView'; import { BranchNode } from './branchNode'; import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class BranchesNode extends ViewNode { + static key = ':branches'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + private _children: ViewNode[] | undefined; constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { @@ -17,7 +23,7 @@ export class BranchesNode extends ViewNode { } get id(): string { - return `gitlens:repository(${this.repo.path}):branches`; + return BranchesNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index 610ef4a..7491e87 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -10,8 +10,14 @@ import { Container } from '../../container'; import { log, Strings } from '../../system'; import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode'; import { ViewShowBranchComparison } from '../../config'; +import { RepositoryNode } from './repositoryNode'; export class CompareBranchNode extends ViewNode { + static key = ':compare-branch'; + static getId(repoPath: string, name: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`; + } + private _children: ViewNode[] | undefined; private _compareWith: BranchComparison | undefined; @@ -32,7 +38,7 @@ export class CompareBranchNode extends ViewNode { } get id(): string { - return `gitlens:repository(${this.branch.repoPath}):compare:branch(${this.branch.name}):compareWith`; + return CompareBranchNode.getId(this.branch.repoPath, this.branch.name); } async getChildren(): Promise { diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts index 4fd1a1d..356a39f 100644 --- a/src/views/nodes/compareResultsNode.ts +++ b/src/views/nodes/compareResultsNode.ts @@ -8,10 +8,16 @@ import { CompareView } from '../compareView'; import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode'; import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; let instanceId = 0; export class CompareResultsNode extends SubscribeableViewNode { + static key = ':compare-results'; + static getId(repoPath: string, ref1: string, ref2: string, instanceId: number): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${ref1}|${ref2}):${instanceId}`; + } + private _children: ViewNode[] | undefined; private _instanceId: number; @@ -28,7 +34,7 @@ export class CompareResultsNode extends SubscribeableViewNode { } get id(): string { - return `gitlens:repository(${this.repoPath}):compare(${this._ref.ref}:${this._compareWith.ref})|${this._instanceId}`; + return CompareResultsNode.getId(this.repoPath, this._ref.ref, this._compareWith.ref, this._instanceId); } get pinned(): boolean { diff --git a/src/views/nodes/contributorNode.ts b/src/views/nodes/contributorNode.ts index d8d5f91..cf06b11 100644 --- a/src/views/nodes/contributorNode.ts +++ b/src/views/nodes/contributorNode.ts @@ -9,8 +9,14 @@ import { MessageNode, ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; import { CommitNode } from './commitNode'; import { GlyphChars } from '../../constants'; +import { RepositoryNode } from './repositoryNode'; export class ContributorNode extends ViewNode implements PageableViewNode { + static key = ':contributor'; + static getId(repoPath: string, name: string, email: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${email})`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -24,7 +30,7 @@ export class ContributorNode extends ViewNode implements Pagea } get id(): string { - return `gitlens:repository(${this.contributor.repoPath}):contributor(${this.contributor.name}|${this.contributor.email}}`; + return ContributorNode.getId(this.contributor.repoPath, this.contributor.name, this.contributor.email); } async getChildren(): Promise { diff --git a/src/views/nodes/contributorsNode.ts b/src/views/nodes/contributorsNode.ts index 2d01b34..22127ad 100644 --- a/src/views/nodes/contributorsNode.ts +++ b/src/views/nodes/contributorsNode.ts @@ -6,14 +6,20 @@ import { MessageNode } from './common'; import { ContributorNode } from './contributorNode'; import { ResourceType, ViewNode } from './viewNode'; import { Container } from '../../container'; +import { RepositoryNode } from './repositoryNode'; export class ContributorsNode extends ViewNode { + static key = ':contributors'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } get id(): string { - return `gitlens:repository(${this.repo.path}):contributors`; + return ContributorsNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/reflogNode.ts b/src/views/nodes/reflogNode.ts index e6466b0..f6b6292 100644 --- a/src/views/nodes/reflogNode.ts +++ b/src/views/nodes/reflogNode.ts @@ -7,8 +7,14 @@ import { RepositoriesView } from '../repositoriesView'; import { ReflogRecordNode } from './reflogRecordNode'; import { debug, gate } from '../../system'; import { MessageNode, ShowMoreNode } from './common'; +import { RepositoryNode } from './repositoryNode'; export class ReflogNode extends ViewNode implements PageableViewNode { + static key = ':reflog'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -20,7 +26,7 @@ export class ReflogNode extends ViewNode implements PageableVi } get id(): string { - return `gitlens:repository(${this.repo.path}):reflog`; + return ReflogNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/reflogRecordNode.ts b/src/views/nodes/reflogRecordNode.ts index 65f00c1..bfe7ebb 100644 --- a/src/views/nodes/reflogRecordNode.ts +++ b/src/views/nodes/reflogRecordNode.ts @@ -8,8 +8,22 @@ import { ViewWithFiles } from '../viewBase'; import { CommitNode } from './commitNode'; import { MessageNode, ShowMoreNode } from './common'; import { PageableViewNode, ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class ReflogRecordNode extends ViewNode implements PageableViewNode { + static key = ':reflog-record'; + static getId( + repoPath: string, + sha: string, + selector: string, + command: string, + commandArgs: string | undefined, + date: Date + ): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${sha}|${selector}|${command}|${commandArgs || + ''}|${date.getTime()})`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -19,9 +33,14 @@ export class ReflogRecordNode extends ViewNode implements Pageabl } get id(): string { - return `gitlens:repository(${this.uri.repoPath}):reflog-record(${this.record.sha}|${this.record.selector}|${ - this.record.command - }|${this.record.commandArgs || ''}|${this.record.date.getTime()})`; + return ReflogRecordNode.getId( + this.uri.repoPath!, + this.record.sha, + this.record.selector, + this.record.command, + this.record.commandArgs, + this.record.date + ); } async getChildren(): Promise { diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts index 4af7889..0a0154a 100644 --- a/src/views/nodes/remoteNode.ts +++ b/src/views/nodes/remoteNode.ts @@ -9,8 +9,14 @@ import { RepositoriesView } from '../repositoriesView'; import { BranchNode } from './branchNode'; import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class RemoteNode extends ViewNode { + static key = ':remote'; + static getId(repoPath: string, name: string, id: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${name}|${id})`; + } + constructor( uri: GitUri, view: RepositoriesView, @@ -26,7 +32,7 @@ export class RemoteNode extends ViewNode { } get id(): string { - return `gitlens:repository(${this.remote.repoPath}):remote(${this.remote.name}:${this.remote.id})`; + return RemoteNode.getId(this.remote.repoPath, this.remote.name, this.remote.id); } async getChildren(): Promise { diff --git a/src/views/nodes/remotesNode.ts b/src/views/nodes/remotesNode.ts index 05195fc..206b6b2 100644 --- a/src/views/nodes/remotesNode.ts +++ b/src/views/nodes/remotesNode.ts @@ -6,14 +6,20 @@ import { RepositoriesView } from '../repositoriesView'; import { MessageNode } from './common'; import { RemoteNode } from './remoteNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class RemotesNode extends ViewNode { + static key = ':remotes'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } get id(): string { - return `gitlens:repository(${this.repo.path}):remotes`; + return RemotesNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index cd38b14..7b0e3b9 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -29,6 +29,11 @@ import { ResourceType, SubscribeableViewNode, ViewNode } from './viewNode'; const hasTimeRegex = /[hHm]/; export class RepositoryNode extends SubscribeableViewNode { + static key = ':repository'; + static getId(repoPath: string): string { + return `gitlens${this.key}(${repoPath})`; + } + private _children: ViewNode[] | undefined; private _lastFetched: number = 0; private _status: Promise; @@ -44,7 +49,7 @@ export class RepositoryNode extends SubscribeableViewNode { } get id(): string { - return `gitlens:repository(${this.repo.path})${this.repo.starred ? '+starred' : ''}`; + return RepositoryNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/searchResultsCommitsNode.ts b/src/views/nodes/searchResultsCommitsNode.ts index c764ab5..fdbe25c 100644 --- a/src/views/nodes/searchResultsCommitsNode.ts +++ b/src/views/nodes/searchResultsCommitsNode.ts @@ -5,11 +5,19 @@ import { Commands } from '../../commands/common'; import { ViewWithFiles } from '../viewBase'; import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; import { SearchPattern } from '../../git/gitService'; let instanceId = 0; export class SearchResultsCommitsNode extends ResultsCommitsNode { + static key = ':search-results'; + static getId(repoPath: string, search: SearchPattern | undefined, instanceId: number): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${ + search === undefined ? '?' : SearchPattern.toKey(search) + }):${instanceId}`; + } + private _instanceId: number; constructor( @@ -29,11 +37,7 @@ export class SearchResultsCommitsNode extends ResultsCommitsNode { } get id(): string { - return `gitlens:repository(${this.repoPath}):search(${this.search && this.search.pattern}|${ - this.search && this.search.matchAll ? 'A' : '' - }${this.search && this.search.matchCase ? 'C' : ''}${ - this.search && this.search.matchRegex ? 'R' : '' - }):commits|${this._instanceId}`; + return SearchResultsCommitsNode.getId(this.repoPath, this.search, this._instanceId); } get type(): ResourceType { diff --git a/src/views/nodes/stashNode.ts b/src/views/nodes/stashNode.ts index 862c099..69358a4 100644 --- a/src/views/nodes/stashNode.ts +++ b/src/views/nodes/stashNode.ts @@ -6,8 +6,14 @@ import { Iterables } from '../../system'; import { View } from '../viewBase'; import { StashFileNode } from './stashFileNode'; import { ResourceType, ViewNode, ViewRefNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class StashNode extends ViewRefNode { + static key = ':stash'; + static getId(repoPath: string, ref: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`; + } + constructor(view: View, parent: ViewNode, public readonly commit: GitStashCommit) { super(commit.toGitUri(), view, parent); } @@ -17,7 +23,7 @@ export class StashNode extends ViewRefNode { } get id(): string { - return `gitlens:repository(${this.commit.repoPath}):stash(${this.commit.sha})`; + return StashNode.getId(this.commit.repoPath, this.commit.sha); } get ref(): string { diff --git a/src/views/nodes/stashesNode.ts b/src/views/nodes/stashesNode.ts index 819613f..af4cc46 100644 --- a/src/views/nodes/stashesNode.ts +++ b/src/views/nodes/stashesNode.ts @@ -7,14 +7,20 @@ import { View } from '../viewBase'; import { MessageNode } from './common'; import { StashNode } from './stashNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class StashesNode extends ViewNode { + static key = ':stashes'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + constructor(uri: GitUri, view: View, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } get id(): string { - return `gitlens:repository(${this.repo.path}):stashes`; + return StashesNode.getId(this.repo.path); } async getChildren(): Promise { diff --git a/src/views/nodes/statusFilesNode.ts b/src/views/nodes/statusFilesNode.ts index 08aeb45..b19da29 100644 --- a/src/views/nodes/statusFilesNode.ts +++ b/src/views/nodes/statusFilesNode.ts @@ -18,8 +18,14 @@ import { RepositoriesView } from '../repositoriesView'; import { FileNode, FolderNode } from './folderNode'; import { StatusFileNode } from './statusFileNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class StatusFilesNode extends ViewNode { + static key = ':status-files'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + readonly repoPath: string; constructor( @@ -33,7 +39,7 @@ export class StatusFilesNode extends ViewNode { } get id(): string { - return `gitlens:repository(${this.status.repoPath}):status:files`; + return StatusFilesNode.getId(this.status.repoPath); } async getChildren(): Promise { diff --git a/src/views/nodes/tagNode.ts b/src/views/nodes/tagNode.ts index 7d3d2db..8601e57 100644 --- a/src/views/nodes/tagNode.ts +++ b/src/views/nodes/tagNode.ts @@ -10,8 +10,14 @@ import { MessageNode, ShowMoreNode } from './common'; import { insertDateMarkers } from './helpers'; import { PageableViewNode, ResourceType, ViewNode, ViewRefNode } from './viewNode'; import { emojify } from '../../emojis'; +import { RepositoryNode } from './repositoryNode'; export class TagNode extends ViewRefNode implements PageableViewNode { + static key = ':tag'; + static getId(repoPath: string, name: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`; + } + readonly supportsPaging = true; readonly rememberLastMaxCount = true; maxCount: number | undefined = this.view.getNodeLastMaxCount(this); @@ -25,7 +31,7 @@ export class TagNode extends ViewRefNode implements PageableVi } get id(): string { - return `gitlens:repository(${this.tag.repoPath}):tag(${this.tag.name})`; + return TagNode.getId(this.tag.repoPath, this.tag.name); } get label(): string { diff --git a/src/views/nodes/tagsNode.ts b/src/views/nodes/tagsNode.ts index bfc54ee..e61e82a 100644 --- a/src/views/nodes/tagsNode.ts +++ b/src/views/nodes/tagsNode.ts @@ -9,14 +9,20 @@ import { BranchOrTagFolderNode } from './branchOrTagFolderNode'; import { MessageNode } from './common'; import { TagNode } from './tagNode'; import { ResourceType, ViewNode } from './viewNode'; +import { RepositoryNode } from './repositoryNode'; export class TagsNode extends ViewNode { + static key = ':tags'; + static getId(repoPath: string): string { + return `${RepositoryNode.getId(repoPath)}${this.key}`; + } + constructor(uri: GitUri, view: RepositoriesView, parent: ViewNode, public readonly repo: Repository) { super(uri, view, parent); } get id(): string { - return `gitlens:repository(${this.repo.path}):tags`; + return TagsNode.getId(this.repo.path); } async getChildren(): Promise {