Skip to content

Commit

Permalink
"input" variables prevent compound configuration from launching more …
Browse files Browse the repository at this point in the history
…than one session (#157596)

* Revert ""input" variables prevent compound configuration from launching more than one session (#157355)"

This reverts commit f1c5243.

* "input" variables prevent compound configuration from launching more than one session
Fixes #141514

* Queue commands
  • Loading branch information
roblourens authored and joyceerhl committed Aug 10, 2022
1 parent 6b66015 commit b936110
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
6 changes: 2 additions & 4 deletions src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as aria from 'vs/base/browser/ui/aria/aria';
import { Action, IAction } from 'vs/base/common/actions';
import { distinct } from 'vs/base/common/arrays';
import { Queue, raceTimeout, RunOnceScheduler } from 'vs/base/common/async';
import { raceTimeout, RunOnceScheduler } from 'vs/base/common/async';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { isErrorWithActions } from 'vs/base/common/errorMessage';
import * as errors from 'vs/base/common/errors';
Expand Down Expand Up @@ -825,7 +825,6 @@ export class DebugService implements IDebugService {
return Promise.all(sessions.map(s => disconnect ? s.disconnect(undefined, suspend) : s.terminate()));
}

private variableSubstitutionQueue = new Queue<IConfig | undefined>();
private async substituteVariables(launch: ILaunch | undefined, config: IConfig): Promise<IConfig | undefined> {
const dbg = this.adapterManager.getDebugger(config.type);
if (dbg) {
Expand All @@ -839,8 +838,7 @@ export class DebugService implements IDebugService {
}
}
try {
// Variable substitution can require user interaction, so only one of these should be running at a time.
return this.variableSubstitutionQueue.queue(() => dbg.substituteVariables(folder, config));
return await dbg.substituteVariables(folder, config);
} catch (err) {
this.showError(err.message, undefined, !!launch?.getConfiguration(config.name));
return undefined; // bail out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Queue } from 'vs/base/common/async';
import { IStringDictionary } from 'vs/base/common/collections';
import { Schemas } from 'vs/base/common/network';
import { IProcessEnvironment } from 'vs/base/common/platform';
import * as Types from 'vs/base/common/types';
import { URI as uri } from 'vs/base/common/uri';
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
import * as nls from 'vs/nls';
import * as Types from 'vs/base/common/types';
import { Schemas } from 'vs/base/common/network';
import { SideBySideEditor, EditorResourceAccessor } from 'vs/workbench/common/editor';
import { IStringDictionary } from 'vs/base/common/collections';
import { IConfigurationService, IConfigurationOverrides, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkspaceFolder, IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { AbstractVariableResolverService } from 'vs/workbench/services/configurationResolver/common/variableResolver';
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
import { IQuickInputService, IInputOptions, IQuickPickItem, IPickOptions } from 'vs/platform/quickinput/common/quickInput';
import { ConfiguredInput } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { ConfigurationTarget, IConfigurationOverrides, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILabelService } from 'vs/platform/label/common/label';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { IInputOptions, IPickOptions, IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { EditorResourceAccessor, SideBySideEditor } from 'vs/workbench/common/editor';
import { ConfiguredInput } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { AbstractVariableResolverService } from 'vs/workbench/services/configurationResolver/common/variableResolver';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IPathService } from 'vs/workbench/services/path/common/pathService';

export abstract class BaseConfigurationResolverService extends AbstractVariableResolverService {

static readonly INPUT_OR_COMMAND_VARIABLES_PATTERN = /\${((input|command):(.*?))}/g;

private userInputAccessQueue = new Queue<string | IQuickPickItem | undefined>();

constructor(
context: {
getAppRoot: () => string | undefined;
Expand Down Expand Up @@ -306,8 +309,8 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
if (info.password) {
inputOptions.password = info.password;
}
return this.quickInputService.input(inputOptions).then(resolvedInput => {
return resolvedInput;
return this.userInputAccessQueue.queue(() => this.quickInputService.input(inputOptions)).then(resolvedInput => {
return resolvedInput as string;
});
}

Expand Down Expand Up @@ -346,9 +349,9 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
}
}
const pickOptions: IPickOptions<PickStringItem> = { placeHolder: info.description, matchOnDetail: true, ignoreFocusLost: true };
return this.quickInputService.pick(picks, pickOptions, undefined).then(resolvedInput => {
return this.userInputAccessQueue.queue(() => this.quickInputService.pick(picks, pickOptions, undefined)).then(resolvedInput => {
if (resolvedInput) {
return resolvedInput.value;
return (resolvedInput as PickStringItem).value;
}
return undefined;
});
Expand All @@ -358,7 +361,7 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
if (!Types.isString(info.command)) {
missingAttribute('command');
}
return this.commandService.executeCommand<string>(info.command, info.args).then(result => {
return this.userInputAccessQueue.queue(() => this.commandService.executeCommand<string>(info.command, info.args)).then(result => {
if (typeof result === 'string' || Types.isUndefinedOrNull(result)) {
return result;
}
Expand Down

0 comments on commit b936110

Please sign in to comment.