Skip to content

Commit

Permalink
Merge pull request #38 from andfoy/terminal_names
Browse files Browse the repository at this point in the history
Terminal tabs naming convention is sequential
  • Loading branch information
andfoy committed Apr 11, 2017
2 parents b241009 + 3d80f7c commit ee92146
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spyder_terminal/terminalplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ def close_term(self, index=None, term=None):
def add_tab(self, widget):
"""Add tab."""
self.terms.append(widget)
index = self.tabwidget.addTab(widget, "Terminal")
num_term = self.tabwidget.count() + 1
index = self.tabwidget.addTab(widget, "Terminal {0}".format(num_term))
self.tabwidget.setCurrentIndex(index)
self.tabwidget.setTabToolTip(index, "Terminal")
self.tabwidget.setTabToolTip(index, "Terminal {0}".format(num_term))
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.raise_()
Expand Down
10 changes: 10 additions & 0 deletions spyder_terminal/tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ def test_terminal_font(qtbot):
terminal.closing_plugin()


def test_terminal_tab_title(qtbot):
"""Test if terminal tab titles are numbered sequentially."""
terminal = setup_terminal(qtbot)
qtbot.wait(TERM_UP)
terminal.create_new_term()
num_1 = int(terminal.tabwidget.tabText(0)[-1])
num_2 = int(terminal.tabwidget.tabText(1)[-1])
assert num_2 == num_1 + 1


def test_new_terminal(qtbot):
"""Test if a new terminal is added."""
# Setup widget
Expand Down

0 comments on commit ee92146

Please sign in to comment.