* This function adds the pythonPath to any section with configuration of 'python'. * Our language server expects the pythonPath from VSCode configurations but this setting is not stored in VSCode * configurations. The Python extension used to store pythonPath in this section but no longer does. De
( pythonEnv: PythonEnvironment, configurationItems: ConfigurationItem[], configuration: (object | null)[], )
| 59 | * - {setting: 'value', pythonPath: '/usr/bin/python3'} is returned |
| 60 | */ |
| 61 | async function overridePythonPath( |
| 62 | pythonEnv: PythonEnvironment, |
| 63 | configurationItems: ConfigurationItem[], |
| 64 | configuration: (object | null)[], |
| 65 | ): Promise<(object | null)[]> { |
| 66 | const newResult = await Promise.all( |
| 67 | configuration.map(async (item, index) => { |
| 68 | if ( |
| 69 | configurationItems.length <= index || |
| 70 | configurationItems[index].section !== 'python' |
| 71 | ) { |
| 72 | return item; |
| 73 | } |
| 74 | const scopeUri = configurationItems[index].scopeUri; |
| 75 | const pythonPath = await pythonEnv.getInterpreterPath( |
| 76 | scopeUri === undefined ? undefined : vscode.Uri.parse(scopeUri), |
| 77 | ); |
| 78 | if (pythonPath === undefined) { |
| 79 | return item; |
| 80 | } |
| 81 | return {...item, pythonPath}; |
| 82 | }), |
| 83 | ); |
| 84 | return newResult; |
| 85 | } |
| 86 | |
| 87 | export async function activate(context: ExtensionContext) { |
| 88 | // Initialize the output channel if it doesn't exist |
no test coverage detected