Skip to content

Commit 6d74b7a

Browse files
anthonykim1wesm
authored andcommitted
Take Smart Send Out of Experiment (microsoft/vscode-python#23067)
Resolves: microsoft/vscode-python#23045
1 parent 6f6e4cf commit 6d74b7a

File tree

4 files changed

+11
-52
lines changed

4 files changed

+11
-52
lines changed

extensions/positron-python/python_files/normalizeSelection.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,7 @@ def get_next_block_lineno(which_line_next):
297297
data = None
298298
which_line_next = 0
299299

300-
if (
301-
empty_Highlight
302-
and contents.get("smartSendExperimentEnabled")
303-
and contents.get("smartSendSettingsEnabled")
304-
):
300+
if empty_Highlight and contents.get("smartSendSettingsEnabled"):
305301
result = traverse_file(
306302
contents["wholeFileContent"],
307303
vscode_start_line,

extensions/positron-python/src/client/common/experiments/groups.ts

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ export enum DiscoveryUsingWorkers {
1919
export enum EnableTestAdapterRewrite {
2020
experiment = 'pythonTestAdapter',
2121
}
22-
// Experiment to enable smart shift+enter, advance cursor.
23-
export enum EnableREPLSmartSend {
24-
experiment = 'pythonREPLSmartSend',
25-
}
2622

2723
// Experiment to recommend installing the tensorboard extension.
2824
export enum RecommendTensobardExtension {

extensions/positron-python/src/client/terminals/codeExecution/helper.ts

+10-25
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import { IInterpreterService } from '../../interpreter/contracts';
2020
import { IServiceContainer } from '../../ioc/types';
2121
import { ICodeExecutionHelper } from '../types';
2222
import { traceError } from '../../logging';
23-
import { IConfigurationService, IExperimentService, Resource } from '../../common/types';
24-
import { EnableREPLSmartSend } from '../../common/experiments/groups';
23+
import { IConfigurationService, Resource } from '../../common/types';
2524
import { sendTelemetryEvent } from '../../telemetry';
2625
import { EventName } from '../../telemetry/constants';
2726

@@ -93,7 +92,6 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
9392
const startLineVal = activeEditor?.selection?.start.line ?? 0;
9493
const endLineVal = activeEditor?.selection?.end.line ?? 0;
9594
const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true;
96-
const smartSendExperimentEnabledVal = pythonSmartSendEnabled(this.serviceContainer);
9795
let smartSendSettingsEnabledVal = false;
9896
const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
9997
if (configuration) {
@@ -107,7 +105,6 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
107105
startLine: startLineVal,
108106
endLine: endLineVal,
109107
emptyHighlight: emptyHighlightVal,
110-
smartSendExperimentEnabled: smartSendExperimentEnabledVal,
111108
smartSendSettingsEnabled: smartSendSettingsEnabledVal,
112109
});
113110
observable.proc?.stdin?.write(input);
@@ -117,12 +114,7 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
117114
const result = await normalizeOutput.promise;
118115
const object = JSON.parse(result);
119116

120-
if (
121-
activeEditor?.selection &&
122-
smartSendExperimentEnabledVal &&
123-
smartSendSettingsEnabledVal &&
124-
object.normalized !== 'deprecated'
125-
) {
117+
if (activeEditor?.selection && smartSendSettingsEnabledVal && object.normalized !== 'deprecated') {
126118
const lineOffset = object.nextBlockLineno - activeEditor!.selection.start.line - 1;
127119
await this.moveToNextBlock(lineOffset, activeEditor);
128120
}
@@ -145,16 +137,15 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
145137
*/
146138
// eslint-disable-next-line class-methods-use-this
147139
private async moveToNextBlock(lineOffset: number, activeEditor?: TextEditor): Promise<void> {
148-
if (pythonSmartSendEnabled(this.serviceContainer)) {
149-
if (activeEditor?.selection?.isEmpty) {
150-
await this.commandManager.executeCommand('cursorMove', {
151-
to: 'down',
152-
by: 'line',
153-
value: Number(lineOffset),
154-
});
155-
await this.commandManager.executeCommand('cursorEnd');
156-
}
140+
if (activeEditor?.selection?.isEmpty) {
141+
await this.commandManager.executeCommand('cursorMove', {
142+
to: 'down',
143+
by: 'line',
144+
value: Number(lineOffset),
145+
});
146+
await this.commandManager.executeCommand('cursorEnd');
157147
}
148+
158149
return Promise.resolve();
159150
}
160151

@@ -314,9 +305,3 @@ function getMultiLineSelectionText(textEditor: TextEditor): string {
314305
// ↑<---------------- To here
315306
return selectionText;
316307
}
317-
318-
function pythonSmartSendEnabled(serviceContainer: IServiceContainer): boolean {
319-
const experiment = serviceContainer.get<IExperimentService>(IExperimentService);
320-
321-
return experiment ? experiment.inExperimentSync(EnableREPLSmartSend.experiment) : false;
322-
}

extensions/positron-python/src/test/terminals/codeExecution/smartSend.test.ts

-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { IConfigurationService, IExperimentService, IPythonSettings } from '../.
1616
import { CodeExecutionHelper } from '../../../client/terminals/codeExecution/helper';
1717
import { IServiceContainer } from '../../../client/ioc/types';
1818
import { ICodeExecutionHelper } from '../../../client/terminals/types';
19-
import { EnableREPLSmartSend } from '../../../client/common/experiments/groups';
2019
import { Commands, EXTENSION_ROOT_DIR } from '../../../client/common/constants';
2120
import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info';
2221
import { PYTHON_PATH } from '../../common';
@@ -117,10 +116,6 @@ suite('REPL - Smart Send', () => {
117116
});
118117

119118
test('Cursor is not moved when explicit selection is present', async () => {
120-
experimentService
121-
.setup((exp) => exp.inExperimentSync(TypeMoq.It.isValue(EnableREPLSmartSend.experiment)))
122-
.returns(() => true);
123-
124119
const activeEditor = TypeMoq.Mock.ofType<TextEditor>();
125120
const firstIndexPosition = new Position(0, 0);
126121
const selection = TypeMoq.Mock.ofType<Selection>();
@@ -164,15 +159,10 @@ suite('REPL - Smart Send', () => {
164159
});
165160

166161
test('Smart send should perform smart selection and move cursor', async () => {
167-
experimentService
168-
.setup((exp) => exp.inExperimentSync(TypeMoq.It.isValue(EnableREPLSmartSend.experiment)))
169-
.returns(() => true);
170-
171162
configurationService
172163
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
173164
.returns({
174165
REPL: {
175-
EnableREPLSmartSend: true,
176166
REPLSmartSend: true,
177167
},
178168
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -228,9 +218,6 @@ suite('REPL - Smart Send', () => {
228218

229219
// Do not perform smart selection when there is explicit selection
230220
test('Smart send should not perform smart selection when there is explicit selection', async () => {
231-
experimentService
232-
.setup((exp) => exp.inExperimentSync(TypeMoq.It.isValue(EnableREPLSmartSend.experiment)))
233-
.returns(() => true);
234221
const activeEditor = TypeMoq.Mock.ofType<TextEditor>();
235222
const firstIndexPosition = new Position(0, 0);
236223
const selection = TypeMoq.Mock.ofType<Selection>();
@@ -257,15 +244,10 @@ suite('REPL - Smart Send', () => {
257244
});
258245

259246
test('Smart Send should provide warning when code is not valid', async () => {
260-
experimentService
261-
.setup((exp) => exp.inExperimentSync(TypeMoq.It.isValue(EnableREPLSmartSend.experiment)))
262-
.returns(() => true);
263-
264247
configurationService
265248
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
266249
.returns({
267250
REPL: {
268-
EnableREPLSmartSend: true,
269251
REPLSmartSend: true,
270252
},
271253
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)