randy3k / SendCode

Send code and text to macOS and Linux Terminals, iTerm, ConEmu, Cmder, Tmux, Terminus; R (RStudio), Julia, IPython.
MIT License
204 stars 28 forks source link

For Windows: SendCode sending "^[" to Cmder instead of the actual code on the line #123

Open ghost opened 4 years ago

ghost commented 4 years ago

I'm not sure what supporting details I can provide for someone else to reproduce the problem, but every time I press ctrl+enter on Sublime (Windows), it sends "^]" to the Cmder console instead of the actual code. Can anyone point me to ideas for debugging this?

randy3k commented 4 years ago

what syntax of code are you sending?

ghost commented 4 years ago

It's sending that regardless of what code I'm trying to send, ranging from simple things like "pwd", "cd", "ls" on bash or lines like "import pandas" on python.

randy3k commented 4 years ago

I cannot reproduce it. If you are sending python code, make sure the syntax is chosen as Python and you are using ipython not the ordinary python. On the other hand, if you are sending a shell command, make sure the syntax is not Python.

ghost commented 4 years ago

Gotcha. I'll try out a couple other things to reproduce the error and let you know!

lucananni93 commented 4 years ago

Same issue also for me!

randy3k commented 4 years ago

What syntax was it?

lucananni93 commented 4 years ago

I am using Python syntax and sending code to ipython

randy3k commented 4 years ago

I guess I have figured out the reason. Please try turning on the setting ctrl+v_to_console for python syntax.

lucananni93 commented 4 years ago

I solved the issue. Indeed one has to turn off the ctrl+v_to_console option. The following setting solved the issue for me:

"python":
    {
        "bracketed_paste_mode": true,
        "ctrl+v_to_console": false,
        "prog": "cmder"
    }
randy3k commented 4 years ago

Was it ipyhon 2 or ipython 3?

lucananni93 commented 4 years ago

ipython3

randy3k commented 4 years ago

That’s not what I expected...

randy3k commented 4 years ago

Are you running a local ipython or doing some kind of ssh?

lucananni93 commented 4 years ago

I'm running ipython on a remote server over ssh

randy3k commented 4 years ago

Ok, that explains. That's technically an ipython on linux rather than an ipython on Windows. ipython is such a weird creature that behaves very differently on linux and windows. In that case, you really need turn off ctrl+v_to_console. Let me think of a better way to do it.

lucananni93 commented 4 years ago

Thank you for your support and for the amazing package!

randy3k commented 4 years ago

I have just pushed 5c6cf016dce982523d3b8e0535aed93ba4b13c30 and hopefull it's now a little bit clear.

https://github.com/randy3k/SendCode/blob/5c6cf016dce982523d3b8e0535aed93ba4b13c30/SendCode%20(Windows).sublime-settings#L25-L28

PS: In future releases, the setting name has changed to paste_to_console (the old name ctrl+v_to_console is still active though)

rsdrahat commented 4 years ago

I'm getting a similar problem with Python code I send to an ipython console in Terminus (Windows, ST3). Weird characters are getting inserted and the code is never executed. Not sure if this is a separate issue. (FYI SendCode works brilliantly for me for RStudio.)

I've tried various permutations of "bracketed_paste_mode" and "ctrl+v_to_console"/"paste_to_console" (I know these last two are the same). All other options are left as default, besides "prog" which is set to "terminus".

Documenting below in case it's helpful.

1

  "bracketed_paste_mode": true,
  "paste_to_console": true 

Result:

Every block of code gets the "^[" at the end and is not executed.

In [2]: print(2+2)^[                              
   ...: 

2

  "bracketed_paste_mode": true,
  "paste_to_console": false 

Result:

Single lines are entered correctly but not executed....

In [4]: print(2+2)                                
   ...: 

... and everything else has weird characters around them.

In [4]: ^[[200~def print4(x):                     
   ...:     print(2+2)^[[201~^[                   
   ...: 

3

  "bracketed_paste_mode": false,
  "paste_to_console": true 

Same as (1):

In [4]: print(2+2)^[                              
   ...: 

4

  "bracketed_paste_mode": false,
  "paste_to_console": false 

Single lines as in (2):

In [4]: print(2+2)                                
   ...: 

Anything else is like this:

In [4]: %cpaste -q                                
   ...: def print4(x):                            
   ...:     print(2+2)                            
   ...: --                                        
   ...: 
randy3k commented 4 years ago

What is the version of ipython?

rsdrahat commented 4 years ago

It's 7.8.0

randy3k commented 4 years ago

I have 7.10.1 in my windows VM but it's working fine with the default setting. Did you apply Python syntax to the file?

rsdrahat commented 4 years ago

Yep - Python syntax. Just updated ipython to 7.12.0, and still getting the issue. For now I'm just removing the tagged on "^[" and pressing enter twice to get by. Might be something off on my system if you got it working on your VM.

canute24 commented 3 years ago

Same as previous, getting ^[ at end of each sent content instead of Enter on Win10/ST3/Terminus/IPython=7.25.0 (I'm not using Cmder but same behaviour)

Also, I noticed just now that after the sent line there is a newline in IPython after the ^[ character. So in IPython I have to hit backspace 2 times and then hit Enter to execute.

Dunno if this has something to do with it but I thought I would mention that the way I start IPython is by Ctrl+P> Terminus in new Tab (View)> typing ipython at the command prompt in Terminus.

SendCode settings:

{
    "python" : {
        "prog": "terminus",
        "bracketed_paste_mode": true,
        "paste_to_console": true
    }
}
canute24 commented 3 years ago

Linking here https://github.com/randy3k/SendCode/issues/134#issuecomment-933761884 since this too is fixed. Works with "bracketed_paste_mode": false or true.