mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-13 11:38:40 -05:00
WIP of Stash Explorer commands
# Conflicts: # src/commands/stashApply.ts
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
import { ExtensionContext, TreeItem } from 'vscode';
|
||||
import { Event, ExtensionContext, TreeItem} from 'vscode';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
|
||||
export declare type ResourceType = 'status' | 'branches' | 'repository' | 'branch-history' | 'file-history' | 'stash-history' | 'commit' | 'stash-commit' | 'commit-file';
|
||||
|
||||
export abstract class ExplorerNode {
|
||||
@@ -12,4 +11,7 @@ export abstract class ExplorerNode {
|
||||
|
||||
abstract getChildren(): ExplorerNode[] | Promise<ExplorerNode[]>;
|
||||
abstract getTreeItem(): TreeItem | Promise<TreeItem>;
|
||||
|
||||
onDidChangeTreeData?: Event<ExplorerNode>;
|
||||
refreshNode?(): void;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||
import { Event, EventEmitter, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||
import { CommitFileNode } from './commitFileNode';
|
||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||
import { CommitFormatter, GitService, GitStashCommit, GitUri } from '../gitService';
|
||||
@@ -8,6 +8,15 @@ export class StashCommitNode extends ExplorerNode {
|
||||
|
||||
readonly resourceType: ResourceType = 'stash-commit';
|
||||
|
||||
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
||||
public get onDidChangeTreeData(): Event<ExplorerNode> {
|
||||
return this._onDidChangeTreeData.event;
|
||||
}
|
||||
|
||||
public refreshNode() {
|
||||
this._onDidChangeTreeData.fire();
|
||||
}
|
||||
|
||||
constructor(public readonly commit: GitStashCommit, context: ExtensionContext, git: GitService) {
|
||||
super(new GitUri(commit.uri, commit), context, git);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri } from 'vscode';
|
||||
import { ExplorerNode, StashNode } from './explorerNodes';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { StashCommitNode } from './stashCommitNode';
|
||||
|
||||
export * from './explorerNodes';
|
||||
|
||||
@@ -10,7 +9,7 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
|
||||
private _node: ExplorerNode;
|
||||
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
||||
public get onDidChangeTreeData(): Event<StashCommitNode> {
|
||||
public get onDidChangeTreeData(): Event<ExplorerNode> {
|
||||
return this._onDidChangeTreeData.event;
|
||||
}
|
||||
|
||||
@@ -28,6 +27,11 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
}
|
||||
|
||||
async getTreeItem(node: ExplorerNode): Promise<TreeItem> {
|
||||
if (node.onDidChangeTreeData) {
|
||||
node.onDidChangeTreeData(() => {
|
||||
this._onDidChangeTreeData.fire();
|
||||
});
|
||||
}
|
||||
return node.getTreeItem();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user