Skip to content

Commit c98755c

Browse files
committed
Adds refresh of custom view on settings change
1 parent 6d759da commit c98755c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/views/gitExplorer.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
2-
import { Functions } from '../system';
3-
import { commands, Event, EventEmitter, ExtensionContext, TextDocumentShowOptions, TextEditor, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
2+
import { Functions, Objects } from '../system';
3+
import { commands, Event, EventEmitter, ExtensionContext, TextDocumentShowOptions, TextEditor, TreeDataProvider, TreeItem, Uri, window, workspace } from 'vscode';
44
import { Commands, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands';
55
import { UriComparer } from '../comparers';
6+
import { ExtensionKey, IConfig } from '../configuration';
67
import { CommandContext, setCommandContext } from '../constants';
78
import { CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoryNode, StashNode } from './explorerNodes';
89
import { GitService, GitUri, RepoChangedReasons } from '../gitService';
@@ -24,6 +25,7 @@ export interface OpenFileRevisionCommandArgs {
2425

2526
export class GitExplorer implements TreeDataProvider<ExplorerNode> {
2627

28+
private _config: IConfig;
2729
private _root?: ExplorerNode;
2830
private _view: GitExplorerView = GitExplorerView.Repository;
2931

@@ -49,8 +51,11 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
4951

5052
const fn = Functions.debounce(this.onActiveEditorChanged, 500);
5153
context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this));
54+
context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
5255

53-
this._view = this.git.config.gitExplorer.view;
56+
this.onConfigurationChanged();
57+
58+
this._view = this._config.gitExplorer.view;
5459
setCommandContext(CommandContext.GitExplorerView, this._view);
5560
this._root = this.getRootNode();
5661
}
@@ -100,6 +105,19 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
100105
this.refresh(undefined, root);
101106
}
102107

108+
private onConfigurationChanged() {
109+
const cfg = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
110+
111+
if (!Objects.areEquivalent(cfg.gitExplorer, this._config && this._config.gitExplorer)) {
112+
setTimeout(() => {
113+
this._root = this.getRootNode(window.activeTextEditor);
114+
this.refresh();
115+
}, 1);
116+
}
117+
118+
this._config = cfg;
119+
}
120+
103121
private onRepoChanged(reasons: RepoChangedReasons[]) {
104122
if (this._view !== GitExplorerView.Repository) return;
105123

0 commit comments

Comments
 (0)