diff --git a/CHANGES b/CHANGES index f3f89e42d5..07422e757f 100644 --- a/CHANGES +++ b/CHANGES @@ -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 ------- diff --git a/tmuxp/testsuite/test_window.py b/tmuxp/testsuite/test_window.py index fb6b93fab7..c7f3a544c4 100644 --- a/tmuxp/testsuite/test_window.py +++ b/tmuxp/testsuite/test_window.py @@ -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) @@ -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 diff --git a/tmuxp/testsuite/test_workspacebuilder.py b/tmuxp/testsuite/test_workspacebuilder.py index 07e86de4c7..99b4f893b9 100644 --- a/tmuxp/testsuite/test_workspacebuilder.py +++ b/tmuxp/testsuite/test_workspacebuilder.py @@ -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 diff --git a/tmuxp/workspacebuilder.py b/tmuxp/workspacebuilder.py index c7c9c78212..943a72bcf1 100644 --- a/tmuxp/workspacebuilder.py +++ b/tmuxp/workspacebuilder.py @@ -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'])