Skip to content

paste: handle "dangling paste" (missing stop-paste code) #10865

@justinmk

Description

@justinmk

Since #4448 , paste is handled now by the vim.paste() handler (which is invoked by the UI via nvim_paste()).

There is a potential issue where the TUI could get stuck in paste-mode if the host terminal fails to send a stop-paste sequence (<Esc>[201~). In this state, the user could recover by RPC:

nvim_paste([''], 3)

Nvim GUIs using nvim_paste do not need such workarounds because they use an out-of-band channel (as opposed to the TUI where user input + paste are in-band).

Vim fixed a similar issue with its bracketed-paste implementation, but:

  • the "infinite loop" problem does not apply because Nvim doesn't actively loop
  • CTRL-C would not interrupt the paste in Nvim, so a "dangling paste" is less likely. (Could be caused by network failure instead.)

Plan

  1. TUI needs to check nvim_paste() result (e.g. revert 2c605d1 )
  2. vim.paste() Lua handler could track some state to decide if a paste is "stuck". E.g. if the paste stream is very "slow", and CTRL-C is seen ~twice in a row, we can guess that (1) the paste was exhausted and (2) the user is trying to cancel the operation, thus false should be returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions