From b208e51ebf0805abceeec60afac089737a9132d2 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 6 Jun 2018 01:32:49 -0400 Subject: [PATCH] Fixes #397 - Error while opening views using `Open View` command --- CHANGELOG.md | 1 + package.json | 68 ++++++++++++++++++++++---------------------- src/views/gitExplorer.ts | 23 +++++++++------ src/views/historyExplorer.ts | 27 ++++++++++++------ src/views/resultsExplorer.ts | 19 ++++++++----- 5 files changed, 80 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f873bf7..ae83279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - 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)) ### Fixed +- Fixes [#397](https://github.com/eamodio/vscode-gitlens/issues/397) - Error while opening the gitlens view using `Open View` command - Fixes [#391](https://github.com/eamodio/vscode-gitlens/issues/391) - GitLens adds some settings in settings.json - 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)) - 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)) diff --git a/package.json b/package.json index 4dc0dd1..f2de9d4 100644 --- a/package.json +++ b/package.json @@ -2560,127 +2560,127 @@ "view/title": [ { "command": "gitlens.showCommitSearch", - "when": "view == gitlens.gitExplorer", + "when": "view =~ /^gitlens.gitExplorer:/", "group": "navigation@1" }, { "command": "gitlens.gitExplorer.undockHistory", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && !gitlens:historyExplorer", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !gitlens:historyExplorer", "group": "navigation@2" }, { "command": "gitlens.gitExplorer.switchToHistoryView", - "when": "view == gitlens.gitExplorer && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository", + "when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository", "group": "navigation@3" }, { "command": "gitlens.gitExplorer.switchToRepositoryView", - "when": "view == gitlens.gitExplorer && !gitlens:historyExplorer && gitlens:gitExplorer:view == history", + "when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == history", "group": "navigation@3" }, { "command": "gitlens.gitExplorer.refresh", - "when": "view == gitlens.gitExplorer", + "when": "view =~ /^gitlens.gitExplorer:/", "group": "navigation@8" }, { "command": "gitlens.gitExplorer.setFilesLayoutToAuto", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository", "group": "1_gitlens" }, { "command": "gitlens.gitExplorer.setFilesLayoutToList", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository", "group": "1_gitlens" }, { "command": "gitlens.gitExplorer.setFilesLayoutToTree", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == repository", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository", "group": "1_gitlens" }, { "command": "gitlens.gitExplorer.setAutoRefreshToOn", - "when": "view == gitlens.gitExplorer && config.gitlens.gitExplorer.autoRefresh && !gitlens:gitExplorer:autoRefresh", + "when": "view =~ /^gitlens.gitExplorer:/ && config.gitlens.gitExplorer.autoRefresh && !gitlens:gitExplorer:autoRefresh", "group": "2_gitlens" }, { "command": "gitlens.gitExplorer.setAutoRefreshToOff", - "when": "view == gitlens.gitExplorer && config.gitlens.gitExplorer.autoRefresh && gitlens:gitExplorer:autoRefresh", + "when": "view =~ /^gitlens.gitExplorer:/ && config.gitlens.gitExplorer.autoRefresh && gitlens:gitExplorer:autoRefresh", "group": "2_gitlens" }, { "command": "gitlens.gitExplorer.setRenameFollowingOn", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames", "group": "2_gitlens_1" }, { "command": "gitlens.gitExplorer.setRenameFollowingOff", - "when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames", + "when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames", "group": "2_gitlens_1" }, { "command": "gitlens.historyExplorer.refresh", - "when": "view == gitlens.historyExplorer", + "when": "view =~ /^gitlens.historyExplorer:/", "group": "navigation@1" }, { "command": "gitlens.historyExplorer.dock", - "when": "view == gitlens.historyExplorer && gitlens:gitExplorer", + "when": "view =~ /^gitlens.historyExplorer:/ && gitlens:gitExplorer", "group": "navigation@9" }, { "command": "gitlens.historyExplorer.close", - "when": "view == gitlens.historyExplorer && !gitlens:gitExplorer", + "when": "view =~ /^gitlens.historyExplorer:/ && !gitlens:gitExplorer", "group": "navigation@9" }, { "command": "gitlens.historyExplorer.setRenameFollowingOn", - "when": "view == gitlens.historyExplorer && !config.gitlens.advanced.fileHistoryFollowsRenames", + "when": "view =~ /^gitlens.historyExplorer:/ && !config.gitlens.advanced.fileHistoryFollowsRenames", "group": "1_gitlens" }, { "command": "gitlens.historyExplorer.setRenameFollowingOff", - "when": "view == gitlens.historyExplorer && config.gitlens.advanced.fileHistoryFollowsRenames", + "when": "view =~ /^gitlens.historyExplorer:/ && config.gitlens.advanced.fileHistoryFollowsRenames", "group": "1_gitlens" }, { "command": "gitlens.showCommitSearch", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "navigation@1" }, { "command": "gitlens.resultsExplorer.setKeepResultsToOn", - "when": "view == gitlens.resultsExplorer && !gitlens:resultsExplorer:keepResults", + "when": "view =~ /^gitlens.resultsExplorer:/ && !gitlens:resultsExplorer:keepResults", "group": "navigation@2" }, { "command": "gitlens.resultsExplorer.setKeepResultsToOff", - "when": "view == gitlens.resultsExplorer && gitlens:resultsExplorer:keepResults", + "when": "view =~ /^gitlens.resultsExplorer:/ && gitlens:resultsExplorer:keepResults", "group": "navigation@2" }, { "command": "gitlens.resultsExplorer.refresh", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "navigation@3" }, { "command": "gitlens.resultsExplorer.close", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "navigation@9" }, { "command": "gitlens.resultsExplorer.setFilesLayoutToAuto", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "1_gitlens" }, { "command": "gitlens.resultsExplorer.setFilesLayoutToList", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "1_gitlens" }, { "command": "gitlens.resultsExplorer.setFilesLayoutToTree", - "when": "view == gitlens.resultsExplorer", + "when": "view =~ /^gitlens.resultsExplorer:/", "group": "1_gitlens" } ], @@ -2977,17 +2977,17 @@ }, { "command": "gitlens.gitExplorer.refreshNode", - "when": "view == gitlens.gitExplorer && viewItem =~ /gitlens:(?!file\\b)/", + "when": "view =~ /^gitlens.gitExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/", "group": "9_gitlens@1" }, { "command": "gitlens.resultsExplorer.refreshNode", - "when": "view == gitlens.resultsExplorer && viewItem =~ /gitlens:(?!file\\b)/", + "when": "view =~ /^gitlens.resultsExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/", "group": "9_gitlens@1" }, { "command": "gitlens.historyExplorer.refreshNode", - "when": "view == gitlens.historyExplorer && viewItem =~ /gitlens:(?!file\\b)/", + "when": "view =~ /^gitlens.historyExplorer:/ && viewItem =~ /gitlens:(?!file\\b)/", "group": "9_gitlens@1" } ] @@ -3180,34 +3180,34 @@ "views": { "explorer": [ { - "id": "gitlens.gitExplorer", + "id": "gitlens.gitExplorer:explorer", "name": "GitLens", "when": "gitlens:enabled && gitlens:gitExplorer == explorer" }, { - "id": "gitlens.historyExplorer", + "id": "gitlens.historyExplorer:explorer", "name": "GitLens History", "when": "gitlens:enabled && gitlens:historyExplorer == explorer" }, { - "id": "gitlens.resultsExplorer", + "id": "gitlens.resultsExplorer:explorer", "name": "GitLens Results", "when": "gitlens:enabled && gitlens:resultsExplorer == explorer" } ], "scm": [ { - "id": "gitlens.gitExplorer", + "id": "gitlens.gitExplorer:scm", "name": "GitLens", "when": "gitlens:enabled && gitlens:gitExplorer == scm" }, { - "id": "gitlens.historyExplorer", + "id": "gitlens.historyExplorer:scm", "name": "GitLens History", "when": "gitlens:enabled && gitlens:historyExplorer == scm" }, { - "id": "gitlens.resultsExplorer", + "id": "gitlens.resultsExplorer:scm", "name": "GitLens Results", "when": "gitlens:enabled && gitlens:resultsExplorer == scm" } diff --git a/src/views/gitExplorer.ts b/src/views/gitExplorer.ts index 73e6bc0..a7edc8a 100644 --- a/src/views/gitExplorer.ts +++ b/src/views/gitExplorer.ts @@ -99,18 +99,25 @@ export class GitExplorer extends Disposable implements TreeDataProvider(WorkspaceState.GitExplorerView, GitExplorerView.Repository); } + } - if (initializing) { - this.view = view; - setCommandContext(CommandContext.GitExplorerView, this.view); - - this.setRoot(await this.getRootNode(window.activeTextEditor)); + if (initializing) { + this.view = view; + setCommandContext(CommandContext.GitExplorerView, this.view); - this._tree = window.createTreeView('gitlens.gitExplorer', { treeDataProvider: this }); - this._disposable = this._tree; + this.setRoot(await this.getRootNode(window.activeTextEditor)); + } - return; + if (initializing || configuration.changed(e, configuration.name('gitExplorer')('location').value)) { + if (this._disposable) { + this._disposable.dispose(); + this._onDidChangeTreeData = new EventEmitter(); } + + this._tree = window.createTreeView(`gitlens.gitExplorer:${this.config.location}`, { treeDataProvider: this }); + this._disposable = this._tree; + + return; } this.reset(view!, configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value)); diff --git a/src/views/historyExplorer.ts b/src/views/historyExplorer.ts index 540a0f2..0c46d56 100644 --- a/src/views/historyExplorer.ts +++ b/src/views/historyExplorer.ts @@ -55,6 +55,12 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider(); + } - this._tree = window.createTreeView('gitlens.historyExplorer', { treeDataProvider: this }); + this._tree = window.createTreeView(`gitlens.historyExplorer:${this.config.location}`, { treeDataProvider: this }); this._disposable = this._tree; } + + if (!initializing && this._root === undefined) { + this.refresh(RefreshReason.ConfigurationChanged); + } } private async onActiveEditorChanged(editor: TextEditor | undefined) { diff --git a/src/views/resultsExplorer.ts b/src/views/resultsExplorer.ts index 291fe48..8652119 100644 --- a/src/views/resultsExplorer.ts +++ b/src/views/resultsExplorer.ts @@ -59,18 +59,23 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider(); + } - if (initializing) { - this._tree = window.createTreeView('gitlens.resultsExplorer', { treeDataProvider: this }); + this._tree = window.createTreeView(`gitlens.resultsExplorer:${this.config.location}`, { treeDataProvider: this }); this._disposable = this._tree; } + + if (!initializing && this._roots.length !== 0) { + this.refresh(RefreshReason.ConfigurationChanged); + } } get config(): IExplorersConfig & IResultsExplorerConfig {