mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-17 05:32:41 +00:00
Merge branch 'pr-10688'
This commit is contained in:
commit
9b8124ac23
3 changed files with 35 additions and 0 deletions
|
|
@ -523,6 +523,9 @@ Detailed list of changes
|
|||
- Kittens: Reject command-line options missing their required value instead of
|
||||
silently ignoring them (:pull:`10687`)
|
||||
|
||||
- Remote control: Fix :ref:`at-action` reporting success when the action's
|
||||
arguments cannot be parsed.
|
||||
|
||||
|
||||
0.49.2 [2026-10-01]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -2106,6 +2106,8 @@ class Boss:
|
|||
try:
|
||||
actions = get_options().alias_map.resolve_aliases(action_definition, MapType.MAP if dispatch_type == 'KeyPress' else MapType.MOUSE_MAP)
|
||||
except Exception as e:
|
||||
if raise_error:
|
||||
raise
|
||||
self.show_error('Failed to parse action', f'{action_definition}\n{e}')
|
||||
return True
|
||||
if actions:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
from types import MethodType
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from kitty.constants import kitty_exe
|
||||
|
|
@ -37,6 +38,35 @@ class Boss:
|
|||
|
||||
|
||||
class TestRemoteControl(BaseTest):
|
||||
def test_action_parse_errors(self):
|
||||
from kitty.boss import Boss as KittyBoss
|
||||
from kitty.rc.base import RemoteControlErrorWithoutTraceback
|
||||
from kitty.remote_control import handle_cmd
|
||||
|
||||
self.set_options()
|
||||
for action in ('goto_tab not-a-number', 'set_font_size invalid', 'unknown_action argument', 'goto_tab 1'):
|
||||
with self.subTest(action=action):
|
||||
boss = Mock(active_window=None, window_for_dispatch=None, dispatch_action=Mock(return_value=True))
|
||||
boss.combine = MethodType(KittyBoss.combine, boss)
|
||||
request = {'cmd': 'action', 'version': [0, 26, 0], 'payload': {'action': action}}
|
||||
if action == 'goto_tab 1':
|
||||
self.ae(handle_cmd(boss, None, request, 0, None), {'ok': True})
|
||||
boss.dispatch_action.assert_called_once()
|
||||
else:
|
||||
with self.assertRaises(RemoteControlErrorWithoutTraceback):
|
||||
handle_cmd(boss, None, request, 0, None)
|
||||
boss.dispatch_action.assert_not_called()
|
||||
boss.show_error.assert_not_called()
|
||||
|
||||
def test_combine_parse_error_reporting(self):
|
||||
from kitty.boss import Boss as KittyBoss
|
||||
|
||||
self.set_options()
|
||||
boss = Mock()
|
||||
self.assertTrue(KittyBoss.combine(boss, 'goto_tab not-a-number'))
|
||||
boss.show_error.assert_called_once()
|
||||
boss.dispatch_action.assert_not_called()
|
||||
|
||||
def test_select_window_exclude_active(self):
|
||||
from kitty.boss import Boss as KittyBoss
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue