Fix language flavor change on connection when in sqlcmd mode (#17719)

* Fix language flavor change on connection when in sqlcmd mode

* comment + fix
This commit is contained in:
Charles Gagnon
2021-11-19 15:04:54 -08:00
committed by GitHub
parent ae5026b432
commit 6ba7bad90c

View File

@@ -49,6 +49,8 @@ import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
import { URI } from 'vs/base/common/uri';
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
@@ -950,9 +952,12 @@ export class ConnectionManagementService extends Disposable implements IConnecti
return this._providers.get(connection.providerName).onReady.then((provider) => {
provider.connect(uri, connectionInfo);
this._onConnectRequestSent.fire();
// Connections are made per URI so while there may possibly be multiple editors with
// that URI they all share the same state
const editor = this._editorService.findEditors(URI.parse(uri))[0]?.editor;
// TODO make this generic enough to handle non-SQL languages too
this.doChangeLanguageFlavor(uri, 'sql', connection.providerName);
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
return true;
});
}