Skip to content

Commit 7b9baef

Browse files
committed
support empty prompt
1 parent 777f89e commit 7b9baef

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/qbpm/menus.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def installed(self) -> bool:
1818
return which(self.name) is not None
1919

2020
def command(self, prompt: str, qb_args: str) -> str:
21+
prompt = prompt or "''"
2122
return f"{self.name} {self.args.format(prompt=prompt, qb_args=qb_args)}"
2223

2324
def commandline(self, profiles: list[str], prompt: str, qb_args: str) -> str:
@@ -59,9 +60,9 @@ def custom_dmenu(command: str) -> Dmenu:
5960
split = command.split(" ", maxsplit=1)
6061
if len(split) == 1 or not split[1]:
6162
name = Path(command).name
62-
for m in supported_menus():
63-
if isinstance(m, Dmenu) and m.name == name:
64-
return m if m.name == command else replace(m, name=command)
63+
for menu in supported_menus():
64+
if isinstance(menu, Dmenu) and menu.name == name:
65+
return menu if menu.name == command else replace(menu, name=command)
6566
return Dmenu(split[0], split[1] if len(split) == 2 else "")
6667

6768

tests/test_choose.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_custom_menu_default_args(tmp_path: Path):
7070
environ["DISPLAY"] = ":1"
7171
dmenu = find_menu(str(menu))
7272
assert dmenu is not None
73-
assert f"{menu} -dmenu" in dmenu.commandline(["p1", "p2"], "", "")
73+
assert f"{menu} -dmenu -no-custom -p ''" in dmenu.commandline(["p1", "p2"], "", "")
7474

7575

7676
def test_custom_menu_custom_args(tmp_path: Path):
@@ -80,4 +80,4 @@ def test_custom_menu_custom_args(tmp_path: Path):
8080
environ["DISPLAY"] = ":1"
8181
dmenu = find_menu(command)
8282
assert dmenu is not None
83-
assert command in dmenu.commandline(["p1", "p2"], "", "")
83+
assert dmenu.commandline(["p1", "p2"], "", "").endswith(command)

0 commit comments

Comments
 (0)