Skip to content

Bracketed (terminal-native) paste bypasses read-only mode and modifies the bufferΒ #2674

Closed

Description

@sinelaw

Summary

When a buffer is in read-only mode, a terminal-native bracketed paste (e.g. right-click paste, middle-click paste, or Ctrl+Shift+V in most terminals) still inserts text into the buffer. Typing and Ctrl+V are correctly blocked, but the bracketed-paste path is not, so a "read-only" buffer can be silently modified.

Steps to Reproduce

  1. Open any file: fresh testfile.txt
  2. Enable read-only mode (Command Palette β†’ "Toggle Read-Only Mode"). The status bar shows [RO].
  3. Confirm editing is blocked:
    • Type some characters β†’ nothing is inserted, status bar shows "Editing disabled in this buffer". βœ…
    • Press Ctrl+V (with something on the clipboard) β†’ nothing is inserted, "Editing disabled in this buffer". βœ…
  4. Now paste using the terminal's own paste (bracketed paste), e.g. right-click β†’ Paste, middle-click, or Ctrl+Shift+V.

(Reproducible from a script via tmux: tmux set-buffer -b pb "PASTED"; tmux paste-buffer -b pb -p targeting the fresh pane β€” -p wraps the text in bracketed-paste markers, exactly like a real terminal paste.)

Actual Behavior

The pasted text is inserted into the read-only buffer:

  • Buffer content changes (the pasted text appears at the cursor).
  • The tab title gains a * (unsaved-changes marker).
  • Status bar shows "Pasted".
  • The [RO] read-only indicator is still displayed the whole time.

Expected Behavior

Bracketed paste should be blocked in a read-only buffer, exactly like typing and Ctrl+V β€” no insertion, and the "Editing disabled in this buffer" message.

Environment

  • Fresh built from master
  • Linux, tmux 3.4 (also applies to any terminal that supports bracketed paste β€” right-click / middle-click / Ctrl+Shift+V)

Activity

  1. sinelaw commented on Jul 14, 2026

    @sinelaw
    OwnerAuthor

    This has been fixed on master in commit 349ec54 ("Block bracketed paste in read-only buffers"): paste_text() now gates buffer-destined bracketed pastes on is_editing_disabled, showing the "Editing disabled in this buffer" message instead of inserting. Closing as fixed.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriaged

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions