SendCode icon indicating copy to clipboard operation
SendCode copied to clipboard

"%cpaste -q" is artificially added to the code selection

Open Isabella-C opened this issue 4 years ago • 6 comments

When I send a single line to terminus, it's working fine. Whenever I send multiple lines to terminus, either for cmd.exe or python, "%cpaste -q ... --" is artificially added to my code.

I am running python in terminus. Code I am sending to terminus is:

x = 1
y = 2

Then, in terminus view, the thing I sent became:

Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32                                                                        
Type "help", "copyright", "credits" or "license" for more information.                                                                                                      
>>> x = 1                                                                                                                                                                   
>>> y = 2                                                                                                                                                                   
>>> %cpaste -q                                                                                                                                                              
  File "<stdin>", line 1                                                                                                                                                    
    %cpaste -q                                                                                                                                                              
    ^                                                                                                                                                                       
SyntaxError: invalid syntax                                                                                                                                                 
>>> x = 1                                                                                                                                                                   
>>> y = 2                                                                                                                                                                   
>>> --                                                                                                                                                                      
  File "<stdin>", line 1                                                                                                                                                    
    --                                                                                                                                                                      
     ^                                                                                                                                                                      
SyntaxError: invalid syntax 

My SendCode.sublime-settings is as below:

{
	"prog": "terminus",
	"python":
	{
		"bracketed_paste_mode": false,
		"paste_to_console": false,
		"prog": "terminus"
	},
	"r":
	{
		"bracketed_paste_mode": false,
		"prog": "terminus"
	},
	"terminal":
	{
		"bracketed_paste_mode": false,
		"prog": "terminus"
	}
}

My Default(Windows).sublime-keymap User version is as below.

{
        "keys": ["alt+enter"],
        "command": "send_code",
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source" }
        ]
    },

My Preferences.sublime-settings User as below:

{
	"auto_complete": true,
	"auto_complete_commit_on_tab": true,
	"auto_complete_triggers":
	[
		{
			"characters": ".",
			"selector": "source, text.html"
		}
	],
	"auto_match_enabled": true,
	"caret_style": "solid",
	"color_scheme": "Packages/One Dark Color Scheme/One Dark.tmTheme",
	"detect_indentation": true,
	"draw_indent_guides": true,
	"ensure_newline_at_eof_on_save": false,
	"file_exclude_patterns":
	[
		"*.DS_Store",
		"*.pyc",
		"*.git"
	],
	"find_selected_text": true,
	"folder_exclude_patterns":
	[
	],
	"font_options":
	[
		"no_round"
	],
	"font_size": 10,
	"highlight_line": true,
	"highlight_modified_tabs": true,
	"ignored_packages":
	[
		"Vintage"
	],
	"indent_to_bracket": true,
	"line_padding_bottom": 0,
	"line_padding_top": 0,
	"match_brackets": true,
	"match_brackets_angle": false,
	"match_brackets_braces": true,
	"match_brackets_content": true,
	"match_brackets_square": true,
	"new_window_settings":
	{
		"hide_open_files": true,
		"show_tabs": true,
		"side_bar_visible": true,
		"status_bar_visible": true
	},
	"remember_open_files": true,
	"remember_open_folders": true,
	"save_on_focus_lost": true,
	"scroll_past_end": false,
	"show_definitions": true,
	"show_full_path": true,
	"show_minimap": false,
	"tab_completion": false,
	"tab_size": 4,
	"theme": "Material-Theme-Darker.sublime-theme",
	"translate_tabs_to_spaces": true,
	"trim_trailing_white_space_on_save": true,
	"use_simple_full_screen": true,
	"vintage_start_in_command_mode": false,
	"word_wrap": false
}

Thanks v much in advance.

Isabella-C avatar May 06 '20 06:05 Isabella-C

We assume that you are using ipython.

randy3k avatar May 06 '20 06:05 randy3k

We assume that you are using ipython.

Thanks for the prompt reply.

So, how can I tell SendCode that I am using Python instead of Ipython?

Isabella-C avatar May 06 '20 06:05 Isabella-C

Only ipython is supported. Infact, there are no reasons to not use ipython.

randy3k avatar May 06 '20 07:05 randy3k

Oh, right. Thanks anyway.

Isabella-C avatar May 06 '20 08:05 Isabella-C

In case anyone else is also getting this when running IPython in Terminus: This happens when I have "bracketed_paste_mode": false AND "paste_to_console": false and have cursor on # %% code block. Setting "bracketed_paste_mode": true fixes it.

canute24 avatar Aug 11 '21 17:08 canute24

I though of giving this another shot as copy pasting code was getting annoying and it started working with no issues when I tried today. I'm thinking it's something to do with the additional libraries I might have installed since I last used it. Previously I only had IPython installed from pip. There was no ipykenel or jupyter installed.

Since the time I last used SendCode I have installed JupyterLab and VSCode. I think it could be these dependencies which got installed might have fixed the issue. I'm not getting %cpaste -q or ^[ anymore and enter is sent automatically.

I keep a track of packages I install but I can't tell which of these might have fixed it but you may be able to so I have included all of them below in case that helps. I'm so happy I don't need to ctrl-c ctrl-v anymore. Thanks.

New libraries installed since the last time I faced the issue: pywin32, tornado, pyzmq, nest-asyncio, jupyter-core, entrypoints, jupyter-client, debugpy, ipykernel, pyrsistent, attrs, jsonschema, webencodings, pycparser, packaging, nbformat, MarkupSafe, idna, charset-normalizer, certifi, testpath, sniffio, requests, pywinpty, pandocfilters, nbclient, mistune, jupyterlab-pygments, jinja2, defusedxml, cffi, bleach, websocket-client, terminado, Send2Trash, requests-unixsocket, prometheus-client, nbconvert, argon2-cffi, anyio, notebook, jupyter-server, json5, babel, nbclassic, jupyterlab-server, jupyterlab.

canute24 avatar Oct 04 '21 18:10 canute24