From f6f0fd48bc73f3d3c4470b2d52b67d0c6d507962 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 27 Oct 2018 23:51:00 -0400 Subject: [PATCH] Fixes showing views --- src/views/fileHistoryView.ts | 4 ++++ src/views/lineHistoryView.ts | 4 ++++ src/views/repositoriesView.ts | 4 ++++ src/views/resultsView.ts | 4 ++++ src/views/viewBase.ts | 14 +++++++------- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 06c3d89..78edee5 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -16,6 +16,10 @@ export class FileHistoryView extends ViewBase { return new FileHistoryTrackerNode(this); } + protected get location(): string { + return this.config.location; + } + protected registerCommands() { Container.viewCommands; commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this); diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index 9ee42d3..ad26816 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -16,6 +16,10 @@ export class LineHistoryView extends ViewBase { return new LineHistoryTrackerNode(this); } + protected get location(): string { + return this.config.location; + } + protected registerCommands() { Container.viewCommands; commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this); diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index aedbc3f..28be39d 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -22,6 +22,10 @@ export class RepositoriesView extends ViewBase { return new RepositoriesNode(this); } + protected get location(): string { + return this.config.location; + } + protected registerCommands() { Container.viewCommands; diff --git a/src/views/resultsView.ts b/src/views/resultsView.ts index a43681e..33d960e 100644 --- a/src/views/resultsView.ts +++ b/src/views/resultsView.ts @@ -28,6 +28,10 @@ export class ResultsView extends ViewBase { return new ResultsNode(this); } + protected get location(): string { + return this.config.location; + } + protected registerCommands() { Container.viewCommands; commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this); diff --git a/src/views/viewBase.ts b/src/views/viewBase.ts index 4fd22f2..11582da 100644 --- a/src/views/viewBase.ts +++ b/src/views/viewBase.ts @@ -1,5 +1,6 @@ 'use strict'; import { + commands, ConfigurationChangeEvent, Disposable, Event, @@ -73,6 +74,8 @@ export abstract class ViewBase implements TreeDataProvid return `${this.id}.${command}`; } + protected abstract get location(): string; + protected abstract getRoot(): TRoot; protected abstract registerCommands(): void; protected abstract onConfigurationChanged(e: ConfigurationChangeEvent): void; @@ -178,7 +181,7 @@ export abstract class ViewBase implements TreeDataProvid focus?: boolean | undefined; } ) { - if (this._tree === undefined || this._root === undefined) return; + if (this._tree === undefined) return; try { await this._tree.reveal(node, options); @@ -189,12 +192,9 @@ export abstract class ViewBase implements TreeDataProvid } @log() - async show() { - if (this._tree === undefined || this._root === undefined) return; - - // This sucks -- have to get the first child to reveal the tree - const [child] = await this._root.getChildren(); - return this.reveal(child, { select: false, focus: true }); + show() { + const location = this.location; + return commands.executeCommand(`${this.id}${location ? `:${location}` : ''}.focus`); } @debug({