Skip to content

Commit bd60254

Browse files
committed
normalize paths from "program" in launch.json
If variables are used as part of the "program" property in the `launch.json` on Windows, it will have Windows path separators. So we need to normalize the path to use UNIX path separators before sending it to the EV3. Fixes: pybricks/support#1016
1 parent 6f57fd1 commit bd60254

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to the "ev3dev-browser" extension will be documented in this
33

44
<!-- Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. -->
55

6+
## Unreleased
7+
8+
### Fixed
9+
- Fixed Windows path separator in "program" in `.vscode/launch.json` not converted to UNIX path.
10+
611
## v1.2.0 - 2020-07-20
712
### Changed
813
- Initial debug configuration has new example to run current file

src/extension.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
191191

192192
// run the program
193193
try {
194-
const dirname = path.posix.dirname(args.program);
194+
// normalize the path to unix path separators since this path will be used on the EV3
195+
const programPath = vscode.Uri.file(args.program).path;
196+
197+
const dirname = path.posix.dirname(programPath);
195198
if (args.interactiveTerminal) {
196-
const command = `brickrun -r --directory="${dirname}" "${args.program}"`;
199+
const command = `brickrun -r --directory="${dirname}" "${programPath}"`;
197200
const config = vscode.workspace.getConfiguration(`terminal.integrated.env.${getPlatform()}`);
198201
const termEnv = config.get<string>('TERM');
199202
const env = {
@@ -208,7 +211,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
208211
debugTerminal.dispose();
209212
}
210213
debugTerminal = vscode.window.createTerminal({
211-
name: `${path.posix.basename(args.program)} on ${device.name}`,
214+
name: `${path.posix.basename(programPath)} on ${device.name}`,
212215
pty: {
213216
onDidWrite: writeEmitter.event,
214217
open: (dim: vscode.TerminalDimensions | undefined) => {
@@ -262,7 +265,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
262265
event.session.customRequest('ev3devBrowser.debugger.thread', 'started');
263266
}
264267
else {
265-
const command = `brickrun --directory="${dirname}" "${args.program}"`;
268+
const command = `brickrun --directory="${dirname}" "${programPath}"`;
266269
output.show(true);
267270
output.clear();
268271
output.appendLine(`Starting: ${command}`);

0 commit comments

Comments
 (0)