Skip to content

Commit da02611

Browse files
committed
Use buildShellCommandLine
1 parent 6008c13 commit da02611

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Extension/src/Debugger/runWithoutDebuggingAdapter.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as os from 'os';
88
import * as path from 'path';
99
import * as vscode from 'vscode';
1010
import * as nls from 'vscode-nls';
11-
import { sessionIsWsl } from '../common';
11+
import { buildShellCommandLine, sessionIsWsl } from '../common';
1212

1313
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
1414
const localize = nls.loadMessageBundle();
@@ -112,8 +112,8 @@ export class RunWithoutDebuggingAdapter implements vscode.DebugAdapter {
112112
this.monitorIntegratedTerminal(this.terminal);
113113
this.terminalExecution = shellIntegration.executeCommand(program, args);
114114
} else {
115-
const shellArgs: string[] = [program, ...args].map(a => this.quoteArg(a));
116-
this.terminal.sendText(shellArgs.join(' '));
115+
const cmdLine: string = buildShellCommandLine('', program, args);
116+
this.terminal.sendText(cmdLine);
117117

118118
// The terminal manages its own lifecycle; notify VS Code the "debug" session is done.
119119
this.sendEvent('terminated');
@@ -124,8 +124,7 @@ export class RunWithoutDebuggingAdapter implements vscode.DebugAdapter {
124124
* Launch the program in an external terminal. We do not keep track of this terminal or the spawned process.
125125
*/
126126
private launchExternalTerminal(program: string, args: string[], cwd: string | undefined, env: NodeJS.ProcessEnv): void {
127-
const quotedArgs: string[] = [program, ...args].map(a => this.quoteArg(a));
128-
const cmdLine: string = quotedArgs.join(' ');
127+
const cmdLine: string = buildShellCommandLine('', program, args);
129128
const platform: string = os.platform();
130129
if (platform === 'win32') {
131130
cp.spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/K', cmdLine], { cwd, env, detached: true, stdio: 'ignore' }).unref();
@@ -203,10 +202,6 @@ export class RunWithoutDebuggingAdapter implements vscode.DebugAdapter {
203202
return arg.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
204203
}
205204

206-
private quoteArg(arg: string): string {
207-
return /\s/.test(arg) ? `"${this.escapeQuotes(arg)}"` : arg;
208-
}
209-
210205
private waitForShellIntegration(terminal: vscode.Terminal, timeoutMs: number): Promise<vscode.TerminalShellIntegration | undefined> {
211206
return new Promise(resolve => {
212207
let resolved: boolean = false;

0 commit comments

Comments
 (0)