Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paste setup sometimes fails to "set nopaste" #7994

Closed
firedev opened this issue Feb 11, 2018 · 8 comments · Fixed by #10311
Closed

paste setup sometimes fails to "set nopaste" #7994

firedev opened this issue Feb 11, 2018 · 8 comments · Fixed by #10311
Labels
bug issues reporting wrong behavior clipboard clipboard, paste has:workaround issue is not fixed but can be circumvented until then input
Milestone

Comments

@firedev
Copy link

firedev commented Feb 11, 2018

  • nvim --version:
$ nvim --version
NVIM v0.2.3-24-gd9b3ebfed
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20171125-11833-1ozpdpl/build/config -I/tmp/neovim-20171125-11833-1ozpdpl/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20171125-11833-1ozpdpl/build/src/nvim/auto -I/tmp/neovim-20171125-11833-1ozpdpl/build/include
Compiled by pain@nick.local

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-d9b3ebf/share/nvim"

Run :checkhealth for more info
  • Operating system/version: macOS 10.13.3
  • Terminal name/version: iTerm Build 3.1.20170717-nightly
  • $TERM: screen-256color

Steps to reproduce using nvim -u NORC

Can't reproduce yet, it works without the config file.

Actual behaviour

I was reporting this before but the issue was renamed #6561

Finally caught it in the wild. Here is what I did:

  1. Went to insert mode
  2. Pasted something from Alfred clipboard history Cmd-Shift-V, Enter

Result:

  1. The fragment was inserted with <Paste> at the end.
  2. :verb set et?noexpandtab

Expected behaviour

  • expandtab should stay on.
  • There should be no <Paste>
@justinmk justinmk added clipboard clipboard, paste bug issues reporting wrong behavior labels Feb 11, 2018
@justinmk justinmk changed the title expandtab turns off by itself paste setup sometimes fails to "set nopaste" Feb 11, 2018
@justinmk justinmk added this to the 0.3 milestone Feb 11, 2018
@justinmk
Copy link
Member

justinmk commented Feb 11, 2018

This is a known issue (yes, it's quite bothersome). Workaround is to

:set nopaste

after pasting. (Edit: or do it automatically in a InsertLeave handler, see below)

@firedev
Copy link
Author

firedev commented Feb 12, 2018

Sorry, which issue is known? What about expandtab?

@justinmk
Copy link
Member

noexpandtab is one of many side-effects of set paste (see :help 'paste'), which is basically what happens when a paste is detected. When the paste ends, Nvim should :set nopaste, but sometimes it doesn't.

@firedev
Copy link
Author

firedev commented Feb 12, 2018

Oh got it, this one was driving me crazy, thanks!

@justinmk justinmk added has:workaround issue is not fixed but can be circumvented until then input labels Feb 12, 2018
@languitar
Copy link

What is the reason for this behavior? I also sometimes see this.

@justinmk
Copy link
Member

For those suffering from this, a workaround is to :set nopaste on InsertLeave to ensure that nopaste is always set:

au InsertLeave * set nopaste

(I won't use this workaround myself, else I might forget about the issue :)

@victoriastuart
Copy link


Update:

See my answer at https://stackoverflow.com/questions/53123297/disable-insert-paste-mode/53285805#53285805

TL/DR:

  • disable (comment out or remove) set nopaste in ~/.vimrc
  • add these to ~/.vimrc:
    • set clipboard+=unnamed
    • nnoremap p p`]<Esc>
  • use p to paste (Normal mode)
  • Insert blank line without entering insert mode:
    • above current line: nmap <A-CR> O<Esc>
    • below current line: nmap <CR> o<Esc>

Related discussion:

@frabjous
Copy link

frabjous commented Jun 7, 2019

I'm having a version of this problem, where if I use the terminal emulator's paste-from-clipboard short key (Ctrl-Shift-V for me) when in the command line in neovim, it'll then put me in -- INSERT (paste) -- mode and keep me in it until I manually set nopaste.
Even the workaround does not work for me. Neovim reports nopaste as being set, e.g., if I type in set paste?, but I always get INSERT (paste) mode anyway.

XrXr added a commit to XrXr/neovim that referenced this issue Jun 23, 2019
<Paste> is a 3-byte sequence and the beginning one or two bytes can appear at
the very end of the typeahead buffer. When this happens, we were exiting from
`vgetorpeek()` instead of reading more characters to see the complete sequence.

I think this should fix neovim#7994 -- at least partially. Before this change, when I
paste exactly 64 characters into a freshly booted instance, I get what I pasted
plus the literal text "<Paste>" at the end. Nvim also stays in nopaste mode.
The attached test case fails in this manner without the code change.

Fix neovim#7994
@justinmk justinmk modified the milestones: 0.6, 0.4 Jun 23, 2019
justinmk pushed a commit that referenced this issue Jun 23, 2019
<Paste> is a 3-byte sequence and the beginning one or two bytes can appear at
the very end of the typeahead buffer. When this happens, we were exiting from
`vgetorpeek()` instead of reading more characters to see the complete sequence.

I think this should fix #7994 -- at least partially. Before this change, when I
paste exactly 64 characters into a freshly booted instance, I get what I pasted
plus the literal text "<Paste>" at the end. Nvim also stays in nopaste mode.
The attached test case fails in this manner without the code change.

Fix #7994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior clipboard clipboard, paste has:workaround issue is not fixed but can be circumvented until then input
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants