Skip to content

Commit df7d77b

Browse files
committed
add select_layout with no args
1 parent f440b36 commit df7d77b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

libtmux/window.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,21 @@ def select_layout(self, layout=None):
115115
custom: custom dimensions (see :term:`tmux(1)` manpages).
116116
117117
:param layout: string of the layout, 'even-horizontal', 'tiled', etc.
118+
Entering None (leaving this blank) is same as ``select-layout``
119+
with no layout. In recent tmux versions, it picks the most recently
120+
set layout.
118121
:type layout: str
119122
120123
"""
121-
122-
proc = self.cmd(
124+
cmd = [
123125
'select-layout',
124-
'-t%s:%s' % (self.get('session_id'), self.index),
125-
layout
126-
)
126+
'-t%s:%s' % (self.get('session_id'), self.index)
127+
]
128+
129+
if layout: # tmux allows select-layout without args
130+
cmd.append(layout)
131+
132+
proc = self.cmd(*cmd)
127133

128134
if proc.stderr:
129135
raise exc.LibTmuxException(proc.stderr)

tests/test_window.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,10 @@ def test_move_window_to_other_session(server, session):
251251
new_session = server.new_session("test_move_window")
252252
window.move_window(session=new_session.get('session_id'))
253253
assert new_session.get_by_id(window.get("window_id")) == window
254+
255+
256+
def test_select_layout_accepts_no_arg(server, session):
257+
"""tmux allows select-layout with no arguments, so let's allow it here."""
258+
259+
window = session.new_window(window_name='test_window')
260+
window.select_layout()

0 commit comments

Comments
 (0)