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

Improvements to “Execute Line in Console” feature in PyCharm. #711

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

guoci
Copy link
Contributor

@guoci guoci commented Jan 18, 2018

This PR suggests some improvements to the “Execute Line in Console” feature in PyCharm. Currently, that feature submits a line to the Python console, even when the line is an incomplete input. A screencast demonstrating the new feature in this PR is shown below.
demo
pycharm_pull_request_demo

In this PR, the following changes are implemented:

When the cursor is on a line and that line is an incomplete input, submit a minimum amount of lines to produce a complete input.

After that, the cursor in the editor is advanced accordingly.

Because of my unfamiliarity with the source code, I have used some code that is clearly not acceptable. I would appreciate if the reviewers can help with improving the code.

@guoci
Copy link
Contributor Author

guoci commented Feb 2, 2018

I have attached a video clip above to help visualize the feature.

@guoci guoci force-pushed the master branch 5 times, most recently from 29e3e78 to 4a721d4 Compare March 21, 2018 22:56
@guoci guoci force-pushed the master branch 4 times, most recently from 43fa9b2 to eae05a2 Compare March 30, 2018 19:43
@guoci guoci force-pushed the master branch 4 times, most recently from e42d4a1 to 267e685 Compare April 9, 2018 20:08
@guoci guoci force-pushed the master branch 5 times, most recently from 4ed307d to 935df01 Compare April 12, 2018 14:34
@guoci guoci force-pushed the master branch 7 times, most recently from 328717b to 23aa74f Compare April 25, 2018 15:53
@guoci guoci force-pushed the master branch 2 times, most recently from bd60b56 to 074bbc0 Compare April 28, 2018 14:28
@guoci guoci force-pushed the master branch 3 times, most recently from 8fa79f5 to a97dbee Compare November 15, 2018 19:03
@guoci
Copy link
Contributor Author

guoci commented Jan 17, 2019

@Elizaveta239 is this PR ok? Let me know if I need to do more.

@Elizaveta239
Copy link
Contributor

Hi @guoci! Yes, the PR is ok, thank you! The feature looks interesting, but we still can't estimate its usefulness.
Why don't you want to publish it as a separate plugin and share it within JetBrains plugin repository? If it's popular, we'll merge it into PyCharm code base.

@guoci
Copy link
Contributor Author

guoci commented Jan 23, 2019

@Elizaveta239 thanks! I will need some time to get that done.

@guoci
Copy link
Contributor Author

guoci commented Jan 31, 2019

@Elizaveta239 where are the instructions for creating a PyCharm plugin? I can find one for creating a Intellij plugin https://www.jetbrains.org/intellij/sdk/docs/, but not for a PyCharm plugin.

@Elizaveta239
Copy link
Contributor

@guoci In fact all PyCharm plugins are Intellij IDEA plugins. So you should develop it as IDEA plugin, and mention in settings, that your plugin is compatible only with PyCharm, not with other Intellij-based IDEs.

We even had a webinar about plugin development recently: https://blog.jetbrains.com/pycharm/2019/01/webinar-recording-live-development-of-a-pycharm-plugin-with-joachim-ansorg/
So you can follow steps from it: https://github.com/jansorg/pycharm-webinar-base

@guoci
Copy link
Contributor Author

guoci commented Feb 3, 2019

Now published as PyCharm plugin.
https://plugins.jetbrains.com/plugin/11945-python-smart-execute

@Elizaveta239
Copy link
Contributor

Great news! Usually plugin approval takes a few days, I'll ask to make it faster.
Thank you very much for your contribution!

@carlosahumada89
Copy link

Hi @guoci. I just wanted to thank you for he creation of this plugin. For those of us who are learning Python after a background in R, this comes very very handy. Thanks!

@avli avli self-assigned this Aug 13, 2019
@guoci
Copy link
Contributor Author

guoci commented Aug 30, 2019

@carlosahumada89 Thanks. Me too, I tried to implement this feature to emulate RStudio's Run Selected Line(s) Crtl+Enter feature. Since Python is not a curly-brace language, the implementation is more complicated.

AFAIK, no Python IDE has this feature.

@Jmarks199
Copy link

Jmarks199 commented Aug 30, 2019 via email

@guoci
Copy link
Contributor Author

guoci commented Aug 30, 2019

@Jmarks199 yes, I am the author of that plugin, link below. The code is based on this PR.
https://plugins.jetbrains.com/plugin/11945-python-smart-execute

@vladimir-koshelev
Copy link
Contributor

@guoci @Elizaveta239 @Traff Maybe it's time to merge it? I've just implemented pretty the same feature for R plugin. Looks like that's really useful for DataScience mode.

@Elizaveta239
Copy link
Contributor

@vedun-z Sure, but at the moment it requires some steps from one of the JetBrains team members. We need to:

  • find a shortcut, which doesn't overlap any other action from Intellij IDEA Ultimate (currently Alt + Shift + A overlaps "Show all affected files" action)
  • create a build from this branch and pass it to QA team
  • make fixes after testing
  • review code and find possible issues there

Unfortunately, I'm currently busy with other tasks. @vedun-z You're welcome to do these steps.

@vladimir-koshelev
Copy link
Contributor

@Elizaveta239 Thank you for great opportunity, but as long as this feature are not going to 2019.3 anyway, there's no reason to rush. We could schedule it to 2020.1, what do you think?

@Elizaveta239
Copy link
Contributor

Sure! I've created a feature request for it: https://youtrack.jetbrains.com/issue/PY-38919

@Jmarks199
Copy link

@vedun-z @Elizaveta239 it would be nice to get this going again. It's really surprising this hasn't been added as a feature. The real question is, why would anyone ever want to use the default execute in console functionality? Personally, I can't imagine using Pycharm without this feature and the plugin seems to be broken in version 2021.3.

java.lang.NoSuchMethodError: 'void com.jetbrains.python.actions.PyExecuteSelectionAction.showConsoleAndExecuteCode(com.intellij.openapi.actionSystem.AnActionEvent, java.lang.String)'

@guoci
Copy link
Contributor Author

guoci commented Dec 5, 2021

I have just uploaded an update, currently pending approval from JetBrains.
@Jmarks199 Thanks for reporting, you can download it here before the approval.

@guoci
Copy link
Contributor Author

guoci commented Dec 7, 2021

For code to the plugin, see https://github.com/guoci/pycharm-smart-execute.
The code in this PR is no longer working due to API changes.

@Jmarks199
Copy link

@guoci thanks for fixing this! Working beautifully. Much appreciated.

@iamqiz
Copy link

iamqiz commented Jun 26, 2022

@guoci good job! thanks!

@guoci
Copy link
Contributor Author

guoci commented Jun 4, 2023

Hi PyCharm developers,
Is there anything I can do to help this plugin be merged into PyCharm as a built-in feature? Or do you prefer it to be separate from the PyCharm code?

@Elizaveta239 Elizaveta239 removed their assignment Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants