From 354560b6e9855e2d65e82dd237019d8e85234205 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 13:42:50 -0700 Subject: [PATCH 01/11] smart send default to true --- src/client/terminals/codeExecution/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/terminals/codeExecution/helper.ts b/src/client/terminals/codeExecution/helper.ts index 335401221bdb..880da969d690 100644 --- a/src/client/terminals/codeExecution/helper.ts +++ b/src/client/terminals/codeExecution/helper.ts @@ -92,7 +92,7 @@ export class CodeExecutionHelper implements ICodeExecutionHelper { const startLineVal = activeEditor?.selection?.start.line ?? 0; const endLineVal = activeEditor?.selection?.end.line ?? 0; const emptyHighlightVal = activeEditor?.selection?.isEmpty ?? true; - let smartSendSettingsEnabledVal = false; + let smartSendSettingsEnabledVal = true; const configuration = this.serviceContainer.get(IConfigurationService); if (configuration) { const pythonSettings = configuration.getSettings(this.activeResourceService.getActiveResource()); From 649b8f6daa203b808053638b8ed5186a3c5b38d4 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:02:59 -0700 Subject: [PATCH 02/11] fix test --- src/test/terminals/codeExecution/helper.test.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index 2922fe9a7ef4..194c4ab90c42 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -23,6 +23,7 @@ import { IProcessServiceFactory, ObservableExecutionResult, } from '../../../client/common/process/types'; +import { IConfigurationService, IPythonSettings } from '../../../client/common/types'; import { Architecture } from '../../../client/common/utils/platform'; import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types'; import { IInterpreterService } from '../../../client/interpreter/contracts'; @@ -44,6 +45,8 @@ suite('Terminal - Code Execution Helper', () => { let interpreterService: TypeMoq.IMock; let commandManager: TypeMoq.IMock; let workspaceService: TypeMoq.IMock; + let configurationService: TypeMoq.IMock; + let pythonSettings: TypeMoq.IMock; const workingPython: PythonEnvironment = { path: PYTHON_PATH, version: new SemVer('3.6.6-final'), @@ -57,6 +60,7 @@ suite('Terminal - Code Execution Helper', () => { setup(() => { const serviceContainer = TypeMoq.Mock.ofType(); commandManager = TypeMoq.Mock.ofType(); + configurationService = TypeMoq.Mock.ofType(); workspaceService = TypeMoq.Mock.ofType(); documentManager = TypeMoq.Mock.ofType(); applicationShell = TypeMoq.Mock.ofType(); @@ -95,8 +99,11 @@ suite('Terminal - Code Execution Helper', () => { serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IEnvironmentVariablesProvider), TypeMoq.It.isAny())) .returns(() => envVariablesProvider.object); + serviceContainer + .setup((c) => c.get(TypeMoq.It.isValue(IConfigurationService))) + .returns(() => configurationService.object); helper = new CodeExecutionHelper(serviceContainer.object); - + configurationService.setup((x) => x.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object); document = TypeMoq.Mock.ofType(); editor = TypeMoq.Mock.ofType(); editor.setup((e) => e.document).returns(() => document.object); @@ -131,6 +138,14 @@ suite('Terminal - Code Execution Helper', () => { ['', '1', '2', '3', '4', '5', '6', '7', '8'].forEach((fileNameSuffix) => { test(`Ensure code is normalized (Sample${fileNameSuffix})`, async () => { + configurationService + .setup((c) => c.getSettings(TypeMoq.It.isAny())) + .returns({ + REPL: { + REPLSmartSend: false, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); const code = await fs.readFile(path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_raw.py`), 'utf8'); const expectedCode = await fs.readFile( path.join(TEST_FILES_PATH, `sample${fileNameSuffix}_normalized_selection.py`), From c46763ca57eb02a723661071d1480fc2a9d64915 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:09:23 -0700 Subject: [PATCH 03/11] try fix again --- src/test/terminals/codeExecution/helper.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index 194c4ab90c42..b3a22382c523 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -142,7 +142,7 @@ suite('Terminal - Code Execution Helper', () => { .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns({ REPL: { - REPLSmartSend: false, + REPLSmartSend: true, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); From fea2bb2616da78364c43c11e468adce8fa17d68b Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:16:40 -0700 Subject: [PATCH 04/11] try again2 --- src/test/terminals/codeExecution/helper.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index b3a22382c523..194c4ab90c42 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -142,7 +142,7 @@ suite('Terminal - Code Execution Helper', () => { .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns({ REPL: { - REPLSmartSend: true, + REPLSmartSend: false, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); From 42edd96283567689c92d05eff291284db927d627 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:25:57 -0700 Subject: [PATCH 05/11] add to configservice --- src/test/terminals/codeExecution/helper.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index 194c4ab90c42..fd9c7ce4fc1b 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -107,6 +107,14 @@ suite('Terminal - Code Execution Helper', () => { document = TypeMoq.Mock.ofType(); editor = TypeMoq.Mock.ofType(); editor.setup((e) => e.document).returns(() => document.object); + configurationService + .setup((c) => c.getSettings(TypeMoq.It.isAny())) + .returns({ + REPL: { + REPLSmartSend: false, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); }); test('normalizeLines should call normalizeSelection.py', async () => { From b24bffce06832a3000a7f9a96267e4389f0227c0 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:40:16 -0700 Subject: [PATCH 06/11] try adding EnableREPLSmartSend to false --- src/test/terminals/codeExecution/helper.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index fd9c7ce4fc1b..e59888bc2781 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -111,6 +111,7 @@ suite('Terminal - Code Execution Helper', () => { .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns({ REPL: { + EnableREPLSmartSend: false, REPLSmartSend: false, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -150,6 +151,7 @@ suite('Terminal - Code Execution Helper', () => { .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns({ REPL: { + EnableREPLSmartSend: false, REPLSmartSend: false, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any From 697653362ebff356aa685d629c2d09c27dd52c82 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 14:40:28 -0700 Subject: [PATCH 07/11] try adding EnableREPLS to false --- .vscode/launch.json | 2 +- package-lock.json | 11 +++++++++++ package.json | 9 +++++---- src/test/.vscode/settings.json | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 152ef1c87f60..1fe5fbfff374 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -101,7 +101,7 @@ "--extensionTestsPath=${workspaceFolder}/out/test" ], "env": { - "VSC_PYTHON_CI_TEST_GREP": "" // Modify this to run a subset of the single workspace tests + "VSC_PYTHON_CI_TEST_GREP": "Terminal - Code Execution Helper" // Modify this to run a subset of the single workspace tests }, "stopOnEntry": false, "sourceMaps": true, diff --git a/package-lock.json b/package-lock.json index a1f8267ffc06..eb4fa97462e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@vscode/extension-telemetry": "^0.8.4", "@vscode/jupyter-lsp-middleware": "^0.2.50", "arch": "^2.1.0", + "diff-match-patch": "^1.0.5", "fs-extra": "^10.0.1", "glob": "^7.2.0", "hash.js": "^1.1.7", @@ -4880,6 +4881,11 @@ "node": ">=0.3.1" } }, + "node_modules/diff-match-patch": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz", + "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==" + }, "node_modules/diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -19122,6 +19128,11 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, + "diff-match-patch": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz", + "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==" + }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", diff --git a/package.json b/package.json index c57dbd923755..de4c02889bb9 100644 --- a/package.json +++ b/package.json @@ -1245,10 +1245,10 @@ ], "menus": { "issue/reporter": [ - { - "command": "python.reportIssue" - } - ], + { + "command": "python.reportIssue" + } + ], "commandPalette": [ { "category": "Python", @@ -1549,6 +1549,7 @@ "@vscode/extension-telemetry": "^0.8.4", "@vscode/jupyter-lsp-middleware": "^0.2.50", "arch": "^2.1.0", + "diff-match-patch": "^1.0.5", "fs-extra": "^10.0.1", "glob": "^7.2.0", "hash.js": "^1.1.7", diff --git a/src/test/.vscode/settings.json b/src/test/.vscode/settings.json index faeb48ffa29c..65764d5f6132 100644 --- a/src/test/.vscode/settings.json +++ b/src/test/.vscode/settings.json @@ -13,5 +13,6 @@ "python.linting.banditEnabled": false, // Don't set this to `Pylance`, for CI we want to use the LS that ships with the extension. "python.languageServer": "Jedi", - "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe" + "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe", + "python.defaultInterpreterPath": "/Users/anthonykim/Desktop/vscode-python/.venv/bin/python" } From e0e4ba0f0d84aaba0c9352b34e21859600ee3083 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 15:13:31 -0700 Subject: [PATCH 08/11] Please work --- .../terminals/codeExecution/helper.test.ts | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/test/terminals/codeExecution/helper.test.ts b/src/test/terminals/codeExecution/helper.test.ts index e59888bc2781..2ea00e77c925 100644 --- a/src/test/terminals/codeExecution/helper.test.ts +++ b/src/test/terminals/codeExecution/helper.test.ts @@ -10,6 +10,7 @@ import { SemVer } from 'semver'; import * as TypeMoq from 'typemoq'; import { Position, Range, Selection, TextDocument, TextEditor, TextLine, Uri } from 'vscode'; import { + IActiveResourceService, IApplicationShell, ICommandManager, IDocumentManager, @@ -36,6 +37,7 @@ import { PYTHON_PATH } from '../../common'; const TEST_FILES_PATH = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'python_files', 'terminalExec'); suite('Terminal - Code Execution Helper', () => { + let activeResourceService: TypeMoq.IMock; let documentManager: TypeMoq.IMock; let applicationShell: TypeMoq.IMock; let helper: ICodeExecutionHelper; @@ -67,7 +69,9 @@ suite('Terminal - Code Execution Helper', () => { const envVariablesProvider = TypeMoq.Mock.ofType(); processService = TypeMoq.Mock.ofType(); interpreterService = TypeMoq.Mock.ofType(); - + activeResourceService = TypeMoq.Mock.ofType(); + pythonSettings = TypeMoq.Mock.ofType(); + const resource = Uri.parse('a'); // eslint-disable-next-line @typescript-eslint/no-explicit-any processService.setup((x: any) => x.then).returns(() => undefined); interpreterService @@ -102,11 +106,12 @@ suite('Terminal - Code Execution Helper', () => { serviceContainer .setup((c) => c.get(TypeMoq.It.isValue(IConfigurationService))) .returns(() => configurationService.object); - helper = new CodeExecutionHelper(serviceContainer.object); + serviceContainer + .setup((c) => c.get(TypeMoq.It.isValue(IActiveResourceService))) + .returns(() => activeResourceService.object); + activeResourceService.setup((a) => a.getActiveResource()).returns(() => resource); + pythonSettings.setup((s) => s.REPL).returns(() => ({ enableREPLSmartSend: false, REPLSmartSend: false })); configurationService.setup((x) => x.getSettings(TypeMoq.It.isAny())).returns(() => pythonSettings.object); - document = TypeMoq.Mock.ofType(); - editor = TypeMoq.Mock.ofType(); - editor.setup((e) => e.document).returns(() => document.object); configurationService .setup((c) => c.getSettings(TypeMoq.It.isAny())) .returns({ @@ -116,6 +121,11 @@ suite('Terminal - Code Execution Helper', () => { }, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); + helper = new CodeExecutionHelper(serviceContainer.object); + + document = TypeMoq.Mock.ofType(); + editor = TypeMoq.Mock.ofType(); + editor.setup((e) => e.document).returns(() => document.object); }); test('normalizeLines should call normalizeSelection.py', async () => { @@ -134,6 +144,15 @@ suite('Terminal - Code Execution Helper', () => { }); async function ensureCodeIsNormalized(source: string, expectedSource: string) { + configurationService + .setup((c) => c.getSettings(TypeMoq.It.isAny())) + .returns({ + REPL: { + EnableREPLSmartSend: false, + REPLSmartSend: false, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any); const actualProcessService = new ProcessService(); processService .setup((p) => p.execObservable(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) From 4c04e2136485904298d8b254f61a5d7f977edd4b Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 15:25:30 -0700 Subject: [PATCH 09/11] bring back OG package json --- .vscode/launch.json | 2 +- package-lock.json | 11 ----------- package.json | 9 ++++----- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1fe5fbfff374..152ef1c87f60 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -101,7 +101,7 @@ "--extensionTestsPath=${workspaceFolder}/out/test" ], "env": { - "VSC_PYTHON_CI_TEST_GREP": "Terminal - Code Execution Helper" // Modify this to run a subset of the single workspace tests + "VSC_PYTHON_CI_TEST_GREP": "" // Modify this to run a subset of the single workspace tests }, "stopOnEntry": false, "sourceMaps": true, diff --git a/package-lock.json b/package-lock.json index eb4fa97462e0..a1f8267ffc06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@vscode/extension-telemetry": "^0.8.4", "@vscode/jupyter-lsp-middleware": "^0.2.50", "arch": "^2.1.0", - "diff-match-patch": "^1.0.5", "fs-extra": "^10.0.1", "glob": "^7.2.0", "hash.js": "^1.1.7", @@ -4881,11 +4880,6 @@ "node": ">=0.3.1" } }, - "node_modules/diff-match-patch": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz", - "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==" - }, "node_modules/diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -19128,11 +19122,6 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, - "diff-match-patch": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz", - "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==" - }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", diff --git a/package.json b/package.json index de4c02889bb9..c57dbd923755 100644 --- a/package.json +++ b/package.json @@ -1245,10 +1245,10 @@ ], "menus": { "issue/reporter": [ - { - "command": "python.reportIssue" - } - ], + { + "command": "python.reportIssue" + } + ], "commandPalette": [ { "category": "Python", @@ -1549,7 +1549,6 @@ "@vscode/extension-telemetry": "^0.8.4", "@vscode/jupyter-lsp-middleware": "^0.2.50", "arch": "^2.1.0", - "diff-match-patch": "^1.0.5", "fs-extra": "^10.0.1", "glob": "^7.2.0", "hash.js": "^1.1.7", From 6b38992629fa7a8bb1d3d6e89dc0b19422e73c01 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 15:29:00 -0700 Subject: [PATCH 10/11] remove debris from testing --- src/test/.vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/.vscode/settings.json b/src/test/.vscode/settings.json index 65764d5f6132..36d3fd77195e 100644 --- a/src/test/.vscode/settings.json +++ b/src/test/.vscode/settings.json @@ -14,5 +14,4 @@ // Don't set this to `Pylance`, for CI we want to use the LS that ships with the extension. "python.languageServer": "Jedi", "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe", - "python.defaultInterpreterPath": "/Users/anthonykim/Desktop/vscode-python/.venv/bin/python" } From 5c804b84c93db807f4242833b260bb9ed70b26af Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 14 Mar 2024 15:29:18 -0700 Subject: [PATCH 11/11] one more --- src/test/.vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/.vscode/settings.json b/src/test/.vscode/settings.json index 36d3fd77195e..faeb48ffa29c 100644 --- a/src/test/.vscode/settings.json +++ b/src/test/.vscode/settings.json @@ -13,5 +13,5 @@ "python.linting.banditEnabled": false, // Don't set this to `Pylance`, for CI we want to use the LS that ships with the extension. "python.languageServer": "Jedi", - "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe", + "python.pythonPath": "C:\\GIT\\s p\\vscode-python\\.venv\\Scripts\\python.exe" }