Skip to content

Commit

Permalink
Merge pull request #131 from mattrose/issue99
Browse files Browse the repository at this point in the history
Issue99
  • Loading branch information
mattrose authored Jun 21, 2020
2 parents 480bc47 + decd21e commit fae95a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
4 changes: 3 additions & 1 deletion terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ def on_tab_switch(self, notebook, page, page_num, data=None):
tabs_last_active_term = data['tabs_last_active_term']
if tabs_last_active_term:
term = self.terminator.find_terminal_by_uuid(tabs_last_active_term.urn)
GObject.idle_add(term.ensure_visible_and_focussed)
# if we can't find a last active term we must be starting up
if term is not None:
GObject.idle_add(term.ensure_visible_and_focussed)
return True

def on_scroll_event(self, notebook, event):
Expand Down
30 changes: 1 addition & 29 deletions terminatorlib/terminator.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,35 +356,7 @@ def layout_done(self):
terminal.spawn_child()

for window in self.windows:
if window.is_child_notebook():
# For windows with a notebook
notebook = window.get_toplevel().get_children()[0]
# Cycle through pages by number
for page in range(0, notebook.get_n_pages()):
# Try and get the entry in the previously saved mapping
mapping = window_last_active_term_mapping[window]
page_last_active_term = mapping.get(notebook.get_nth_page(page), None)
if page_last_active_term is None:
# Couldn't find entry, so we find the first child of type Terminal
children = notebook.get_nth_page(page).get_children()
for page_last_active_term in children:
if maker.isinstance(page_last_active_term, 'Terminal'):
page_last_active_term = page_last_active_term.uuid
break
else:
err('Should never reach here!')
page_last_active_term = None
if page_last_active_term is None:
# Bail on this tab as we're having no luck here, continue with the next
continue
# Set the notebook entry, then ensure Terminal is visible and focussed
urn = page_last_active_term.urn
notebook.last_active_term[notebook.get_nth_page(page)] = page_last_active_term
if urn:
term = self.find_terminal_by_uuid(urn)
if term:
term.ensure_visible_and_focussed()
else:
if not window.is_child_notebook():
# For windows without a notebook ensure Terminal is visible and focussed
if window_last_active_term_mapping[window]:
term = self.find_terminal_by_uuid(window_last_active_term_mapping[window].urn)
Expand Down

0 comments on commit fae95a7

Please sign in to comment.