Skip to content

Commit 028398e

Browse files
authored
Smart Send default value should be true (#23074)
Forgot to set default value to true here: #23067 It was true before removing experiment code since we had experiment to 100%, which effectively overrode the smart send setting value to True.
1 parent f624331 commit 028398e

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

src/client/terminals/codeExecution/helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
9292
const startLineVal = activeEditor?.selection?.start.line ?? 0;
9393
const endLineVal = activeEditor?.selection?.end.line ?? 0;
9494
const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true;
95-
let smartSendSettingsEnabledVal = false;
95+
let smartSendSettingsEnabledVal = true;
9696
const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
9797
if (configuration) {
9898
const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource());

src/test/terminals/codeExecution/helper.test.ts

+45-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SemVer } from 'semver';
1010
import * as TypeMoq from 'typemoq';
1111
import { Position, Range, Selection, TextDocument, TextEditor, TextLine, Uri } from 'vscode';
1212
import {
13+
IActiveResourceService,
1314
IApplicationShell,
1415
ICommandManager,
1516
IDocumentManager,
@@ -23,6 +24,7 @@ import {
2324
IProcessServiceFactory,
2425
ObservableExecutionResult,
2526
} from '../../../client/common/process/types';
27+
import { IConfigurationService, IPythonSettings } from '../../../client/common/types';
2628
import { Architecture } from '../../../client/common/utils/platform';
2729
import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types';
2830
import { IInterpreterService } from '../../../client/interpreter/contracts';
@@ -35,6 +37,7 @@ import { PYTHON_PATH } from '../../common';
3537
const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec');
3638

3739
suite('Terminal - Code Execution Helper', () => {
40+
let activeResourceService: TypeMoq.IMock<IActiveResourceService>;
3841
let documentManager: TypeMoq.IMock<IDocumentManager>;
3942
let applicationShell: TypeMoq.IMock<IApplicationShell>;
4043
let helper: ICodeExecutionHelper;
@@ -44,6 +47,8 @@ suite('Terminal - Code Execution Helper', () => {
4447
let interpreterService: TypeMoq.IMock<IInterpreterService>;
4548
let commandManager: TypeMoq.IMock<ICommandManager>;
4649
let workspaceService: TypeMoq.IMock<IWorkspaceService>;
50+
let configurationService: TypeMoq.IMock<IConfigurationService>;
51+
let pythonSettings: TypeMoq.IMock<IPythonSettings>;
4752
const workingPython: PythonEnvironment = {
4853
path: PYTHON_PATH,
4954
version: new SemVer('3.6.6-final'),
@@ -57,13 +62,16 @@ suite('Terminal - Code Execution Helper', () => {
5762
setup(() => {
5863
const serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();
5964
commandManager = TypeMoq.Mock.ofType<ICommandManager>();
65+
configurationService = TypeMoq.Mock.ofType<IConfigurationService>();
6066
workspaceService = TypeMoq.Mock.ofType<IWorkspaceService>();
6167
documentManager = TypeMoq.Mock.ofType<IDocumentManager>();
6268
applicationShell = TypeMoq.Mock.ofType<IApplicationShell>();
6369
const envVariablesProvider = TypeMoq.Mock.ofType<IEnvironmentVariablesProvider>();
6470
processService = TypeMoq.Mock.ofType<IProcessService>();
6571
interpreterService = TypeMoq.Mock.ofType<IInterpreterService>();
66-
72+
activeResourceService = TypeMoq.Mock.ofType<IActiveResourceService>();
73+
pythonSettings = TypeMoq.Mock.ofType<IPythonSettings>();
74+
const resource = Uri.parse('a');
6775
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6876
processService.setup((x: any) => x.then).returns(() => undefined);
6977
interpreterService
@@ -95,6 +103,24 @@ suite('Terminal - Code Execution Helper', () => {
95103
serviceContainer
96104
.setup((c) => c.get(TypeMoq.It.isValue(IEnvironmentVariablesProvider), TypeMoq.It.isAny()))
97105
.returns(() => envVariablesProvider.object);
106+
serviceContainer
107+
.setup((c) => c.get(TypeMoq.It.isValue(IConfigurationService)))
108+
.returns(() => configurationService.object);
109+
serviceContainer
110+
.setup((c) => c.get(TypeMoq.It.isValue(IActiveResourceService)))
111+
.returns(() => activeResourceService.object);
112+
activeResourceService.setup((a) => a.getActiveResource()).returns(() => resource);
113+
pythonSettings.setup((s) => s.REPL).returns(() => ({ enableREPLSmartSend: false, REPLSmartSend: false }));
114+
configurationService.setup((x) => x.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object);
115+
configurationService
116+
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
117+
.returns({
118+
REPL: {
119+
EnableREPLSmartSend: false,
120+
REPLSmartSend: false,
121+
},
122+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
123+
} as any);
98124
helper = new CodeExecutionHelper(serviceContainer.object);
99125

100126
document = TypeMoq.Mock.ofType<TextDocument>();
@@ -118,6 +144,15 @@ suite('Terminal - Code Execution Helper', () => {
118144
});
119145

120146
async function ensureCodeIsNormalized(source: string, expectedSource: string) {
147+
configurationService
148+
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
149+
.returns({
150+
REPL: {
151+
EnableREPLSmartSend: false,
152+
REPLSmartSend: false,
153+
},
154+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
155+
} as any);
121156
const actualProcessService = new ProcessService();
122157
processService
123158
.setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
@@ -131,6 +166,15 @@ suite('Terminal - Code Execution Helper', () => {
131166

132167
['', '1', '2', '3', '4', '5', '6', '7', '8'].forEach((fileNameSuffix) => {
133168
test(`Ensure code is normalized (Sample${fileNameSuffix})`, async () => {
169+
configurationService
170+
.setup((c) => c.getSettings(TypeMoq.It.isAny()))
171+
.returns({
172+
REPL: {
173+
EnableREPLSmartSend: false,
174+
REPLSmartSend: false,
175+
},
176+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
177+
} as any);
134178
const code = await fs.readFile(path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_raw.py`), 'utf8');
135179
const expectedCode = await fs.readFile(
136180
path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_normalized_selection.py`),

0 commit comments

Comments
 (0)