Skip to content

Commit

Permalink
remoteControlMode - PR nursing
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Sep 27, 2023
1 parent 4d63bf9 commit fa8c8dd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
25 changes: 21 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/DebugConfigurationProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, <any>{
remoteControlMode: input
});
expect(config.remoteControlMode).to.deep.equal(expected);
});
});
});

describe('processLogfilePath', () => {
Expand Down
12 changes: 8 additions & 4 deletions src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') || {};
Expand Down Expand Up @@ -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`);
Expand Down Expand Up @@ -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 };
}
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit fa8c8dd

Please sign in to comment.