Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10484,20 +10484,10 @@ def handle_ctrl_c(event):
self._should_exit = True
event.app.exit()

@kb.add('c-S-c') # Ctrl+Shift+C
def handle_ctrl_shift_c(event):
"""Copy text to clipboard (terminal-native).

This is a no-op at the application level. Terminal emulators
handle the actual copy operation when Ctrl+Shift+C is pressed.
This binding prevents Hermes from intercepting the keystroke
as an interrupt signal.

On macOS the standard copy shortcut is Cmd+C (no Hermes binding
needed). On Linux/Windows Ctrl+Shift+C is the conventional
terminal copy shortcut.
"""
return # No-op — let the terminal perform native copy
# Do not bind Ctrl+Shift+C here. prompt_toolkit does not support a
# portable key name for that chord (e.g. 'c-S-c' raises
# ValueError: Invalid key), and terminal emulators handle copy before
# the application sees it anyway.

@kb.add('c-q') # Ctrl+Q
def handle_ctrl_q(event):
Expand Down
18 changes: 18 additions & 0 deletions tests/cli/test_invalid_keybindings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pathlib import Path

import pytest
from prompt_toolkit.key_binding import KeyBindings


@pytest.mark.parametrize("key", ["c-S-c"])
def test_prompt_toolkit_rejects_non_portable_key_names(key):
kb = KeyBindings()

with pytest.raises(Exception, match="Invalid key"):
kb.add(key)(lambda event: None)


def test_cli_does_not_register_invalid_ctrl_shift_c_binding():
source = Path(__file__).resolve().parents[2] / "cli.py"

assert "@kb.add('c-S-c')" not in source.read_text()