Skip to content
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

Add Interactive REPL Experiment #23235

Merged
merged 40 commits into from
May 16, 2024
Merged

Conversation

anthonykim1
Copy link

@anthonykim1 anthonykim1 commented Apr 15, 2024

Allow users to use Interactive Window UI with Python custom REPL controller instead of iPykernel.
Closes #23175
Closes #23174
Closes #23029
Majority of: #23332

Context menu under Python for running Python REPL code using IW UI should only appear when user's pythonRunREPL experiment is enabled.

@anthonykim1 anthonykim1 self-assigned this Apr 15, 2024
@anthonykim1 anthonykim1 added the feature-request Request for new features or functionality label Apr 15, 2024
package.json Outdated
{
"command": "python.execInREPL",
"group": "Python",
"when": "editorFocus && editorLangId == python && !virtualWorkspace && shellExecutionSupported"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also need “not in interactive”
?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "not in interactive" referring to IW only with Jupyter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think #23389 was what we were talking about??

@anthonykim1 anthonykim1 added the skip package*.json package.json and package-lock.json don't both need updating label May 7, 2024
@anthonykim1 anthonykim1 marked this pull request as ready for review May 16, 2024 01:43
@anthonykim1 anthonykim1 requested a review from amunger May 16, 2024 01:43
@vscodenpa vscodenpa added this to the May 2024 milestone May 16, 2024
@@ -105,6 +108,17 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
interpreterService,
pathUtils,
);

// Register native REPL context menu when in experiment
const experimentService = ext.legacyIOC.serviceContainer.get<IExperimentService>(IExperimentService);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy IOC? is there a newer one to use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually in other files in Python extension if we were to use serviceContainer, we access it via IServiceContainer, which we still could I believe if we register the REPL command in other file? I just thought extensionActivation was the best place to register command and read experiment service since it seemed like the fastest/prioritized when extension loads.

const notebookEdit = NotebookEdit.insertCells(cellCount, [notebookCellData]);
const workspaceEdit = new WorkspaceEdit();
workspaceEdit.set(notebookDocument.uri, [notebookEdit]);
workspace.applyEdit(workspaceEdit);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this returns a thenable, might need to await this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, just added a commit for this!

amunger
amunger previously approved these changes May 16, 2024
@anthonykim1 anthonykim1 merged commit 6997f7b into microsoft:main May 16, 2024
37 checks passed
anthonykim1 added a commit to anthonykim1/vscode-python that referenced this pull request May 16, 2024
Allow users to use Interactive Window UI with Python custom REPL
controller instead of iPykernel.
Closes microsoft#23175
Closes microsoft#23174 
Closes microsoft#23029
Majority of: microsoft#23332 

Context menu under Python for running Python REPL code using IW UI
should only appear when user's ```pythonRunREPL``` experiment is
enabled.
anthonykim1 added a commit that referenced this pull request May 24, 2024
… UI (#23442)

"Smartly" allow execute on enter for the
#23235 experiment.
User should be able to execute when they press enter on text input box
of interactive window trigger from Python extension, whereas we would
"wait" and allow insertion of new line after detecting user's Python
command is not complete.

When the user finally types enter again on a blank line, we should just
proceed to execute whatever code, regardless of whether it is
complete/valid or not to replicate Python's original interactive REPL
behavior.

Basically creating Python command and registering that for keybinding of
'Enter'.
This would conditionally call interactive.execute which would then
eventually call our execute handler contributed from Python n
extension's REPL controller, or go ahead and insert,pass in Enter to the
text input box to allow user to type "complete" code.



This PR only intends to implement/add changes regarding execute on enter
logic, adding Intellisense support, and also adding things into
disposables so they can be properly disposed. Trying to also add setting
to allow toggling on/off to send Python command to Terminal or IW REPL
if the user is in experiment.


Handling of interrupt for windows should be on separate PR.
Test will be added later as separate PR.

---------

Co-authored-by: Courtney Webster <[email protected]>
Co-authored-by: Karthik Nadig <[email protected]>
DonJayamanne pushed a commit to DonJayamanne/pythonVSCode that referenced this pull request Jun 24, 2024
… UI (#23442)

"Smartly" allow execute on enter for the
microsoft#23235 experiment.
User should be able to execute when they press enter on text input box
of interactive window trigger from Python extension, whereas we would
"wait" and allow insertion of new line after detecting user's Python
command is not complete.

When the user finally types enter again on a blank line, we should just
proceed to execute whatever code, regardless of whether it is
complete/valid or not to replicate Python's original interactive REPL
behavior.

Basically creating Python command and registering that for keybinding of
'Enter'.
This would conditionally call interactive.execute which would then
eventually call our execute handler contributed from Python n
extension's REPL controller, or go ahead and insert,pass in Enter to the
text input box to allow user to type "complete" code.



This PR only intends to implement/add changes regarding execute on enter
logic, adding Intellisense support, and also adding things into
disposables so they can be properly disposed. Trying to also add setting
to allow toggling on/off to send Python command to Terminal or IW REPL
if the user is in experiment.


Handling of interrupt for windows should be on separate PR.
Test will be added later as separate PR.

---------

Co-authored-by: Courtney Webster <[email protected]>
Co-authored-by: Karthik Nadig <[email protected]>
DonJayamanne pushed a commit that referenced this pull request Jun 24, 2024
Allow users to use Interactive Window UI with Python custom REPL
controller instead of iPykernel.
Closes #23175
Closes #23174 
Closes #23029
Majority of: #23332 

Context menu under Python for running Python REPL code using IW UI
should only appear when user's ```pythonRunREPL``` experiment is
enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-repl feature-request Request for new features or functionality skip package*.json package.json and package-lock.json don't both need updating
Projects
None yet
4 participants