mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds Refresh command to most custom view items
Updates custom view when repo changes (brute force for now)
This commit is contained in:
@@ -1611,6 +1611,11 @@
|
|||||||
"command": "gitlens.showQuickFileHistory",
|
"command": "gitlens.showQuickFileHistory",
|
||||||
"when": "gitlens:isTracked && view == gitlens.gitExplorer && viewItem == gitlens:stash-file",
|
"when": "gitlens:isTracked && view == gitlens.gitExplorer && viewItem == gitlens:stash-file",
|
||||||
"group": "5_gitlens@1"
|
"group": "5_gitlens@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.gitExplorer.refresh",
|
||||||
|
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem != gitlens:commit-file && viewItem != gitlens:stash-file",
|
||||||
|
"group": "9_gitlens@1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ export const GitRepoSearchBy = {
|
|||||||
Sha: 'sha' as GitRepoSearchBy
|
Sha: 'sha' as GitRepoSearchBy
|
||||||
};
|
};
|
||||||
|
|
||||||
type RepoChangedReasons = 'stash' | 'unknown';
|
export type RepoChangedReasons = 'stash' | 'unknown';
|
||||||
|
export const RepoChangedReasons = {
|
||||||
|
Stash: 'stash' as RepoChangedReasons,
|
||||||
|
Unknown: 'unknown' as RepoChangedReasons
|
||||||
|
};
|
||||||
|
|
||||||
export class GitService extends Disposable {
|
export class GitService extends Disposable {
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Commands, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, open
|
|||||||
import { UriComparer } from '../comparers';
|
import { UriComparer } from '../comparers';
|
||||||
import { CommandContext, setCommandContext } from '../constants';
|
import { CommandContext, setCommandContext } from '../constants';
|
||||||
import { CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoryNode, StashNode } from './explorerNodes';
|
import { CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoryNode, StashNode } from './explorerNodes';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri, RepoChangedReasons } from '../gitService';
|
||||||
|
|
||||||
export * from './explorerNodes';
|
export * from './explorerNodes';
|
||||||
|
|
||||||
@@ -45,6 +45,8 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this);
|
commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this);
|
||||||
|
|
||||||
|
context.subscriptions.push(this.git.onDidChangeRepo(this.onRepoChanged, this));
|
||||||
|
|
||||||
const fn = Functions.debounce(this.onActiveEditorChanged, 500);
|
const fn = Functions.debounce(this.onActiveEditorChanged, 500);
|
||||||
context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this));
|
context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this));
|
||||||
|
|
||||||
@@ -90,15 +92,26 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
|
|
||||||
private onActiveEditorChanged(editor: TextEditor | undefined) {
|
private onActiveEditorChanged(editor: TextEditor | undefined) {
|
||||||
if (this._view !== GitExplorerView.History) return;
|
if (this._view !== GitExplorerView.History) return;
|
||||||
|
|
||||||
const root = this.getRootNode(editor);
|
const root = this.getRootNode(editor);
|
||||||
if (root === this._root) return;
|
if (root === this._root) return;
|
||||||
|
|
||||||
this.refresh(root);
|
this._root = root;
|
||||||
|
this.refresh(undefined, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh(root?: ExplorerNode) {
|
private onRepoChanged(reasons: RepoChangedReasons[]) {
|
||||||
this._root = root || this.getRootNode();
|
if (this._view !== GitExplorerView.Repository) return;
|
||||||
this._onDidChangeTreeData.fire();
|
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh(node?: ExplorerNode, root?: ExplorerNode) {
|
||||||
|
if (root === undefined && this._view === GitExplorerView.History) {
|
||||||
|
this._root = this.getRootNode(window.activeTextEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._onDidChangeTreeData.fire(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
switchTo(view: GitExplorerView) {
|
switchTo(view: GitExplorerView) {
|
||||||
@@ -107,7 +120,7 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
this._view = view;
|
this._view = view;
|
||||||
setCommandContext(CommandContext.GitExplorerView, this._view);
|
setCommandContext(CommandContext.GitExplorerView, this._view);
|
||||||
|
|
||||||
this._root = undefined;
|
this._root = this.getRootNode(window.activeTextEditor);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user