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

@@ -96,12 +96,12 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
}
private _onEditorClosed(event: IEditorCloseEvent): void {
let uri = event.editor.resource.toString();
let uri = event.editor.resource?.toString();
if (uri && uri in this._sqlStatusEditors) {
// If active editor is being closed, hide the query status.
let activeEditor = this.editorService.activeEditorPane;
if (activeEditor) {
let currentUri = activeEditor.input.resource.toString();
let currentUri = activeEditor.input.resource?.toString();
if (uri === currentUri) {
this.hide();
}
@@ -114,7 +114,7 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
private _onEditorsChanged(): void {
let activeEditor = this.editorService.activeEditorPane;
if (activeEditor) {
let uri = activeEditor.input.resource.toString();
let uri = activeEditor.input.resource?.toString();
// Show active editor's language flavor status
if (uri) {
@@ -145,7 +145,7 @@ export class SqlFlavorStatusbarItem extends Disposable implements IWorkbenchCont
private _showStatus(uri: string): void {
let activeEditor = this.editorService.activeEditorPane;
if (activeEditor) {
let currentUri = activeEditor.input.resource.toString();
let currentUri = activeEditor.input.resource?.toString();
if (uri === currentUri) {
let flavor: SqlProviderEntry = this._sqlStatusEditors[uri];
if (flavor) {
@@ -186,7 +186,7 @@ export class ChangeFlavorAction extends Action {
public run(): Promise<any> {
let activeEditor = this._editorService.activeEditorPane;
let currentUri = activeEditor?.input.resource.toString();
let currentUri = activeEditor?.input.resource?.toString();
if (this._connectionManagementService.isConnected(currentUri)) {
let currentProvider = this._connectionManagementService.getProviderIdFromUri(currentUri);
return this._showMessage(Severity.Info, nls.localize('alreadyConnected',