Skip to content

Commit b208e51

Browse files
committed
Fixes #397 - Error while opening views using Open View command
1 parent d065379 commit b208e51

File tree

5 files changed

+80
-58
lines changed

5 files changed

+80
-58
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
- Adds clipboard support for Linux without requiring any external dependencies — thanks to [PR #394](https://github.com/eamodio/vscode-gitlens/pull/394) by Cédric Malard ([@cmalard](https://github.com/cmalard))
1010

1111
### Fixed
12+
- Fixes [#397](https://github.com/eamodio/vscode-gitlens/issues/397) - Error while opening the gitlens view using `Open View` command
1213
- Fixes [#391](https://github.com/eamodio/vscode-gitlens/issues/391) - GitLens adds some settings in settings.json
1314
- Fixes another case of [#343](https://github.com/eamodio/vscode-gitlens/issues/343) - Can't show blame when VSCode starts on branch without upstream — thanks to [PR #390](https://github.com/eamodio/vscode-gitlens/pull/390) by ryenus ([@ryenus](https://github.com/ryenus))
1415
- Fixes [#392](https://github.com/eamodio/vscode-gitlens/issues/392) - unable to contribute if default script shell is sh — thanks to [PR #393](https://github.com/eamodio/vscode-gitlens/pull/393) by Cédric Malard ([@cmalard](https://github.com/cmalard))

package.json

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,127 +2560,127 @@
25602560
"view/title": [
25612561
{
25622562
"command": "gitlens.showCommitSearch",
2563-
"when": "view == gitlens.gitExplorer",
2563+
"when": "view =~ /^gitlens.gitExplorer:/",
25642564
"group": "navigation@1"
25652565
},
25662566
{
25672567
"command": "gitlens.gitExplorer.undockHistory",
2568-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && !gitlens:historyExplorer",
2568+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !gitlens:historyExplorer",
25692569
"group": "navigation@2"
25702570
},
25712571
{
25722572
"command": "gitlens.gitExplorer.switchToHistoryView",
2573-
"when": "view == gitlens.gitExplorer && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository",
2573+
"when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository",
25742574
"group": "navigation@3"
25752575
},
25762576
{
25772577
"command": "gitlens.gitExplorer.switchToRepositoryView",
2578-
"when": "view == gitlens.gitExplorer && !gitlens:historyExplorer && gitlens:gitExplorer:view == history",
2578+
"when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == history",
25792579
"group": "navigation@3"
25802580
},
25812581
{
25822582
"command": "gitlens.gitExplorer.refresh",
2583-
"when": "view == gitlens.gitExplorer",
2583+
"when": "view =~ /^gitlens.gitExplorer:/",
25842584
"group": "navigation@8"
25852585
},
25862586
{
25872587
"command": "gitlens.gitExplorer.setFilesLayoutToAuto",
2588-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository",
2588+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
25892589
"group": "1_gitlens"
25902590
},
25912591
{
25922592
"command": "gitlens.gitExplorer.setFilesLayoutToList",
2593-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository",
2593+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
25942594
"group": "1_gitlens"
25952595
},
25962596
{
25972597
"command": "gitlens.gitExplorer.setFilesLayoutToTree",
2598-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository",
2598+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
25992599
"group": "1_gitlens"
26002600
},
26012601
{
26022602
"command": "gitlens.gitExplorer.setAutoRefreshToOn",
2603-
"when": "view == gitlens.gitExplorer && config.gitlens.gitExplorer.autoRefresh && !gitlens:gitExplorer:autoRefresh",
2603+
"when": "view =~ /^gitlens.gitExplorer:/ && config.gitlens.gitExplorer.autoRefresh && !gitlens:gitExplorer:autoRefresh",
26042604
"group": "2_gitlens"
26052605
},
26062606
{
26072607
"command": "gitlens.gitExplorer.setAutoRefreshToOff",
2608-
"when": "view == gitlens.gitExplorer && config.gitlens.gitExplorer.autoRefresh && gitlens:gitExplorer:autoRefresh",
2608+
"when": "view =~ /^gitlens.gitExplorer:/ && config.gitlens.gitExplorer.autoRefresh && gitlens:gitExplorer:autoRefresh",
26092609
"group": "2_gitlens"
26102610
},
26112611
{
26122612
"command": "gitlens.gitExplorer.setRenameFollowingOn",
2613-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames",
2613+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames",
26142614
"group": "2_gitlens_1"
26152615
},
26162616
{
26172617
"command": "gitlens.gitExplorer.setRenameFollowingOff",
2618-
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames",
2618+
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames",
26192619
"group": "2_gitlens_1"
26202620
},
26212621
{
26222622
"command": "gitlens.historyExplorer.refresh",
2623-
"when": "view == gitlens.historyExplorer",
2623+
"when": "view =~ /^gitlens.historyExplorer:/",
26242624
"group": "navigation@1"
26252625
},
26262626
{
26272627
"command": "gitlens.historyExplorer.dock",
2628-
"when": "view == gitlens.historyExplorer && gitlens:gitExplorer",
2628+
"when": "view =~ /^gitlens.historyExplorer:/ && gitlens:gitExplorer",
26292629
"group": "navigation@9"
26302630
},
26312631
{
26322632
"command": "gitlens.historyExplorer.close",
2633-
"when": "view == gitlens.historyExplorer && !gitlens:gitExplorer",
2633+
"when": "view =~ /^gitlens.historyExplorer:/ && !gitlens:gitExplorer",
26342634
"group": "navigation@9"
26352635
},
26362636
{
26372637
"command": "gitlens.historyExplorer.setRenameFollowingOn",
2638-
"when": "view == gitlens.historyExplorer && !config.gitlens.advanced.fileHistoryFollowsRenames",
2638+
"when": "view =~ /^gitlens.historyExplorer:/ && !config.gitlens.advanced.fileHistoryFollowsRenames",
26392639
"group": "1_gitlens"
26402640
},
26412641
{
26422642
"command": "gitlens.historyExplorer.setRenameFollowingOff",
2643-
"when": "view == gitlens.historyExplorer && config.gitlens.advanced.fileHistoryFollowsRenames",
2643+
"when": "view =~ /^gitlens.historyExplorer:/ && config.gitlens.advanced.fileHistoryFollowsRenames",
26442644
"group": "1_gitlens"
26452645
},
26462646
{
26472647
"command": "gitlens.showCommitSearch",
2648-
"when": "view == gitlens.resultsExplorer",
2648+
"when": "view =~ /^gitlens.resultsExplorer:/",
26492649
"group": "navigation@1"
26502650
},
26512651
{
26522652
"command": "gitlens.resultsExplorer.setKeepResultsToOn",
2653-
"when": "view == gitlens.resultsExplorer && !gitlens:resultsExplorer:keepResults",
2653+
"when": "view =~ /^gitlens.resultsExplorer:/ && !gitlens:resultsExplorer:keepResults",
26542654
"group": "navigation@2"
26552655
},
26562656
{
26572657
"command": "gitlens.resultsExplorer.setKeepResultsToOff",
2658-
"when": "view == gitlens.resultsExplorer && gitlens:resultsExplorer:keepResults",
2658+
"when": "view =~ /^gitlens.resultsExplorer:/ && gitlens:resultsExplorer:keepResults",
26592659
"group": "navigation@2"
26602660
},
26612661
{
26622662
"command": "gitlens.resultsExplorer.refresh",
2663-
"when": "view == gitlens.resultsExplorer",
2663+
"when": "view =~ /^gitlens.resultsExplorer:/",
26642664
"group": "navigation@3"
26652665
},
26662666
{
26672667
"command": "gitlens.resultsExplorer.close",
2668-
"when": "view == gitlens.resultsExplorer",
2668+
"when": "view =~ /^gitlens.resultsExplorer:/",
26692669
"group": "navigation@9"
26702670
},
26712671
{
26722672
"command": "gitlens.resultsExplorer.setFilesLayoutToAuto",
2673-
"when": "view == gitlens.resultsExplorer",
2673+
"when": "view =~ /^gitlens.resultsExplorer:/",
26742674
"group": "1_gitlens"
26752675
},
26762676
{
26772677
"command": "gitlens.resultsExplorer.setFilesLayoutToList",
2678-
"when": "view == gitlens.resultsExplorer",
2678+
"when": "view =~ /^gitlens.resultsExplorer:/",
26792679
"group": "1_gitlens"
26802680
},
26812681
{
26822682
"command": "gitlens.resultsExplorer.setFilesLayoutToTree",
2683-
"when": "view == gitlens.resultsExplorer",
2683+
"when": "view =~ /^gitlens.resultsExplorer:/",
26842684
"group": "1_gitlens"
26852685
}
26862686
],
@@ -2977,17 +2977,17 @@
29772977
},
29782978
{
29792979
"command": "gitlens.gitExplorer.refreshNode",
2980-
"when": "view == gitlens.gitExplorer && viewItem =~ /gitlens:(?!file\\b)/",
2980+
"when": "view =~ /^gitlens.gitExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/",
29812981
"group": "9_gitlens@1"
29822982
},
29832983
{
29842984
"command": "gitlens.resultsExplorer.refreshNode",
2985-
"when": "view == gitlens.resultsExplorer && viewItem =~ /gitlens:(?!file\\b)/",
2985+
"when": "view =~ /^gitlens.resultsExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/",
29862986
"group": "9_gitlens@1"
29872987
},
29882988
{
29892989
"command": "gitlens.historyExplorer.refreshNode",
2990-
"when": "view == gitlens.historyExplorer && viewItem =~ /gitlens:(?!file\\b)/",
2990+
"when": "view =~ /^gitlens.historyExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/",
29912991
"group": "9_gitlens@1"
29922992
}
29932993
]
@@ -3180,34 +3180,34 @@
31803180
"views": {
31813181
"explorer": [
31823182
{
3183-
"id": "gitlens.gitExplorer",
3183+
"id": "gitlens.gitExplorer:explorer",
31843184
"name": "GitLens",
31853185
"when": "gitlens:enabled && gitlens:gitExplorer == explorer"
31863186
},
31873187
{
3188-
"id": "gitlens.historyExplorer",
3188+
"id": "gitlens.historyExplorer:explorer",
31893189
"name": "GitLens History",
31903190
"when": "gitlens:enabled && gitlens:historyExplorer == explorer"
31913191
},
31923192
{
3193-
"id": "gitlens.resultsExplorer",
3193+
"id": "gitlens.resultsExplorer:explorer",
31943194
"name": "GitLens Results",
31953195
"when": "gitlens:enabled && gitlens:resultsExplorer == explorer"
31963196
}
31973197
],
31983198
"scm": [
31993199
{
3200-
"id": "gitlens.gitExplorer",
3200+
"id": "gitlens.gitExplorer:scm",
32013201
"name": "GitLens",
32023202
"when": "gitlens:enabled && gitlens:gitExplorer == scm"
32033203
},
32043204
{
3205-
"id": "gitlens.historyExplorer",
3205+
"id": "gitlens.historyExplorer:scm",
32063206
"name": "GitLens History",
32073207
"when": "gitlens:enabled && gitlens:historyExplorer == scm"
32083208
},
32093209
{
3210-
"id": "gitlens.resultsExplorer",
3210+
"id": "gitlens.resultsExplorer:scm",
32113211
"name": "GitLens Results",
32123212
"when": "gitlens:enabled && gitlens:resultsExplorer == scm"
32133213
}

src/views/gitExplorer.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,25 @@ export class GitExplorer extends Disposable implements TreeDataProvider<Explorer
9999
if (view === GitExplorerView.Auto) {
100100
view = Container.context.workspaceState.get<GitExplorerView>(WorkspaceState.GitExplorerView, GitExplorerView.Repository);
101101
}
102+
}
102103

103-
if (initializing) {
104-
this.view = view;
105-
setCommandContext(CommandContext.GitExplorerView, this.view);
106-
107-
this.setRoot(await this.getRootNode(window.activeTextEditor));
104+
if (initializing) {
105+
this.view = view;
106+
setCommandContext(CommandContext.GitExplorerView, this.view);
108107

109-
this._tree = window.createTreeView('gitlens.gitExplorer', { treeDataProvider: this });
110-
this._disposable = this._tree;
108+
this.setRoot(await this.getRootNode(window.activeTextEditor));
109+
}
111110

112-
return;
111+
if (initializing || configuration.changed(e, configuration.name('gitExplorer')('location').value)) {
112+
if (this._disposable) {
113+
this._disposable.dispose();
114+
this._onDidChangeTreeData = new EventEmitter<ExplorerNode>();
113115
}
116+
117+
this._tree = window.createTreeView(`gitlens.gitExplorer:${this.config.location}`, { treeDataProvider: this });
118+
this._disposable = this._tree;
119+
120+
return;
114121
}
115122

116123
this.reset(view!, configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value));

src/views/historyExplorer.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider<Expl
5555
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value) &&
5656
!configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value)) return;
5757

58+
if (initializing ||
59+
configuration.changed(e, configuration.name('historyExplorer')('enabled').value) ||
60+
configuration.changed(e, configuration.name('historyExplorer')('location').value)) {
61+
setCommandContext(CommandContext.HistoryExplorer, this.config.enabled ? this.config.location : false);
62+
}
63+
5864
if (initializing || configuration.changed(e, configuration.name('historyExplorer')('enabled').value)) {
5965
if (this.config.enabled) {
6066
this.undock(!initializing, !configuration.changed(e, configuration.name('mode').value));
@@ -64,20 +70,23 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider<Expl
6470
}
6571
}
6672

67-
if (!initializing && configuration.changed(e, configuration.name('historyExplorer')('location').value) && this.config.enabled) {
68-
setCommandContext(CommandContext.HistoryExplorer, this.config.location);
69-
}
70-
71-
if (!initializing && this._root === undefined) {
72-
this.refresh(RefreshReason.ConfigurationChanged);
73-
}
74-
7573
if (initializing) {
7674
this.setRoot(await this.getRootNode(window.activeTextEditor));
75+
}
76+
77+
if (initializing || configuration.changed(e, configuration.name('historyExplorer')('location').value)) {
78+
if (this._disposable) {
79+
this._disposable.dispose();
80+
this._onDidChangeTreeData = new EventEmitter<ExplorerNode>();
81+
}
7782

78-
this._tree = window.createTreeView('gitlens.historyExplorer', { treeDataProvider: this });
83+
this._tree = window.createTreeView(`gitlens.historyExplorer:${this.config.location}`, { treeDataProvider: this });
7984
this._disposable = this._tree;
8085
}
86+
87+
if (!initializing && this._root === undefined) {
88+
this.refresh(RefreshReason.ConfigurationChanged);
89+
}
8190
}
8291

8392
private async onActiveEditorChanged(editor: TextEditor | undefined) {

src/views/resultsExplorer.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider<Expl
5959
!configuration.changed(e, configuration.name('explorers').value) &&
6060
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value)) return;
6161

62-
if (!initializing && configuration.changed(e, configuration.name('resultsExplorer')('location').value) && this.enabled) {
63-
setCommandContext(CommandContext.ResultsExplorer, this.config.location);
62+
if (initializing || configuration.changed(e, configuration.name('resultsExplorer')('location').value)) {
63+
setCommandContext(CommandContext.ResultsExplorer, this.enabled ? this.config.location : false);
6464
}
6565

66-
if (!initializing && this._roots.length !== 0) {
67-
this.refresh(RefreshReason.ConfigurationChanged);
68-
}
66+
if (initializing || configuration.changed(e, configuration.name('resultsExplorer')('location').value)) {
67+
if (this._disposable) {
68+
this._disposable.dispose();
69+
this._onDidChangeTreeData = new EventEmitter<ExplorerNode>();
70+
}
6971

70-
if (initializing) {
71-
this._tree = window.createTreeView('gitlens.resultsExplorer', { treeDataProvider: this });
72+
this._tree = window.createTreeView(`gitlens.resultsExplorer:${this.config.location}`, { treeDataProvider: this });
7273
this._disposable = this._tree;
7374
}
75+
76+
if (!initializing && this._roots.length !== 0) {
77+
this.refresh(RefreshReason.ConfigurationChanged);
78+
}
7479
}
7580

7681
get config(): IExplorersConfig & IResultsExplorerConfig {

0 commit comments

Comments
 (0)