Skip to content

feat(🎄🎁): support reading the OSC52 clipboard contents in tests#862

Merged
mikavilpas merged 1 commit intomainfrom
osc52
Dec 24, 2025
Merged

feat(🎄🎁): support reading the OSC52 clipboard contents in tests#862
mikavilpas merged 1 commit intomainfrom
osc52

Conversation

@mikavilpas
Copy link
Copy Markdown
Owner

Issue:

An important part of terminal applications is the ability to set and read the system clipboard. This is not possible to test.

Solution:

Support an in-memory OSC52 clipboard in the terminal testing session that can be tested. OSC52 is a terminal escape sequence that allows terminal applications to set the clipboard contents of the host terminal. It works locally and even over ssh connections.

Features:

  • store the latest clipboard contents in memory, and allow read-only access in tests.
    • tests can only read the clipboard contents, not set them.
    • the test application (e.g. neovim) can read + write the clipboard contents normally using OSC52 requests.
    • Does not affect the system clipboard of the host system (your computer), which could disturb other tasks while the tests are running. Now they are completely separate.
  • support both "system" and "primary" clipboards. This is what xtermjs exposes, and we now support both. The "system" clipboard seems to be the default on macOS, while "primary" is probably used on Linux X11.

References:

Closes #857

**Issue:**

An important part of terminal applications is the ability to set and
read the system clipboard. This is not possible to test.

**Solution:**

Support an in-memory OSC52 clipboard in the terminal testing session
that can be tested. OSC52 is a terminal escape sequence that allows
terminal applications to set the clipboard contents of the host
terminal. It works locally and even over ssh connections.

Features:

- store the latest clipboard contents in memory, and allow **read-only**
  access in tests.
  - tests can only read the clipboard contents, not set them.
  - the test application (e.g. neovim) can read + write the clipboard
    contents normally using OSC52 requests.
  - Does not affect the system clipboard of the host system (your
    computer), which could disturb other tasks while the tests are
    running. Now they are completely separate.
- support both "system" and "primary" clipboards. This is what xtermjs
  exposes, and we now support both. The "system" clipboard seems to be
  the default on macOS, while "primary" is probably used on Linux X11.

References:

- xtermjs 6.0 added support for OSC52 clipboard requests via
  xtermjs/xterm.js#4220
- https://neovim.io/doc/user/provider.html#clipboard-osc52

Closes #857
@mikavilpas mikavilpas enabled auto-merge (squash) December 24, 2025 13:40
@mikavilpas mikavilpas merged commit 8aa995e into main Dec 24, 2025
14 checks passed
@mikavilpas mikavilpas deleted the osc52 branch December 24, 2025 13:41
mikavilpas added a commit to mikavilpas/yazi.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/yazi.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/tsugit.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/tsugit.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/blink-ripgrep.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/incr.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/blink-ripgrep.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/my-nvim-micro-plugins.nvim that referenced this pull request Dec 24, 2025
mikavilpas added a commit to mikavilpas/my-nvim-micro-plugins.nvim that referenced this pull request Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support testing OSC52 clipboard usage

1 participant