Check for valid uri/resource (#9593)

* Check for valid uri/resource

* Add a few other cases
This commit is contained in:
Charles Gagnon
2020-03-13 11:19:25 -07:00
committed by GitHub
parent d5fdec5699
commit 1699dd0729
2 changed files with 8 additions and 8 deletions

View File

@@ -57,7 +57,7 @@ export function replaceConnection(oldUri: string, newUri: string, connectionServ
*
* @param topLevelOnly If true, only return top-level (i.e. connected) Object Explorer connections instead of database connections when appropriate
*/
export function getCurrentGlobalConnection(objectExplorerService: IObjectExplorerService, connectionManagementService: IConnectionManagementService, workbenchEditorService: IEditorService, topLevelOnly: boolean = false): IConnectionProfile {
export function getCurrentGlobalConnection(objectExplorerService: IObjectExplorerService, connectionManagementService: IConnectionManagementService, workbenchEditorService: IEditorService, topLevelOnly: boolean = false): IConnectionProfile | undefined {
let connection: IConnectionProfile;
// object Explorer Connection
let objectExplorerSelection = objectExplorerService.getSelectedProfileAndDatabase();
@@ -78,9 +78,9 @@ export function getCurrentGlobalConnection(objectExplorerService: IObjectExplore
let activeInput = workbenchEditorService.activeEditor;
if (activeInput) {
// dashboard Connection
if (activeInput instanceof DashboardInput) {
if (activeInput instanceof DashboardInput && activeInput.uri) {
connection = connectionManagementService.getConnectionProfile(activeInput.uri.toString());
} else {
} else if (activeInput.resource) {
// editor Connection
connection = connectionManagementService.getConnectionProfile(activeInput.resource.toString());
}