close
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7250861
Adding Run Without Debugging feature
bobbrow Apr 3, 2026
448763e
Updates for WSL
bobbrow Apr 3, 2026
c315d20
Add support for linux terminals
bobbrow Apr 3, 2026
a86afd6
Add tests
bobbrow Apr 3, 2026
bb77661
address CodeQL issue
bobbrow Apr 3, 2026
2608547
set the console type based on debugger type
bobbrow Apr 3, 2026
9f9dd61
use shell integration on terminals that support it
bobbrow Apr 3, 2026
d59f6c0
Merge branch 'main' into bobbrow/runWithoutDebugging
bobbrow Apr 4, 2026
de0e20c
PR comments and placeholder for automation for later
bobbrow Apr 6, 2026
6008c13
warn the user if they try to do run without debugging in unsupported …
bobbrow Apr 6, 2026
da02611
Use buildShellCommandLine
bobbrow Apr 6, 2026
68dddd8
reinterpret internalConsole to be integratedTerminal
bobbrow Apr 7, 2026
da18921
set the MIMode explicitly
bobbrow Apr 7, 2026
ad01d4a
Fix the test to work with integratedTerminal mode
bobbrow Apr 7, 2026
a69ba2a
Change the test to read from file instead of exit code
bobbrow Apr 9, 2026
b94df3e
Merge branch 'main' into bobbrow/runWithoutDebugging
bobbrow Apr 9, 2026
44dda31
handle programs with spaces in the name for shell integration
bobbrow Apr 9, 2026
161627d
Addres feedback and test more launch combinations
bobbrow Apr 10, 2026
826e1d2
PowerShell is the default shell on Windows
bobbrow Apr 13, 2026
bd6eb8b
Merge branch 'main' into bobbrow/runWithoutDebugging
bobbrow Apr 13, 2026
cf48779
Merge branch 'main' into bobbrow/runWithoutDebugging
bobbrow Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for linux terminals
  • Loading branch information
bobbrow committed Apr 3, 2026
commit c315d2028d23b85ef2b4a3c9faed1fab3e6dc1d0
43 changes: 42 additions & 1 deletion Extension/src/Debugger/runWithoutDebuggingAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import * as os from 'os';
import * as path from 'path';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { sessionIsWsl } from '../common';

nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize = nls.loadMessageBundle();

/**
* A minimal inline Debug Adapter that runs the target program directly without a debug adapter
* when the user invokes "Run Without Debugging".
Expand Down Expand Up @@ -113,15 +117,52 @@
if (platform === 'win32') {
cp.spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/K', cmdLine], { cwd, env, detached: true, stdio: 'ignore' }).unref();
} else if (platform === 'darwin') {
cp.spawn('osascript', ['-e', `tell application "Terminal" to do script "${cmdLine.replace(/"/g, '\\"')}"`], { cwd, env, detached: true, stdio: 'ignore' }).unref();

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
} else if (platform === 'linux' && sessionIsWsl()) {
cp.spawn('/mnt/c/Windows/System32/cmd.exe', ['/c', 'start', 'bash', '-c', `${cmdLine};read -p 'Press enter to continue...'`], { env, detached: true, stdio: 'ignore' }).unref();
} else { // platform === 'linux'
cp.spawn('bash', ['-c', `${cmdLine};read -p 'Press enter to continue...'`], { cwd, env, detached: true, stdio: 'ignore' }).unref();
this.launchLinuxExternalTerminal(cmdLine, cwd, env);
}
this.sendEvent('terminated');
}

/**
* On Linux, find and launch an available terminal emulator to run the command.
*/
private launchLinuxExternalTerminal(cmdLine: string, cwd: string | undefined, env: NodeJS.ProcessEnv): void {
const bashCmd = `${cmdLine}; echo; read -p 'Press enter to continue...'`;
const bashArgs = ['bash', '-c', bashCmd];

// Terminal emulators in order of preference, with the correct flag style for each.
const candidates: { cmd: string; buildArgs: () => string[] }[] = [

Check failure on line 137 in Extension/src/Debugger/runWithoutDebuggingAdapter.ts

View workflow job for this annotation

Image GitHub Actions / job / build

Function property signature is forbidden. Use a method shorthand instead

Check failure on line 137 in Extension/src/Debugger/runWithoutDebuggingAdapter.ts

View workflow job for this annotation

Image GitHub Actions / job / build

Function property signature is forbidden. Use a method shorthand instead

Check failure on line 137 in Extension/src/Debugger/runWithoutDebuggingAdapter.ts

View workflow job for this annotation

Image GitHub Actions / job / build

Function property signature is forbidden. Use a method shorthand instead
{ cmd: 'x-terminal-emulator', buildArgs: () => ['-e', ...bashArgs] },
{ cmd: 'gnome-terminal', buildArgs: () => ['-e', ...bashArgs] },
{ cmd: 'konsole', buildArgs: () => ['-e', ...bashArgs] },
{ cmd: 'xterm', buildArgs: () => ['-e', ...bashArgs] }
];

// Honor the $TERMINAL environment variable if set.
const terminalEnv = process.env['TERMINAL'];
if (terminalEnv) {
candidates.unshift({ cmd: terminalEnv, buildArgs: () => ['-e', ...bashArgs] });
}

for (const candidate of candidates) {
try {
const result = cp.spawnSync('which', [candidate.cmd], { stdio: 'pipe' });
if (result.status === 0) {
cp.spawn(candidate.cmd, candidate.buildArgs(), { cwd, env, detached: true, stdio: 'ignore' }).unref();
return;
}
} catch {
continue;
}
}

const message = localize('no.terminal.emulator', 'No terminal emulator found. Please set the $TERMINAL environment variable to your terminal emulator of choice, or install one of the following: x-terminal-emulator, gnome-terminal, konsole, xterm.');
vscode.window.showErrorMessage(message);
}

/**
* Spawn the process and forward stdout/stderr as DAP output events.
*/
Expand All @@ -146,7 +187,7 @@
}

private quoteArg(arg: string): string {
return /\s/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
}

private sendResponse(request: { command: string; seq: number; }, body: object): void {
Expand Down
Loading