Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ichizok
Copy link
Contributor

@ichizok ichizok commented Nov 16, 2017

Problem (reported by @itchyny)

On :terminal on terminal-application with support for bracketed-paste, paste (e.g. Cmd-V on macOS) may not work properly.

Repro steps

The case of zsh:

vim --clean +'term zsh'

and paste text "echo hello", then an extra character ~ is appended.

32777341-242a6836-c979-11e7-93c4-219241f8f57e

Detail

When user pastes "echo hello", Vim receives \e[200~echo hello\e[201~ and trys to send it to :terminal, but the end sequence \e[201~ is separated from the body of paste-text and then zsh will interpret it as mere ~ character.

expected:

in << \e[200~echo hello\e[201~
out>> echo hello

actual:

in << \e[200~echo hello
out>> echo hello
in << \e[201~
out>> ~

in << means "Vim sends to :term zsh", and out>> means the echoback from tty.

Cause

terminal.c:861 term_convert_key()

        case K_PS:              vterm_keyboard_start_paste(vterm); return 0;
        case K_PE:              vterm_keyboard_end_paste(vterm); return 0;

When there is an input of bracketed-paste sequence \e[200~ or \e[201~, it is stored to vtrem buffer and is not sent at this time; then it will be sent to tty together with next input.
Therefore the end sequence \e[201~ is not sent at the time of doing paste.

@codecov-io
Copy link

Codecov Report

Merging #2341 into master will increase coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2341      +/-   ##
==========================================
+ Coverage   74.45%   74.45%   +<.01%     
==========================================
  Files          90       90              
  Lines      132166   132168       +2     
  Branches    29025    29025              
==========================================
+ Hits        98403    98410       +7     
+ Misses      33734    33729       -5     
  Partials       29       29
Impacted Files Coverage Δ
src/terminal.c 65.1% <0%> (-0.09%) ⬇️
src/gui_beval.c 44.47% <0%> (-0.31%) ⬇️
src/os_unix.c 53.41% <0%> (-0.14%) ⬇️
src/gui.c 47.42% <0%> (ø) ⬆️
src/window.c 81.42% <0%> (+0.03%) ⬆️
src/channel.c 82.48% <0%> (+0.04%) ⬆️
src/message.c 68.31% <0%> (+0.04%) ⬆️
src/term.c 50.94% <0%> (+0.05%) ⬆️
src/gui_gtk_x11.c 47.7% <0%> (+0.09%) ⬆️
src/if_xcmdsrv.c 85.07% <0%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58a8f17...2d8fdf6. Read the comment docs.

@brammool brammool closed this in a42ad57 Nov 16, 2017
@ichizok ichizok deleted the fix/terminal-bracketed-paste branch November 16, 2017 12:28
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Bracketed paste does not work well in terminal window.
Solution:   Send translated string to job right away. (Ozaki Kiichi, closes
            vim#2341)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants