mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-29 11:18:50 +02:00
Merge branch 'fix/copy-or-noop-passthrough' of https://github.com/M-Hassan-Raza/kitty
This commit is contained in:
+2
-2
@@ -3737,6 +3737,6 @@ class Boss:
|
||||
if w := self.active_window:
|
||||
w.search_scrollback()
|
||||
|
||||
def copy_or_noop(self) -> None:
|
||||
def copy_or_noop(self) -> bool | None:
|
||||
if w := self.active_window:
|
||||
w.copy_or_noop()
|
||||
return w.copy_or_noop()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from functools import partial
|
||||
from types import SimpleNamespace
|
||||
|
||||
import kitty.fast_data_types as defines
|
||||
from kitty.key_encoding import EventType, KeyEvent, decode_key_event, encode_key_event
|
||||
@@ -656,6 +657,42 @@ class TestKeys(BaseTest):
|
||||
self.ae(tm.actions, ['push_keyboard_mode mw', 'new_window'])
|
||||
af(tm.ignore_os_keyboard_processing)
|
||||
|
||||
def test_copy_or_noop_passthrough(self):
|
||||
from kitty.boss import Boss
|
||||
from kitty.conf.utils import KeyAction
|
||||
|
||||
class Window:
|
||||
def __init__(self, passthrough: bool):
|
||||
self.passthrough = passthrough
|
||||
self.calls = 0
|
||||
|
||||
def copy_or_noop(self) -> bool:
|
||||
self.calls += 1
|
||||
return self.passthrough
|
||||
|
||||
class TestBoss(Boss):
|
||||
window: Window
|
||||
|
||||
@property
|
||||
def active_window(self):
|
||||
return self.window
|
||||
|
||||
@property
|
||||
def active_tab(self):
|
||||
return None
|
||||
|
||||
boss = TestBoss.__new__(TestBoss)
|
||||
boss.args = SimpleNamespace(debug_keyboard=False)
|
||||
boss.window_for_dispatch = None
|
||||
|
||||
boss.window = Window(True)
|
||||
self.assertFalse(boss.dispatch_action(KeyAction('copy_or_noop')))
|
||||
self.ae(boss.window.calls, 1)
|
||||
|
||||
boss.window = Window(False)
|
||||
self.assertTrue(boss.dispatch_action(KeyAction('copy_or_noop')))
|
||||
self.ae(boss.window.calls, 1)
|
||||
|
||||
def test_match_physical_keys_removed(self):
|
||||
# match_physical_keys global option has been removed in favor of per-mapping --allow-fallback
|
||||
# Verify that get_shortcut does NOT match via alternate_key without per-mapping allow_fallback='ascii'
|
||||
|
||||
Reference in New Issue
Block a user