-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent unnecessary activation of the Python extension #5199
Conversation
) { | ||
const previouslyInstalled = this.extensionChecker.isPythonExtensionInstalled; | ||
if (!previouslyInstalled) { | ||
this.extensions.onDidChange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the extension is subsequently installed, then register the hooks
Codecov Report
@@ Coverage Diff @@
## main #5199 +/- ##
=====================================
- Coverage 73% 73% -1%
=====================================
Files 402 402
Lines 26403 26456 +53
Branches 3799 3809 +10
=====================================
- Hits 19432 19429 -3
- Misses 5403 5444 +41
- Partials 1568 1583 +15
|
.catch(noop); | ||
if (this.extensionChecker.isPythonExtensionInstalled) { | ||
if (this.extensionChecker.isPythonExtensionActive && this.eventHandlerAdded) { | ||
this.hookupOnDidChangeInterpreterEvent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add event handlers only if extension has been activated, and add it later once python loads.
@@ -220,11 +216,6 @@ export class NativeEditorStorage implements INotebookStorage { | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
return (notebookData.metadata.language_info.codemirror_mode as any).version; | |||
} | |||
// Use the active interpreter if allowed | |||
if (this.extensionChecker.isPythonExtensionInstalled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally unnecessary, we're just storing this in metadata for language, today we generate all of this information from the kernel, hence we have more accurate information than this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this was more stuff that slowed down notebooks, unnecessary when creating blank notebooks.
@@ -19,12 +19,14 @@ export interface ILanguageServer extends Disposable { | |||
|
|||
export const IPythonApiProvider = Symbol('IPythonApi'); | |||
export interface IPythonApiProvider { | |||
onDidActivatePythonExtension: Event<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure if I'm suggesting this. But does this seem to you like it should be on IPythonExtensionChecker? That has everything relevant to checking if the extension is installed or active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No can do, its the PythonApiProvider that activates the Python extension. So only PythonAPIProvider knows if the python extension was activated or not.
VS Code doesn't fire events when extensions load.
Here we're only interested in situations when we load the python extension & other parts of the code can then react to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid. Just had one question on the interfaces and one spot that looked like maybe a bug with the event hookup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on check that active interpreter is still used for interactive window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on check that active interpreter is still used for interactive window
Don't quite follow this comment.
See the comment in localKernelFinder.ts |
Somehow that comment was missing when i replied. anyways. |
For #5193