do not run query in multi-selection mode (#20213)

* do not run query in multi-selection mode

* fix test

* fix more tests
This commit is contained in:
Alan Ren
2022-07-30 14:29:32 -07:00
committed by GitHub
parent 6704bc552a
commit 6be1420220
4 changed files with 32 additions and 11 deletions

View File

@@ -200,6 +200,7 @@ export class RunQueryAction extends QueryTaskbarAction {
editor: QueryEditor,
@IQueryModelService protected readonly queryModelService: IQueryModelService,
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
@INotificationService private readonly notificationService: INotificationService,
@ICommandService private readonly commandService?: ICommandService
) {
super(connectionManagementService, editor, RunQueryAction.ID, RunQueryAction.EnabledClass);
@@ -238,6 +239,13 @@ export class RunQueryAction extends QueryTaskbarAction {
if (this.isConnected(editor)) {
// Hide IntelliSense suggestions list when running query to match SSMS behavior
this.commandService?.executeCommand('hideSuggestWidget');
// Do not execute when there are multiple selections in the editor until it can be properly handled.
// Otherwise only the first selection will be executed and cause unexpected issues.
if (editor.getSelections()?.length > 1) {
this.notificationService.error(nls.localize('query.multiSelectionNotSupported', "Running query is not supported when the editor is in multiple selection mode."));
return true;
}
// if the selection isn't empty then execute the selection
// otherwise, either run the statement or the script depending on parameter
let selection = editor.getSelection(false);