Skip to content

Commit

Permalink
Merge pull request #5229 from rlaverde/editor-historystack-improvements
Browse files Browse the repository at this point in the history
PR: Editor historystack improvements
  • Loading branch information
ccordoba12 authored Sep 15, 2017
2 parents 78e60c3 + 193c50d commit 9224248
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ def __len__(self):
return len(self.history)

def __getitem__(self, i):
return self.id_list.index(self.history[i])
self._update_id_list()
try:
return self.id_list.index(self.history[i])
except ValueError:
self.refresh()
raise IndexError

def __delitem__(self, i):
del self.history[i]
Expand Down Expand Up @@ -1718,12 +1723,11 @@ def current_changed(self, index):
pass

def _get_previous_file_index(self):
if len(self.stack_history) > 1:
last = len(self.stack_history)-1
w_id = self.stack_history.pop(last)
self.stack_history.insert(0, w_id)

return self.stack_history[last]
"""Return the penultimate element of the stack history."""
try:
return self.stack_history[-2]
except IndexError:
return None

def tab_navigation_mru(self, forward=True):
"""
Expand Down

0 comments on commit 9224248

Please sign in to comment.