Merge pull request #3340 from kajojify/buttons

keys.yaml priority over defaultkeys.py
This commit is contained in:
Samoilenko Roman 2018-09-29 16:21:46 +03:00 committed by GitHub
commit a8b809dcbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -199,11 +199,14 @@ class KeymapConfig:
"Error reading %s: %s" % (p, e) "Error reading %s: %s" % (p, e)
) from e ) from e
for v in vals: for v in vals:
user_ctxs = v.get("ctx", ["global"])
try: try:
km._check_contexts(user_ctxs)
km.remove(v["key"], Contexts)
km.add( km.add(
key = v["key"], key = v["key"],
command = v["cmd"], command = v["cmd"],
contexts = v.get("ctx", ["global"]), contexts = user_ctxs,
help = v.get("help", None), help = v.get("help", None),
) )
except ValueError as e: except ValueError as e:

View File

@ -117,6 +117,21 @@ def test_load_path(tmpdir):
kmc.load_path(km, dst) kmc.load_path(km, dst)
assert(km.get("chooser", "key1")) assert(km.get("chooser", "key1"))
km.add("key123", "str", ["flowlist", "flowview"])
with open(dst, 'w') as f:
f.write(
"""
- key: key123
ctx: [options]
cmd: foo
"""
)
kmc.load_path(km, dst)
for b in km.bindings:
if b.key == "key123":
assert b.contexts == ["options"]
break
def test_parse(): def test_parse():
kmc = keymap.KeymapConfig() kmc = keymap.KeymapConfig()