Skip to content

Commit

Permalink
Fix #23 where workspaces would not build with a non-default (non 0) p…
Browse files Browse the repository at this point in the history
…ane-base-index.
  • Loading branch information
tony committed Nov 23, 2013
1 parent 269dec0 commit e9c567a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ Here you can find the recent changes to tmuxp.
master
------

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

.. _Issue #23: https://github.com/tony/tmuxp/issues/23

0.1-rc1
-------

Expand Down
11 changes: 7 additions & 4 deletions tmuxp/testsuite/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ def test_select_window(self):
class NewTest(TmuxTestCase):

def test_zfresh_window_data(self):
# self.session.select_window(1)
#

pane_base_index = int(self.session.attached_window().show_window_option(
'pane-base-index', g=True
))

self.assertEqual(len(self.session.windows), 1)

self.assertEqual(len(self.session.attached_window().panes), 1)
Expand All @@ -73,9 +76,9 @@ def test_zfresh_window_data(self):
self.assertIsInstance(window, Window)
self.assertEqual(len(self.session.attached_window().panes), 1)
pane = window.split_window()
self.session.attached_window().select_pane(0)
self.session.attached_window().select_pane(pane_base_index)
self.session.attached_pane().send_keys('cd /srv/www/flaskr')
self.session.attached_window().select_pane(1)
self.session.attached_window().select_pane(pane_base_index + 1)
self.session.attached_pane().send_keys('source .env/bin/activate')
self.session.new_window(window_name='second')
current_windows += 1
Expand Down
6 changes: 3 additions & 3 deletions tmuxp/testsuite/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def test_split_windows(self):
'focused window'
)

pane_base_index = self.session.attached_window().show_window_option(
'pane-base-index'
)
pane_base_index = int(self.session.attached_window().show_window_option(
'pane-base-index', g=True
))

if not pane_base_index:
pane_base_index = 0
Expand Down
14 changes: 7 additions & 7 deletions tmuxp/workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,18 @@ def iter_create_panes(self, w, wconf):
pane_base_index = int(w.show_window_option('pane-base-index', g=True))

for pindex, pconf in enumerate(wconf['panes'], start=pane_base_index):
if pindex != int(pane_base_index):

if pindex == int(pane_base_index):
p = w.attached_pane()

else:
p = w.split_window(
attach=True,
#target=w.list_panes()[-1].get('pane_index')
)
assert(isinstance(p, Pane))
assert int(p.get('pane_index')) == int(pane_base_index + pindex)
else:
p = w.attached_pane()
assert(isinstance(p, Pane))
assert int(p.get('pane_index')) == int(pane_base_index)

assert(isinstance(p, Pane))
assert(int(p.get('pane_index')) == int(pindex))
if 'layout' in wconf:
w.select_layout(wconf['layout'])

Expand Down

0 comments on commit e9c567a

Please sign in to comment.