Fix issue #3251
This commit is contained in:
parent
b9aa5df5ed
commit
6e719d1796
@ -170,6 +170,11 @@ class KeyConfig:
|
|||||||
|
|
||||||
def bind(self, key, command, *, mode, save_yaml=False):
|
def bind(self, key, command, *, mode, save_yaml=False):
|
||||||
"""Add a new binding from key to command."""
|
"""Add a new binding from key to command."""
|
||||||
|
if command is not None and not command.strip():
|
||||||
|
raise configexc.KeybindingError(
|
||||||
|
"Can't add binding '{}' with empty command in {} "
|
||||||
|
'mode'.format(key, mode))
|
||||||
|
|
||||||
key = self._prepare(key, mode)
|
key = self._prepare(key, mode)
|
||||||
log.keyboard.vdebug("Adding binding {} -> {} in mode {}.".format(
|
log.keyboard.vdebug("Adding binding {} -> {} in mode {}.".format(
|
||||||
key, command, mode))
|
key, command, mode))
|
||||||
|
@ -285,6 +285,12 @@ class TestKeyConfig:
|
|||||||
key_config_stub.unbind('a')
|
key_config_stub.unbind('a')
|
||||||
assert key_config_stub.get_command('a', mode='normal') is None
|
assert key_config_stub.get_command('a', mode='normal') is None
|
||||||
|
|
||||||
|
def test_empty_command(self, key_config_stub):
|
||||||
|
"""Try binding a key to an empty command."""
|
||||||
|
message = "Can't add binding 'x' with empty command in normal mode"
|
||||||
|
with pytest.raises(configexc.KeybindingError, match=message):
|
||||||
|
key_config_stub.bind('x', ' ', mode='normal')
|
||||||
|
|
||||||
|
|
||||||
class TestConfig:
|
class TestConfig:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user