diff --git a/src/features/terminal/utils.ts b/src/features/terminal/utils.ts index 866a7486..935dce95 100644 --- a/src/features/terminal/utils.ts +++ b/src/features/terminal/utils.ts @@ -392,7 +392,7 @@ export type AutoActivationType = 'off' | 'command' | 'shellStartup'; * a. globalRemoteValue * b. globalLocalValue * c. globalValue - * 2. python.terminal.activateEnvironment setting (if false, returns 'off' & sets autoActivationType to 'off') + * 2. python.terminal.activateEnvironment setting (if false, returns 'off') * 3. Default to 'command' if no setting is found * * @returns {AutoActivationType} The determined auto-activation type @@ -420,8 +420,6 @@ export function getAutoActivationType(): AutoActivationType { const pythonConfig = getConfiguration('python'); const pythonActivateSetting = pythonConfig.get('terminal.activateEnvironment', undefined); if (pythonActivateSetting === false) { - // Set autoActivationType to 'off' if python.terminal.activateEnvironment is false - pyEnvsConfig.update('terminal.autoActivationType', ACT_TYPE_OFF); return ACT_TYPE_OFF; } diff --git a/src/test/features/terminal/utils.unit.test.ts b/src/test/features/terminal/utils.unit.test.ts index ff890a56..e999c0a5 100644 --- a/src/test/features/terminal/utils.unit.test.ts +++ b/src/test/features/terminal/utils.unit.test.ts @@ -484,7 +484,7 @@ suite('Terminal Utils - getAutoActivationType', () => { }); suite('Legacy Python Setting Fallback', () => { - test('should return ACT_TYPE_OFF and update config when python.terminal.activateEnvironment is false', () => { + test('should return ACT_TYPE_OFF without writing config when python.terminal.activateEnvironment is false', () => { // Mock - no python-envs settings, python.terminal.activateEnvironment is false pyEnvsConfig.inspect.withArgs('terminal.autoActivationType').returns(undefined); pythonConfig.get.withArgs('terminal.activateEnvironment', undefined).returns(false); @@ -494,10 +494,26 @@ suite('Terminal Utils - getAutoActivationType', () => { // Assert assert.strictEqual(result, ACT_TYPE_OFF, 'Should return ACT_TYPE_OFF when legacy setting is false'); - assert.ok( - pyEnvsConfig.update.calledWithExactly('terminal.autoActivationType', ACT_TYPE_OFF), - 'Should update python-envs config to ACT_TYPE_OFF', - ); + sinon.assert.notCalled(pyEnvsConfig.update); + }); + + test('should follow changes to the legacy setting without persisting an override', () => { + pyEnvsConfig.inspect.withArgs('terminal.autoActivationType').returns(undefined); + pythonConfig.get.withArgs('terminal.activateEnvironment', undefined).onFirstCall().returns(false); + pythonConfig.get.withArgs('terminal.activateEnvironment', undefined).onSecondCall().returns(true); + + assert.strictEqual(getAutoActivationType(), ACT_TYPE_OFF); + assert.strictEqual(getAutoActivationType(), ACT_TYPE_COMMAND); + sinon.assert.notCalled(pyEnvsConfig.update); + }); + + test('should keep an explicit activation mode when the legacy setting is false', () => { + pyEnvsConfig.inspect.withArgs('terminal.autoActivationType').returns({ globalValue: ACT_TYPE_SHELL }); + pythonConfig.get.withArgs('terminal.activateEnvironment', undefined).returns(false); + + assert.strictEqual(getAutoActivationType(), ACT_TYPE_SHELL); + sinon.assert.notCalled(pythonConfig.get); + sinon.assert.notCalled(pyEnvsConfig.update); }); test('should return ACT_TYPE_COMMAND when python.terminal.activateEnvironment is true', () => {