mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
#3911 Support keybinding for different contexts with different commands
This commit is contained in:
parent
fbe296aaba
commit
4d2cb321d6
@ -202,7 +202,7 @@ class KeymapConfig:
|
|||||||
user_ctxs = v.get("ctx", ["global"])
|
user_ctxs = v.get("ctx", ["global"])
|
||||||
try:
|
try:
|
||||||
km._check_contexts(user_ctxs)
|
km._check_contexts(user_ctxs)
|
||||||
km.remove(v["key"], Contexts)
|
km.remove(v["key"], user_ctxs)
|
||||||
km.add(
|
km.add(
|
||||||
key = v["key"],
|
key = v["key"],
|
||||||
command = v["cmd"],
|
command = v["cmd"],
|
||||||
|
@ -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"))
|
||||||
|
|
||||||
|
with open(dst, 'w') as f:
|
||||||
|
f.write(
|
||||||
|
"""
|
||||||
|
- key: key2
|
||||||
|
ctx: [flowlist]
|
||||||
|
cmd: foo
|
||||||
|
- key: key2
|
||||||
|
ctx: [flowview]
|
||||||
|
cmd: bar
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
kmc.load_path(km, dst)
|
||||||
|
assert(km.get("flowlist", "key2"))
|
||||||
|
assert(km.get("flowview", "key2"))
|
||||||
|
|
||||||
km.add("key123", "str", ["flowlist", "flowview"])
|
km.add("key123", "str", ["flowlist", "flowview"])
|
||||||
with open(dst, 'w') as f:
|
with open(dst, 'w') as f:
|
||||||
f.write(
|
f.write(
|
||||||
@ -127,10 +142,9 @@ def test_load_path(tmpdir):
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
kmc.load_path(km, dst)
|
kmc.load_path(km, dst)
|
||||||
for b in km.bindings:
|
assert(km.get("flowlist", "key123"))
|
||||||
if b.key == "key123":
|
assert(km.get("flowview", "key123"))
|
||||||
assert b.contexts == ["options"]
|
assert(km.get("options", "key123"))
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse():
|
def test_parse():
|
||||||
|
Loading…
Reference in New Issue
Block a user