Browse Source

Fixes #607 - adds more uniqueness to view node ids

main
Eric Amodio 5 years ago
parent
commit
c904f99f12
14 changed files with 33 additions and 17 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +5
    -3
      src/views/nodes/branchNode.ts
  3. +1
    -1
      src/views/nodes/branchOrTagFolderNode.ts
  4. +1
    -1
      src/views/nodes/branchTrackingStatusNode.ts
  5. +1
    -1
      src/views/nodes/branchesNode.ts
  6. +1
    -1
      src/views/nodes/remoteNode.ts
  7. +1
    -1
      src/views/nodes/remotesNode.ts
  8. +4
    -3
      src/views/nodes/repositoryNode.ts
  9. +1
    -1
      src/views/nodes/stashNode.ts
  10. +1
    -1
      src/views/nodes/stashesNode.ts
  11. +1
    -1
      src/views/nodes/statusFilesNode.ts
  12. +1
    -1
      src/views/nodes/tagNode.ts
  13. +1
    -1
      src/views/nodes/tagsNode.ts
  14. +13
    -1
      src/views/nodes/viewNode.ts

+ 1
- 0
CHANGELOG.md View File

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#606](https://github.com/eamodio/vscode-gitlens/issues/606) - ID for xxx is already registered?!
- Fixes [#607](https://github.com/eamodio/vscode-gitlens/issues/607) - Open file in Remote Doesn't URL encode
## [9.3.0] - 2019-01-02

+ 5
- 3
src/views/nodes/branchNode.ts View File

@ -30,9 +30,11 @@ 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 `${this._instanceId}:gitlens:repository(${this.branch.repoPath})${this._root ? ':root:' : ''}:branch(${
this.branch.name
})${this.branch.current ? '+current:' : ''}${this.branch.remote ? '+remote' : ''}${
this.branch.starred ? '+starred:' : ''
}`;
}
get current(): boolean {

+ 1
- 1
src/views/nodes/branchOrTagFolderNode.ts View File

@ -24,7 +24,7 @@ export class BranchOrTagFolderNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repoPath}):${this.type}-folder(${this.relativePath})`;
return `${this._instanceId}:gitlens:repository(${this.repoPath}):${this.type}-folder(${this.relativePath})`;
}
async getChildren(): Promise<ViewNode[]> {

+ 1
- 1
src/views/nodes/branchTrackingStatusNode.ts View File

@ -32,7 +32,7 @@ export class BranchTrackingStatusNode extends ViewNode implements
}
get id(): string {
return `gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${
return `${this._instanceId}:gitlens:repository(${this.status.repoPath}):${this._root ? 'root:' : ''}branch(${
this.status.ref
}):status:upstream:(${this.status.upstream}):${this.direction}`;
}

+ 1
- 1
src/views/nodes/branchesNode.ts View File

@ -22,7 +22,7 @@ export class BranchesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path}):branches`;
return `${this._instanceId}:gitlens:repository(${this.repo.path}):branches`;
}
async getChildren(): Promise<ViewNode[]> {

+ 1
- 1
src/views/nodes/remoteNode.ts View File

@ -22,7 +22,7 @@ export class RemoteNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.remote.repoPath}):remote(${this.remote.name})`;
return `${this._instanceId}:gitlens:repository(${this.remote.repoPath}):remote(${this.remote.name})`;
}
async getChildren(): Promise<ViewNode[]> {

+ 1
- 1
src/views/nodes/remotesNode.ts View File

@ -19,7 +19,7 @@ export class RemotesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path}):remotes`;
return `${this._instanceId}:gitlens:repository(${this.repo.path}):remotes`;
}
async getChildren(): Promise<ViewNode[]> {

+ 4
- 3
src/views/nodes/repositoryNode.ts View File

@ -41,7 +41,7 @@ export class RepositoryNode extends SubscribeableViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path})${this.repo.starred ? '+starred:' : ''}`;
return `${this._instanceId}:gitlens:repository(${this.repo.path})${this.repo.starred ? '+starred:' : ''}`;
}
async getChildren(): Promise<ViewNode[]> {
@ -238,9 +238,10 @@ export class RepositoryNode extends SubscribeableViewNode {
@debug({
args: {
0: (e: RepositoryFileSystemChangeEvent) =>
`{ repository: ${e.repository ? e.repository.name : ''}, uris: [${e.uris
`{ repository: ${e.repository ? e.repository.name : ''}, uris(${e.uris.length}): [${e.uris
.slice(0, 1)
.map(u => u.fsPath)
.join(', ')}] }`
.join(', ')}${e.uris.length > 1 ? ', ...' : ''}] }`
}
})
private onFileSystemChanged(e: RepositoryFileSystemChangeEvent) {

+ 1
- 1
src/views/nodes/stashNode.ts View File

@ -17,7 +17,7 @@ export class StashNode extends ViewRefNode {
}
get id(): string {
return `gitlens:repository(${this.commit.repoPath}):stash(${this.commit.sha})`;
return `${this._instanceId}:gitlens:repository(${this.commit.repoPath}):stash(${this.commit.sha})`;
}
get ref(): string {

+ 1
- 1
src/views/nodes/stashesNode.ts View File

@ -19,7 +19,7 @@ export class StashesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path}):stashes`;
return `${this._instanceId}:gitlens:repository(${this.repo.path}):stashes`;
}
async getChildren(): Promise<ViewNode[]> {

+ 1
- 1
src/views/nodes/statusFilesNode.ts View File

@ -33,7 +33,7 @@ export class StatusFilesNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.status.repoPath}):status:files`;
return `${this._instanceId}:gitlens:repository(${this.status.repoPath}):status:files`;
}
async getChildren(): Promise<ViewNode[]> {

+ 1
- 1
src/views/nodes/tagNode.ts View File

@ -24,7 +24,7 @@ export class TagNode extends ViewRefNode implements PageableVi
}
get id(): string {
return `gitlens:repository(${this.tag.repoPath}):tag(${this.tag.name})`;
return `${this._instanceId}:gitlens:repository(${this.tag.repoPath}):tag(${this.tag.name})`;
}
get label(): string {

+ 1
- 1
src/views/nodes/tagsNode.ts View File

@ -21,7 +21,7 @@ export class TagsNode extends ViewNode {
}
get id(): string {
return `gitlens:repository(${this.repo.path}):tags`;
return `${this._instanceId}:gitlens:repository(${this.repo.path}):tags`;
}
async getChildren(): Promise<ViewNode[]> {

+ 13
- 1
src/views/nodes/viewNode.ts View File

@ -51,13 +51,25 @@ export interface ViewNode {
readonly id?: string;
}
@logName<ViewNode>((c, name) => `${name}${c.id ? `(${c.id})` : ''}`)
let counter = 0;
function getViewNodeInstanceId() {
if (counter === Number.MAX_SAFE_INTEGER) {
counter = 0;
}
counter++;
return counter;
}
@logName<ViewNode>((c, name) => `${name}(${c.id || c._instanceId})`)
export abstract class ViewNode<TView extends View = View> {
protected readonly _instanceId: number;
constructor(
uri: GitUri,
public readonly view: TView,
protected readonly parent?: ViewNode
) {
this._instanceId = getViewNodeInstanceId();
this._uri = uri;
}

Loading…
Cancel
Save