mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
Merge pull request #3340 from kajojify/buttons
keys.yaml priority over defaultkeys.py
This commit is contained in:
commit
a8b809dcbc
@ -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:
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user