guoci / pycharm-smart-execute

PyCharm plugin to execute python code
https://plugins.jetbrains.com/plugin/11945-python-smart-execute
GNU General Public License v3.0
9 stars 1 forks source link

Put cursor at anywhere in the code block features no longer work in 0.1.12 #3

Closed ntluong95 closed 1 year ago

ntluong95 commented 1 year ago

In versions 0.1.11, the introduction of "Execute and send cell code to the console" works very well with .ipynb, and coming with an expected feature that in .py file, you can put your cursor at anywhere in the code block and execute the action

Now in ver 0.1.12, this was broken. You have to highlight the whole code block. See the error I got

image
guoci commented 1 year ago

I am not getting any of the issues that you posted for 0.1.12. Did you restart your IDE after the plugin install? Also, consider posting your .ipynb file.

ntluong95 commented 1 year ago

Hi, you can find the sample dataset here: https://github.com/ntluong95/data/blob/main/smartexecute.ipynb https://github.com/ntluong95/data/blob/main/smartexecute.py

Let me guide you to reproduce the problem

  1. Work on .py file:

1a Put your cursor at any line in the file, run action "Execute cell in console", there is nothing happen with this file. But for another .py file, this give me the above error (it seems running all codes in the file). In version 0.1.11, running this action can run exactly the code block, which is unexpected but very useful 1b Now put your curse in line 8 to run the list my_cols with action "Execute selection in console", it runs correctly and the curse move to line 10 (blank line before the comments). My expectation is it can jump directly to next code block in line 17

  1. Work on .ipynb: Same as problem 1b

I am using Window 11, Python 3.11 and DataSpell EAP 2023.2

guoci commented 1 year ago

For 1a, you can use the DataSpell built-in "Execute Cell in Console" ctrl+enter. I will also make my plugin do the same as the built-in for easier use. 1b is implementable but needs some effort. Also, we have to consider users who may not want that behavior.

ntluong95 commented 1 year ago

For 1a, I didn't mean run the whole cell. Assume in the cell you have 2 code block, so if you put your cursor at any line in the second block and run action "Execute cell in console" from your plugin, it will send only this code block to the console.

guoci commented 1 year ago

A code block can be nested (indented), so I will need to assume you mean the top level (non indented) code block?

ntluong95 commented 1 year ago

yes taking this example, it should recognize the highest level, here is the monthly_summary function

image
guoci commented 1 year ago

https://github.com/guoci/pycharm-smart-execute/releases/tag/0.2.0

ntluong95 commented 1 year ago

Just test and think the feature works well now. Close the issue. Thank you for always prompt in help

guoci commented 1 year ago

Skip over comments and blanks. https://github.com/guoci/pycharm-smart-execute/releases/tag/0.2.1