diff --git a/package.json b/package.json index 04f8afc0..f91c7695 100644 --- a/package.json +++ b/package.json @@ -825,10 +825,27 @@ "default": false, "description": "Delete any currently installed dev channel before starting the debug session" }, - "enableRemoteControl": { - "type": "boolean", - "default": true, - "description": "Enable remote control mode when starting the debug session" + "remoteControlMode": { + "oneOf": [ + { + "type": "object", + "description": "Options for activating and deactivating remote control mode", + "properties": { + "activateOnSessionStart": { + "type": "boolean", + "description": "Activate remote control mode on debug session start" + }, + "deactivateOnSessionEnd": { + "type": "boolean", + "description": "Deactivate remote control mode on session end" + } + } + }, + { + "type": "boolean", + "description": "Activate on session start, deactivate on session end." + } + ] } } } diff --git a/src/DebugConfigurationProvider.spec.ts b/src/DebugConfigurationProvider.spec.ts index 8148b288..20eb5cdf 100644 --- a/src/DebugConfigurationProvider.spec.ts +++ b/src/DebugConfigurationProvider.spec.ts @@ -164,6 +164,19 @@ describe('BrightScriptConfigurationProvider', () => { expect(config.packagePort).to.equal(1234); expect(config.remotePort).to.equal(5678); }); + + [ + { input: true, expected: { activateOnSessionStart: true, deactivateOnSessionEnd: true } }, + { input: false, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } }, + { input: undefined, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } } + ].forEach(({ input, expected }) => { + it('allows using a bool value for remoteConfigMode', async () => { + let config = await configProvider.resolveDebugConfiguration(folder, { + remoteControlMode: input + }); + expect(config.remoteControlMode).to.deep.equal(expected); + }); + }); }); describe('processLogfilePath', () => { diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 202d83bb..2b794aa8 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -53,7 +53,10 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio remotePort: 8060, rendezvousTracking: true, deleteDevChannelBeforeInstall: false, - enableRemoteControl: false + remoteControlMode: { + activateOnSessionStart: false, + deactivateOnSessionEnd: false + } }; let config: any = vscode.workspace.getConfiguration('brightscript') || {}; @@ -244,7 +247,8 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.cwd = folderUri.fsPath; config.rendezvousTracking = config.rendezvousTracking === false ? false : true; config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true; - config.enableRemoteControl = config.enableRemoteControl === true ? true : this.configDefaults.enableRemoteControl; + config.remoteControlMode = config.remoteControlMode ? config.remoteControlMode : this.configDefaults.remoteControlMode; + config.remoteControlMode = config.remoteControlMode === true ? { activateOnSessionStart: true, deactivateOnSessionEnd: true } : config.remoteControlMode; if (config.request !== 'launch') { await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`); @@ -565,8 +569,8 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration { disableScreenSaver?: boolean; /** - * If true, the remote control will be enabled at the start of the debug session + * If true, the remote control will be enabled at the start of the debug session, and disabled at the end of the debug session. * @default false */ - enableRemoteControl?: boolean; + remoteControlMode?: boolean | { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean }; } diff --git a/src/extension.ts b/src/extension.ts index 66810440..42f6f93c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -178,7 +178,7 @@ export class Extension { if (e.type === 'brightscript') { this.chanperfStatusBar.hide(); const config = e.configuration as BrightScriptLaunchConfiguration; - if (config.enableRemoteControl) { + if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.deactivateOnSessionEnd === true)) { void this.remoteControlManager.setRemoteControlMode(false, 'launch'); } } @@ -216,7 +216,7 @@ export class Extension { const config = e.body as BrightScriptLaunchConfiguration; await docLinkProvider.setLaunchConfig(config); logOutputManager.setLaunchConfig(config); - if (config.enableRemoteControl) { + if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.activateOnSessionStart === true)) { void this.remoteControlManager.setRemoteControlMode(true, 'launch'); } } else if (isChannelPublishedEvent(e)) {