Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0227d28

Browse filesBrowse files
authored
Merge pull request #49 from per1234/fix-custom-override
Fix regression in overriding remapped debug configuration data via `debug_custom.json`
2 parents 4938c41 + 8dcb493 commit 0227d28
Copy full SHA for 0227d28

File tree

2 files changed

+43
-6
lines changed
Filter options

2 files changed

+43
-6
lines changed

‎src/debug.ts

Copy file name to clipboardExpand all lines: src/debug.ts
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ async function mergeLaunchConfig(
306306
(config) => config.configId === configId
307307
);
308308
const name = createName(board, programmer);
309-
const launchConfig = {
309+
// Create base configuration data
310+
let launchConfig = {
310311
configId,
311312
cwd: '${workspaceRoot}',
312313
request: 'launch',
@@ -315,17 +316,26 @@ async function mergeLaunchConfig(
315316
...(debugInfo.customConfigs
316317
? debugInfo.customConfigs[cortexDebug] ?? {}
317318
: {}),
318-
...(customConfig ? customConfig : {}),
319319
name,
320320
};
321+
322+
// Remap Arduino CLI debug config properties to launch.json keys
321323
replaceValue('serverPath', 'serverpath', launchConfig);
322324
replaceValue('server', 'servertype', launchConfig);
323325
replaceValue('toolchainPath', 'armToolchainPath', launchConfig);
324326
replaceValue('serverConfiguration.scripts', 'configFiles', launchConfig);
327+
// Remove unused Arduino CLI debug config data
325328
unsetValue(launchConfig, 'customConfigs');
326329
unsetValue(launchConfig, 'serverConfiguration');
327330
unsetValue(launchConfig, 'programmer'); // The programmer is not used by the debugger https://github.com/arduino/arduino-cli/pull/2391
328331
unsetValue(launchConfig, 'toolchain'); // The toolchain is also unused by IDE2 or the cortex-debug VSIX
332+
333+
// Merge configuration from debug_custom.json
334+
launchConfig = {
335+
...launchConfig,
336+
...(customConfig ? customConfig : {}),
337+
};
338+
329339
return launchConfig;
330340
}
331341

‎src/test/suite/debug.test.ts

Copy file name to clipboardExpand all lines: src/test/suite/debug.test.ts
+31-4Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,27 @@ describe('debug', () => {
144144
const actual = await mergeLaunchConfig(
145145
board,
146146
programmer,
147-
{ executable },
148-
[{ configId, cwd: 'alma' }]
147+
{
148+
executable,
149+
toolchainPrefix: 'toolchain-prefix',
150+
serverPath: 'path/to/server',
151+
server: 'openocd',
152+
toolchainPath: 'path/to/toolchain',
153+
serverConfiguration: {
154+
scripts: ['path/to/config-file'],
155+
},
156+
},
157+
[
158+
{
159+
configId,
160+
cwd: 'alma',
161+
toolchainPrefix: 'custom-toolchain-prefix',
162+
serverpath: '/path/to/custom-server',
163+
servertype: 'jlink',
164+
armToolchainPath: '/path/to/custom-arm-toolchain',
165+
configFiles: ['/path/to/custom-config'],
166+
},
167+
]
149168
);
150169
assert.deepStrictEqual(actual, {
151170
configId,
@@ -154,6 +173,11 @@ describe('debug', () => {
154173
name: 'ABC (p1)',
155174
request: 'launch',
156175
type: 'cortex-debug',
176+
toolchainPrefix: 'custom-toolchain-prefix',
177+
serverpath: '/path/to/custom-server',
178+
servertype: 'jlink',
179+
armToolchainPath: '/path/to/custom-arm-toolchain',
180+
configFiles: ['/path/to/custom-config'],
157181
});
158182
});
159183

@@ -230,8 +254,11 @@ describe('debug', () => {
230254
const actual = await mergeLaunchConfig(
231255
board,
232256
programmer,
233-
{ executable },
234-
[{ configId, [key]: value }]
257+
{
258+
executable,
259+
[key]: value,
260+
},
261+
[]
235262
);
236263
assert.deepStrictEqual(actual, expected);
237264
})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.