()
| 93 | } |
| 94 | |
| 95 | private watchExtensionChanges() { |
| 96 | let hadPyEnvs = !!vscode.extensions.getExtension( |
| 97 | 'ms-python.vscode-python-envs', |
| 98 | ); |
| 99 | let hadMsPython = !!vscode.extensions.getExtension('ms-python.python'); |
| 100 | |
| 101 | this.context.subscriptions.push( |
| 102 | vscode.extensions.onDidChange(() => { |
| 103 | const hasPyEnvs = !!vscode.extensions.getExtension( |
| 104 | 'ms-python.vscode-python-envs', |
| 105 | ); |
| 106 | const hasMsPython = !!vscode.extensions.getExtension( |
| 107 | 'ms-python.python', |
| 108 | ); |
| 109 | |
| 110 | if (hasPyEnvs === hadPyEnvs && hasMsPython === hadMsPython) { |
| 111 | return; |
| 112 | } |
| 113 | hadPyEnvs = hasPyEnvs; |
| 114 | hadMsPython = hasMsPython; |
| 115 | |
| 116 | this.tryResolveProvider() |
| 117 | .then(provider => { |
| 118 | for (const d of this.listenerDisposables) { |
| 119 | d.dispose(); |
| 120 | } |
| 121 | this.listenerDisposables = []; |
| 122 | |
| 123 | this.provider = Promise.resolve(provider); |
| 124 | |
| 125 | if (provider) { |
| 126 | for (const listener of this.listeners) { |
| 127 | listener(); |
| 128 | this.listenerDisposables.push( |
| 129 | provider.onDidChange(listener), |
| 130 | ); |
| 131 | } |
| 132 | } |
| 133 | }) |
| 134 | .catch(() => {}); |
| 135 | }), |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | async getInterpreterPath(uri?: vscode.Uri): Promise<string | undefined> { |
| 140 | const provider = await this.provider; |
no test coverage detected