Fix for database name in connection details after changing database (#22376)

This commit is contained in:
Alex Ma
2023-05-18 14:34:54 -07:00
committed by GitHub
parent 7d0a7a6721
commit 89386c9c11
14 changed files with 76 additions and 36 deletions

View File

@@ -27,10 +27,13 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IUntit
public static readonly ID = UNTITLED_QUERY_EDITOR_TYPEID;
private originalConnectionUri: string;
constructor(
description: string | undefined,
text: UntitledTextEditorInput,
results: QueryResultsInput,
initialConnectionUri: string | undefined,
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
@IQueryModelService queryModelService: IQueryModelService,
@IConfigurationService configurationService: IConfigurationService,
@@ -39,6 +42,7 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IUntit
@IEditorResolverService private readonly editorResolverService: IEditorResolverService
) {
super(description, text, results, connectionManagementService, queryModelService, configurationService, instantiationService);
this.originalConnectionUri = initialConnectionUri;
// Set the mode explicitely to stop the auto language detection service from changing the mode unexpectedly.
// the auto language detection service won't do the language change only if the mode is explicitely set.
// if the mode (e.g. kusto, sql) do not exist for whatever reason, we will default it to sql.
@@ -121,4 +125,11 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IUntit
// Subclasses need to explicitly opt-in to being untitled.
return EditorInputCapabilities.Untitled;
}
override dispose() {
if (this.originalConnectionUri) {
this.connectionManagementService.disconnect(this.originalConnectionUri);
}
super.dispose();
}
}