Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/features/terminal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -420,8 +420,6 @@ export function getAutoActivationType(): AutoActivationType {
const pythonConfig = getConfiguration('python');
const pythonActivateSetting = pythonConfig.get<boolean | undefined>('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;
}

Expand Down
26 changes: 21 additions & 5 deletions src/test/features/terminal/utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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', () => {
Expand Down
Loading