Skip to content

Commit aba1736

Browse files
authored
Pane, Window: Improve parsing of option values (#520)
2 parents db775fc + 4d79151 commit aba1736

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGES

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ $ pip install --user --upgrade --pre libtmux
1414

1515
<!-- Maintainers and contributors: Insert change notes for the next release above -->
1616

17+
### Improvement
18+
19+
- pane, window commands: Impove parsing of option values that return numbers
20+
(#520)
21+
1722
### Tests
1823

1924
- pytest: Fix `usefixture` warning (#519)

src/libtmux/pane.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
113113
Specifying ``('-t', 'custom-target')`` or ``('-tcustom_target')`` in
114114
``args`` will override using the object's ``pane_id`` as target.
115115
"""
116-
if not any(arg.startswith("-t") for arg in args):
116+
if not any("-t" in str(x) for x in args):
117117
args = ("-t", self.pane_id, *args)
118118

119119
return self.server.cmd(cmd, *args, **kwargs)

src/libtmux/window.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def cmd(self, cmd: str, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
139139
Specifying ``('-t', 'custom-target')`` or ``('-tcustom_target')`` in
140140
``args`` will override using the object's ``window_id`` as target.
141141
"""
142-
if not any(arg.startswith("-t") for arg in args):
142+
if not any("-t" in str(x) for x in args):
143143
args = ("-t", self.window_id, *args)
144144

145145
return self.server.cmd(cmd, *args, **kwargs)
@@ -389,7 +389,10 @@ def show_window_options(self, g: t.Optional[bool] = False) -> "WindowOptionDict"
389389

390390
window_options: "WindowOptionDict" = {}
391391
for item in output:
392-
key, val = shlex.split(item)
392+
try:
393+
key, val = shlex.split(item)
394+
except ValueError:
395+
logger.exception(f"Error extracting option: {item}")
393396
assert isinstance(key, str)
394397
assert isinstance(val, str)
395398

0 commit comments

Comments
 (0)