d0vgan / nppexec

NppExec (plugin for Notepad++)
GNU General Public License v3.0
132 stars 23 forks source link

Issue when executing selected or clipboard texts #97

Open mrrezaie opened 1 month ago

mrrezaie commented 1 month ago

Hi, when using Execute Selected Text or Execute Clipboard Text, codes are not executed in new line and this happens:

https://github.com/user-attachments/assets/92ba98b6-6f83-4a5b-8039-f14a45dfbb13

It would be great if NppExec starts with new line after execution the codes.

Thank you.

d0vgan commented 1 month ago

The Execute Selected Text does exactly what its name says: executes the selected text as is, without any implicit changes. If you want to alter this behavior, you may write an NppExec's script and assign a shortcut key to that script. https://d0vgan.github.io/nppexec/?q=3.7

mrrezaie commented 1 month ago

@d0vgan, thanks for your response. Indeed I want the outputs to be printed in a new line. If I run a cell with a couple of prints in the middle, this happens:

>>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> prints something
>>> >>> >>> >>> >>> >>> >>> >>> ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... >>> finished
>>> >>> >>> >>> >>>

Actually, I have no idea how to alter this behavior. I was wondering if you could help on this as well. Thank you.

d0vgan commented 4 weeks ago

Hmm, when there is interactive python (such as python -i -u) running in NppExec's Console and you quickly press Enter several times in NppExec's Console, you'll get something similar to the following as the result:

>>> >>> >>>

If you slowly press Enter several times, you'll get the following:

>>> 
>>> 
>>> 

So it looks like new lines in the output are "swallowed" by NppExec when several lines (remember: pressing Enter in NppExec's Console is the same as passing an empty line) are passed to python as an input.

On the other hand, if I do the very same actions with cmd, I always get the following, disregarding of whether Enter was pressed quickly or slowly:

C:\Users\UserName\AppData\Local\Temp>

C:\Users\UserName\AppData\Local\Temp>

C:\Users\UserName\AppData\Local\Temp>

As you can see, cmd does not demonstrate this "cumulative effect" in its output. This seems to be related to the fact that NppExec uses pipes to deal with console process'es input/output as mentioned here: https://d0vgan.github.io/nppexec/?q=1.3

Unfortunately, NppExec does not have any control of the pipes' behavior which is fully controlled by the system (Windows). I'll see if I could do something with python here, but I can't promise anything.