SendCode icon indicating copy to clipboard operation
SendCode copied to clipboard

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

Open ghost opened this issue 6 years ago • 24 comments

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?

ghost avatar Nov 20 '19 20:11 ghost

what syntax of code are you sending?

randy3k avatar Nov 20 '19 20:11 randy3k

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.

ghost avatar Nov 20 '19 20:11 ghost

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.

randy3k avatar Nov 20 '19 20:11 randy3k

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

ghost avatar Nov 20 '19 23:11 ghost

Same issue also for me!

lucananni93 avatar Nov 22 '19 21:11 lucananni93

What syntax was it?

randy3k avatar Nov 22 '19 21:11 randy3k

I am using Python syntax and sending code to ipython

lucananni93 avatar Nov 22 '19 21:11 lucananni93

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

randy3k avatar Nov 22 '19 21:11 randy3k

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"
	}

lucananni93 avatar Nov 22 '19 21:11 lucananni93

Was it ipyhon 2 or ipython 3?

randy3k avatar Nov 22 '19 22:11 randy3k

ipython3

lucananni93 avatar Nov 22 '19 22:11 lucananni93

That’s not what I expected...

randy3k avatar Nov 22 '19 22:11 randy3k

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

randy3k avatar Nov 22 '19 22:11 randy3k

I'm running ipython on a remote server over ssh

lucananni93 avatar Nov 22 '19 22:11 lucananni93

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.

randy3k avatar Nov 22 '19 22:11 randy3k

Thank you for your support and for the amazing package!

lucananni93 avatar Nov 22 '19 22:11 lucananni93

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)

randy3k avatar Nov 22 '19 23:11 randy3k

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)                            
   ...: --                                        
   ...: 

rsdrahat avatar Feb 23 '20 19:02 rsdrahat

What is the version of ipython?

randy3k avatar Feb 23 '20 19:02 randy3k

It's 7.8.0

rsdrahat avatar Feb 23 '20 20:02 rsdrahat

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?

randy3k avatar Feb 23 '20 21:02 randy3k

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.

rsdrahat avatar Feb 24 '20 00:02 rsdrahat

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 avatar Aug 11 '21 18:08 canute24

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

canute24 avatar Oct 04 '21 19:10 canute24