Skip to content

Commit

Permalink
wrap around experiment, context key
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed May 9, 2024
1 parent bc9637c commit fa76d00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@
{
"command": "python.execInREPL",
"group": "Python",
"when": "editorFocus && editorLangId == python && !virtualWorkspace && shellExecutionSupported"
"when": "editorFocus && editorLangId == python && !virtualWorkspace && shellExecutionSupported && pythonRunREPL"
}
],
"editor/title": [
Expand Down
5 changes: 5 additions & 0 deletions src/client/common/experiments/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ export enum EnableTestAdapterRewrite {
export enum RecommendTensobardExtension {
experiment = 'pythonRecommendTensorboardExt',
}

// Experiment to enable running Python REPL using IW.
export enum EnableRunREPL {
experiment = 'pythonRunREPL',
}
17 changes: 15 additions & 2 deletions src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

import { DebugConfigurationProvider, debug, languages, window } from 'vscode';
import { DebugConfigurationProvider, debug, languages, window, commands } from 'vscode';

import { registerTypes as activationRegisterTypes } from './activation/serviceRegistry';
import { IExtensionActivationManager } from './activation/types';
Expand All @@ -16,6 +16,7 @@ import { IFileSystem } from './common/platform/types';
import {
IConfigurationService,
IDisposableRegistry,
IExperimentService,
IExtensions,
IInterpreterPathService,
ILogOutputChannel,
Expand Down Expand Up @@ -54,6 +55,7 @@ import { logAndNotifyOnLegacySettings } from './logging/settingLogs';
import { DebuggerTypeName } from './debugger/constants';
import { StopWatch } from './common/utils/stopWatch';
import { registerReplCommands } from './repl/replCommands';
import { EnableRunREPL } from './common/experiments/groups';

export async function activateComponents(
// `ext` is passed to any extra activation funcs.
Expand Down Expand Up @@ -115,7 +117,18 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
// registerReplCommands(ext.disposables, interpreterService);
// }
// uncomment
registerReplCommands(ext.disposables, interpreterService);

// Only register if they are in experiment for pythonRunREPL.
const experimentService = ext.legacyIOC.serviceContainer.get<IExperimentService>(IExperimentService);
commands.executeCommand('setContext', 'pythonRunREPL', false);
if (experimentService) {
const replExperimentValue = experimentService.inExperimentSync(EnableRunREPL.experiment);
if (replExperimentValue) {
registerReplCommands(ext.disposables, interpreterService);
commands.executeCommand('setContext', 'pythonRunREPL', true);
}
}
// registerReplCommands(ext.disposables, interpreterService); // Register regardless
}

/// //////////////////////////
Expand Down

0 comments on commit fa76d00

Please sign in to comment.