Skip to content

Commit e9c567a

Browse files
committed
Fix #23 where workspaces would not build with a non-default (non 0) pane-base-index.
1 parent 269dec0 commit e9c567a

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ Here you can find the recent changes to tmuxp.
77
master
88
------
99

10+
- [cli] [tests] - fix `Issue #23`_ where workspace would not build with
11+
pane-base-index set to 1. Update tests to fix if ``pane-base-index`` is
12+
not 0.
1013
- [cli] - removed ``$ tmuxp load --list`` functionality. Update
1114
:ref:`quickstart` accordingly.
1215

16+
.. _Issue #23: https://github.com/tony/tmuxp/issues/23
17+
1318
0.1-rc1
1419
-------
1520

tmuxp/testsuite/test_window.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ def test_select_window(self):
5252
class NewTest(TmuxTestCase):
5353

5454
def test_zfresh_window_data(self):
55-
# self.session.select_window(1)
56-
#
55+
56+
pane_base_index = int(self.session.attached_window().show_window_option(
57+
'pane-base-index', g=True
58+
))
59+
5760
self.assertEqual(len(self.session.windows), 1)
5861

5962
self.assertEqual(len(self.session.attached_window().panes), 1)
@@ -73,9 +76,9 @@ def test_zfresh_window_data(self):
7376
self.assertIsInstance(window, Window)
7477
self.assertEqual(len(self.session.attached_window().panes), 1)
7578
pane = window.split_window()
76-
self.session.attached_window().select_pane(0)
79+
self.session.attached_window().select_pane(pane_base_index)
7780
self.session.attached_pane().send_keys('cd /srv/www/flaskr')
78-
self.session.attached_window().select_pane(1)
81+
self.session.attached_window().select_pane(pane_base_index + 1)
7982
self.session.attached_pane().send_keys('source .env/bin/activate')
8083
self.session.new_window(window_name='second')
8184
current_windows += 1

tmuxp/testsuite/test_workspacebuilder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def test_split_windows(self):
154154
'focused window'
155155
)
156156

157-
pane_base_index = self.session.attached_window().show_window_option(
158-
'pane-base-index'
159-
)
157+
pane_base_index = int(self.session.attached_window().show_window_option(
158+
'pane-base-index', g=True
159+
))
160160

161161
if not pane_base_index:
162162
pane_base_index = 0

tmuxp/workspacebuilder.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,18 @@ def iter_create_panes(self, w, wconf):
210210
pane_base_index = int(w.show_window_option('pane-base-index', g=True))
211211

212212
for pindex, pconf in enumerate(wconf['panes'], start=pane_base_index):
213-
if pindex != int(pane_base_index):
213+
214+
if pindex == int(pane_base_index):
215+
p = w.attached_pane()
216+
217+
else:
214218
p = w.split_window(
215219
attach=True,
216220
#target=w.list_panes()[-1].get('pane_index')
217221
)
218-
assert(isinstance(p, Pane))
219-
assert int(p.get('pane_index')) == int(pane_base_index + pindex)
220-
else:
221-
p = w.attached_pane()
222-
assert(isinstance(p, Pane))
223-
assert int(p.get('pane_index')) == int(pane_base_index)
224222

223+
assert(isinstance(p, Pane))
224+
assert(int(p.get('pane_index')) == int(pindex))
225225
if 'layout' in wconf:
226226
w.select_layout(wconf['layout'])
227227

0 commit comments

Comments
 (0)