Fixing unsupported providers behavior on Async Server Tree (#23758)

* Throwing error so that connection loading fails.

* Fixing stuff

* Fixing tests
This commit is contained in:
Aasim Khan 2023-07-11 22:59:00 -07:00 коммит произвёл GitHub
Родитель c3ef0f91cb
Коммит 953ea05802
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -1368,16 +1368,22 @@ export class ConnectionManagementService extends Disposable implements IConnecti
});
await this._extensionService.activateByEvent(`onConnect:${connection.providerName}`);
if (this._providers.get(connection.providerName) === undefined) {
await this.handleUnsupportedProvider(connection.providerName);
throw new Error(nls.localize('connection.providerNotFound', "Connection provider '{0}' not found", connection.providerName));
}
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
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
const editors = this._editorService.findEditors(URI.parse(uri));
if (editors && editors[0]?.editor) {
const editor = editors[0].editor;
// TODO make this generic enough to handle non-SQL languages too
const language = editor instanceof QueryEditorInput && editor.state.isSqlCmdMode ? 'sqlcmd' : 'sql';
this.doChangeLanguageFlavor(uri, language, connection.providerName);
}
return true;
});
}
@ -1644,7 +1650,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti
});
// send connection request
self.sendConnectRequest(connection, uri).catch((e) => this._logService.error(e));
self.sendConnectRequest(connection, uri).catch((e) => {
this._logService.error(e);
this._connectionStatusManager.removeConnection(uri);
reject(e);
});
});
}

Просмотреть файл

@ -128,7 +128,10 @@ export class TreeSelectionHandler {
}
const selectedNode = selection[0];
if (selectedNode instanceof ConnectionProfile && !capabilitiesService.getCapabilities(selectedNode.providerName)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError);
// Async tree handles unsupported providers through the connection management service
if (!(tree instanceof AsyncServerTree)) {
connectionManagementService.handleUnsupportedProvider(selectedNode.providerName).catch(onUnexpectedError);
}
return;
}