@@ -10,7 +10,7 @@ import {
1010import { PythonProject } from '../../api' ;
1111import { DEFAULT_ENV_MANAGER_ID , DEFAULT_PACKAGE_MANAGER_ID } from '../../common/constants' ;
1212import { traceError , traceInfo , traceWarn } from '../../common/logging' ;
13- import { getWorkspaceFile , getWorkspaceFolders } from '../../common/workspace.apis' ;
13+ import { getConfiguration , getWorkspaceFile , getWorkspaceFolders } from '../../common/workspace.apis' ;
1414import { PythonProjectManager , PythonProjectSettings } from '../../internal.api' ;
1515
1616function getSettings (
@@ -393,3 +393,77 @@ export async function removePythonProjectSetting(edits: EditProjectSettings[]):
393393 } ) ;
394394 await Promise . all ( promises ) ;
395395}
396+
397+ /**
398+ * Gets user-configured setting for window-scoped settings.
399+ * Priority order: globalRemoteValue > globalLocalValue > globalValue
400+ * @param section - The configuration section (e.g., 'python-envs')
401+ * @param key - The configuration key (e.g., 'terminal.autoActivationType')
402+ * @returns The user-configured value or undefined if not set by user
403+ */
404+ export function getSettingWindowScope < T > ( section : string , key : string ) : T | undefined {
405+ const config = getConfiguration ( section ) ;
406+ const inspect = config . inspect < T > ( key ) ;
407+ if ( ! inspect ) {
408+ return undefined ;
409+ }
410+
411+ const inspectRecord = inspect as Record < string , unknown > ;
412+ if ( 'globalRemoteValue' in inspect && inspectRecord . globalRemoteValue !== undefined ) {
413+ return inspectRecord . globalRemoteValue as T ;
414+ }
415+ if ( 'globalLocalValue' in inspect && inspectRecord . globalLocalValue !== undefined ) {
416+ return inspectRecord . globalLocalValue as T ;
417+ }
418+ if ( inspect . globalValue !== undefined ) {
419+ return inspect . globalValue ;
420+ }
421+ return undefined ;
422+ }
423+
424+ /**
425+ * Gets user-configured setting for workspace-scoped settings.
426+ * Priority order: workspaceFolderValue > workspaceValue > globalValue
427+ * @param section - The configuration section (e.g., 'python')
428+ * @param key - The configuration key (e.g., 'pipenvPath')
429+ * @param scope - Optional URI scope for workspace folder-specific settings
430+ * @returns The user-configured value or undefined if not set by user
431+ */
432+ export function getSettingWorkspaceScope < T > ( section : string , key : string , scope ?: Uri ) : T | undefined {
433+ const config = getConfiguration ( section , scope ) ;
434+ const inspect = config . inspect < T > ( key ) ;
435+ if ( ! inspect ) {
436+ return undefined ;
437+ }
438+
439+ if ( inspect . workspaceFolderValue !== undefined ) {
440+ return inspect . workspaceFolderValue ;
441+ }
442+ if ( inspect . workspaceValue !== undefined ) {
443+ return inspect . workspaceValue ;
444+ }
445+ if ( inspect . globalValue !== undefined ) {
446+ return inspect . globalValue ;
447+ }
448+ return undefined ;
449+ }
450+
451+ /**
452+ * Gets user-configured setting for user-scoped settings.
453+ * Only checks globalValue (ignores defaultValue).
454+ * @param section - The configuration section (e.g., 'python')
455+ * @param key - The configuration key (e.g., 'pipenvPath')
456+ * @returns The user-configured value or undefined if not set by user
457+ */
458+ export function getSettingUserScope < T > ( section : string , key : string ) : T | undefined {
459+ const config = getConfiguration ( section ) ;
460+ const inspect = config . inspect < T > ( key ) ;
461+ if ( ! inspect ) {
462+ return undefined ;
463+ }
464+
465+ if ( inspect . globalValue !== undefined ) {
466+ return inspect . globalValue ;
467+ }
468+ return undefined ;
469+ }
0 commit comments