Defers command construction until later

Gets a properly constructed commit to improve performance of opening the diff
This commit is contained in:
Eric Amodio
2017-06-14 02:04:59 -04:00
parent da450a614d
commit bc21272409
3 changed files with 32 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
'use strict';
import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitFileNode } from './commitFileNode';
import { ExplorerNode, ResourceType } from './explorerNode';
import { CommitFormatter, GitService, GitStashCommit, GitUri } from '../gitService';
@@ -7,25 +7,12 @@ import { CommitFormatter, GitService, GitStashCommit, GitUri } from '../gitServi
export class StashCommitNode extends ExplorerNode {
readonly resourceType: ResourceType = 'stash-commit';
command: Command;
constructor(public commit: GitStashCommit, uri: GitUri, context: ExtensionContext, git: GitService) {
super(uri, context, git);
// this.command = {
// title: 'Show Stash Details',
// command: Commands.ShowQuickCommitDetails,
// arguments: [
// new GitUri(commit.uri, commit),
// {
// commit: commit,
// sha: commit.sha
// } as ShowQuickCommitDetailsCommandArgs
// ]
// };
}
getChildren(): Promise<CommitFileNode[]> {
async getChildren(): Promise<CommitFileNode[]> {
return Promise.resolve((this.commit as GitStashCommit).fileStatuses.map(_ => new CommitFileNode(_, this.commit, this.uri, this.context, this.git)));
}
@@ -34,7 +21,17 @@ export class StashCommitNode extends ExplorerNode {
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.contextValue = this.resourceType;
item.command = this.command;
// item.command = {
// title: 'Show Stash Details',
// command: Commands.ShowQuickCommitDetails,
// arguments: [
// new GitUri(commit.uri, commit),
// {
// commit: this.commit,
// sha: this.commit.sha
// } as ShowQuickCommitDetailsCommandArgs
// ]
// };
return item;
}
}