Skip to content

Commit 1cc7eec

Browse files
committed
Add the missing remote
1 parent 147bf2f commit 1cc7eec

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

src/features/terminal/utils.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,16 @@ export async function setAutoActivationType(value: AutoActivationType): Promise<
263263
}
264264

265265
/**
266-
* Determines whether activation commands should be sent to the currently focused terminal and previous terminal.
267-
* Checks the legacy `python.terminal.activateEnvInCurrentTerminal` setting.
266+
* Determines whether activation commands should be sent to pre-existing terminals
267+
* (terminals open before extension load).
268268
*
269-
* - If the user has explicitly set the value to `false` at any scope
270-
* (global, workspace, or workspace folder), returns `false`.
269+
* Checks the legacy `python.terminal.activateEnvInCurrentTerminal` setting using `inspect()`
270+
* to distinguish between the default value and an explicitly user-set value.
271+
*
272+
* Priority: workspaceFolderValue > workspaceValue > globalRemoteValue > globalLocalValue > globalValue
273+
* (matches the precedence used by getShellIntegrationEnabledCache and getAutoActivationType)
274+
*
275+
* - If the user has explicitly set the value to `false` at any scope, returns `false`.
271276
* - Otherwise (default or explicitly `true`), returns `true`.
272277
*
273278
* @returns `false` only when the user has explicitly set the setting to `false`; `true` otherwise.
@@ -280,14 +285,22 @@ export function shouldActivateInCurrentTerminal(): boolean {
280285
return true;
281286
}
282287

283-
// Check explicit user-set values at each scope (highest precedence first).
284288
// Only respect `false` when the user has deliberately set it.
289+
// Priority: workspaceFolder > workspace > globalRemote > globalLocal > global
290+
const inspectValue = inspected as Record<string, unknown>;
291+
285292
if (inspected.workspaceFolderValue === false) {
286293
return false;
287294
}
288295
if (inspected.workspaceValue === false) {
289296
return false;
290297
}
298+
if ('globalRemoteValue' in inspected && inspectValue.globalRemoteValue === false) {
299+
return false;
300+
}
301+
if ('globalLocalValue' in inspected && inspectValue.globalLocalValue === false) {
302+
return false;
303+
}
291304
if (inspected.globalValue === false) {
292305
return false;
293306
}

src/test/features/terminal/utils.unit.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,55 @@ suite('Terminal Utils - shouldActivateInCurrentTerminal', () => {
477477
'workspaceFolderValue false should take precedence',
478478
);
479479
});
480+
481+
test('should return false when globalRemoteValue is explicitly false', () => {
482+
pythonConfig.inspect.withArgs('terminal.activateEnvInCurrentTerminal').returns({
483+
key: 'terminal.activateEnvInCurrentTerminal',
484+
defaultValue: false,
485+
globalRemoteValue: false,
486+
globalValue: undefined,
487+
workspaceValue: undefined,
488+
workspaceFolderValue: undefined,
489+
});
490+
491+
assert.strictEqual(
492+
shouldActivateInCurrentTerminal(),
493+
false,
494+
'Should return false when user explicitly set globalRemoteValue to false',
495+
);
496+
});
497+
498+
test('should return false when globalLocalValue is explicitly false', () => {
499+
pythonConfig.inspect.withArgs('terminal.activateEnvInCurrentTerminal').returns({
500+
key: 'terminal.activateEnvInCurrentTerminal',
501+
defaultValue: false,
502+
globalLocalValue: false,
503+
globalValue: undefined,
504+
workspaceValue: undefined,
505+
workspaceFolderValue: undefined,
506+
});
507+
508+
assert.strictEqual(
509+
shouldActivateInCurrentTerminal(),
510+
false,
511+
'Should return false when user explicitly set globalLocalValue to false',
512+
);
513+
});
514+
515+
test('workspaceValue false takes precedence over globalRemoteValue true', () => {
516+
pythonConfig.inspect.withArgs('terminal.activateEnvInCurrentTerminal').returns({
517+
key: 'terminal.activateEnvInCurrentTerminal',
518+
defaultValue: false,
519+
globalRemoteValue: true,
520+
globalValue: undefined,
521+
workspaceValue: false,
522+
workspaceFolderValue: undefined,
523+
});
524+
525+
assert.strictEqual(
526+
shouldActivateInCurrentTerminal(),
527+
false,
528+
'workspaceValue false should take precedence over globalRemoteValue true',
529+
);
530+
});
480531
});

0 commit comments

Comments
 (0)