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

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

Open Isabella-C opened 4 years ago

Isabella-C commented 4 years ago

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.

randy3k commented 4 years ago

We assume that you are using ipython.

Isabella-C commented 4 years ago

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?

randy3k commented 4 years ago

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

Isabella-C commented 4 years ago

Oh, right. Thanks anyway.

canute24 commented 3 years ago

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 commented 3 years ago

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.