diff options
author | hut <hut@lepus.uberspace.de> | 2016-02-28 16:42:56 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-02-28 16:42:56 +0100 |
commit | cddce56b95823b3087f8ff6682dcfe0640039666 (patch) | |
tree | f5bfb90e7946cfafe1c49a12e3a42c8f329871cc /ranger | |
parent | 2132b95f9fc889276abf0f5e22f7e876bc6ca8ab (diff) | |
parent | cb137db7fc8a1bf3d0efd31493d0a781c35b7931 (diff) | |
download | ranger-cddce56b95823b3087f8ff6682dcfe0640039666.tar.gz |
Merge branch 'add_tests' of https://github.com/charignon/ranger
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/bookmarks.py | 18 | ||||
-rw-r--r-- | ranger/container/history.py | 9 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 |
3 files changed, 13 insertions, 16 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index cbb95864..02f3e3bc 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -30,6 +30,7 @@ class Bookmarks(object): """ self.autosave = autosave self.dct = {} + self.original_dict = {} self.path = bookmarkfile self.bookmarktype = bookmarktype @@ -42,14 +43,6 @@ class Bookmarks(object): self._set_dict(new_dict, original=new_dict) - def delete(self, key): - """Delete the bookmark with the given key""" - if key == '`': - key = "'" - if key in self.dct: - del self.dct[key] - if self.autosave: self.save() - def enter(self, key): """Enter the bookmark with the given key. @@ -70,6 +63,15 @@ class Bookmarks(object): self["'"] = value if self.autosave: self.save() + def __delitem__(self, key): + """Delete the bookmark with the given key""" + if key == '`': + key = "'" + if key in self.dct: + del self.dct[key] + if self.autosave: self.save() + + def __iter__(self): return iter(self.dct.items()) diff --git a/ranger/container/history.py b/ranger/container/history.py index 8300edae..db2ea8ab 100644 --- a/ranger/container/history.py +++ b/ranger/container/history.py @@ -8,6 +8,7 @@ class HistoryEmptyException(Exception): class History(object): def __init__(self, maxlen=None, unique=True): + assert maxlen is not None, "maxlen cannot be None" if isinstance(maxlen, History): self._history = list(maxlen._history) self._index = maxlen._index @@ -54,7 +55,7 @@ class History(object): def rebase(self, other_history): assert isinstance(other_history, History) index_offset = len(self._history) - self._index - self._history[:self._index] = list(other_history._history) + self._history[:self._index + 1] = list(other_history._history) if len(self._history) > self.maxlen: self._history = self._history[-self.maxlen:] self._index = len(self._history) - index_offset @@ -112,9 +113,6 @@ class History(object): def __iter__(self): return self._history.__iter__() - def next(self): - return self._history.next() - def forward(self): if self._history: self._index += 1 @@ -129,6 +127,3 @@ class History(object): self._index = len(self._history) - 1 else: self._index = 0 - - def _left(self): # used for unit test - return self._history[0:self._index+1] diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 63916145..e692eb39 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -790,7 +790,7 @@ class Actions(FileManagerAware, SettingsAware): def unset_bookmark(self, key): """Delete the bookmark with the name <key>""" self.bookmarks.update_if_outdated() - self.bookmarks.delete(str(key)) + del self.bookmarks[str(key)] def draw_bookmarks(self): self.ui.browser.draw_bookmarks = True |