Ver código fonte

Fixes active repo tracking in explorer

Fixes status node updates in explorer
main
Eric Amodio 6 anos atrás
pai
commit
1255803b6c
5 arquivos alterados com 34 adições e 6 exclusões
  1. +7
    -1
      src/views/activeRepositoryNode.ts
  2. +5
    -0
      src/views/repositoryNode.ts
  3. +7
    -1
      src/views/statusFilesNode.ts
  4. +8
    -3
      src/views/statusNode.ts
  5. +7
    -1
      src/views/statusUpstreamNode.ts

+ 7
- 1
src/views/activeRepositoryNode.ts Ver arquivo

@ -33,6 +33,10 @@ export class ActiveRepositoryNode extends ExplorerNode {
}
}
get id(): string {
return 'gitlens:repository:active';
}
private async onActiveEditorChanged(editor: TextEditor | undefined) {
if (editor !== undefined && !isTextEditor(editor)) return;
@ -86,8 +90,10 @@ export class ActiveRepositoryNode extends ExplorerNode {
}
getTreeItem(): TreeItem {
return this._repositoryNode !== undefined
const item = this._repositoryNode !== undefined
? this._repositoryNode.getTreeItem()
: new TreeItem('No active repository', TreeItemCollapsibleState.None);
item.id = this.id;
return item;
}
}

+ 5
- 0
src/views/repositoryNode.ts Ver arquivo

@ -23,6 +23,10 @@ export class RepositoryNode extends ExplorerNode {
super(uri);
}
get id(): string {
return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}`;
}
async getChildren(): Promise<ExplorerNode[]> {
this.resetChildren();
this.updateSubscription();
@ -45,6 +49,7 @@ export class RepositoryNode extends ExplorerNode {
: `${this.repo.formattedName || this.uri.repoPath}`;
const item = new TreeItem(label, this.active ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed);
item.id = this.id;
item.contextValue = ResourceType.Repository;
return item;
}

+ 7
- 1
src/views/statusFilesNode.ts Ver arquivo

@ -18,12 +18,17 @@ export class StatusFilesNode extends ExplorerNode {
constructor(
public readonly status: GitStatus,
public readonly range: string | undefined,
private readonly explorer: GitExplorer
private readonly explorer: GitExplorer,
private readonly active: boolean = false
) {
super(GitUri.fromRepoPath(status.repoPath));
this.repoPath = status.repoPath;
}
get id(): string {
return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:files`;
}
async getChildren(): Promise<ExplorerNode[]> {
let statuses: IGitStatusFileWithCommit[] = [];
@ -119,6 +124,7 @@ export class StatusFilesNode extends ExplorerNode {
const label = `${files} file${files > 1 ? 's' : ''} changed`; // ${this.status.upstream === undefined ? '' : ` (ahead of ${this.status.upstream})`}`;
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.id = this.id;
item.contextValue = ResourceType.StatusFiles;
item.iconPath = {
dark: Container.context.asAbsolutePath(`images/dark/icon-diff.svg`),

+ 8
- 3
src/views/statusNode.ts Ver arquivo

@ -17,6 +17,10 @@ export class StatusNode extends ExplorerNode {
super(uri);
}
get id(): string {
return `gitlens:repository(${this.repo.path})${this.active ? ':active' : ''}:status`;
}
async getChildren(): Promise<ExplorerNode[]> {
this.resetChildren();
@ -26,18 +30,18 @@ export class StatusNode extends ExplorerNode {
this.children = [];
if (status.state.behind) {
this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer));
this.children.push(new StatusUpstreamNode(status, 'behind', this.explorer, this.active));
}
if (status.state.ahead) {
this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer));
this.children.push(new StatusUpstreamNode(status, 'ahead', this.explorer, this.active));
}
if (status.state.ahead || (status.files.length !== 0 && this.includeWorkingTree)) {
const range = status.upstream
? `${status.upstream}..${status.branch}`
: undefined;
this.children.push(new StatusFilesNode(status, range, this.explorer));
this.children.push(new StatusFilesNode(status, range, this.explorer, this.active));
}
return this.children;
@ -99,6 +103,7 @@ export class StatusNode extends ExplorerNode {
}
const item = new TreeItem(label, state);
item.id = this.id;
item.contextValue = ResourceType.Status;
item.iconPath = {

+ 7
- 1
src/views/statusUpstreamNode.ts Ver arquivo

@ -11,11 +11,16 @@ export class StatusUpstreamNode extends ExplorerNode {
constructor(
public readonly status: GitStatus,
public readonly direction: 'ahead' | 'behind',
private readonly explorer: Explorer
private readonly explorer: Explorer,
private readonly active: boolean = false
) {
super(GitUri.fromRepoPath(status.repoPath));
}
get id(): string {
return `gitlens:repository(${this.status.repoPath})${this.active ? ':active' : ''}:status:upstream`;
}
async getChildren(): Promise<ExplorerNode[]> {
const range = this.direction === 'ahead'
? `${this.status.upstream}..${this.status.branch}`
@ -45,6 +50,7 @@ export class StatusUpstreamNode extends ExplorerNode {
: `${this.status.state.behind} commit${this.status.state.behind > 1 ? 's' : ''} (behind ${this.status.upstream})`;
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.id = this.id;
item.contextValue = ResourceType.StatusUpstream;
item.iconPath = {

Carregando…
Cancelar
Salvar