firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
213 stars 37 forks source link

option --reverse causes AttributeError with urwid 2.1.0 #99

Closed pavoljuhas closed 3 years ago

pavoljuhas commented 3 years ago

I am getting AttributeError when trying to use the --reverse option. This happens with urwid 2.1.0 installed from system package.

$ bin/urlscan --reverse /dev/null
Traceback (most recent call last):
  File "bin/urlscan", line 216, in <module>
    main()
  File "bin/urlscan", line 195, in main
    tui = urlchoose.URLChooser(urlscan.msgurls(msg),
  File ".../urlscan/urlchoose.py", line 226, in __init__
    self._reverse()
  File ".../urlscan/urlchoose.py", line 465, in _reverse
    fpo = self.top.body.focus_position
AttributeError: 'Padding' object has no attribute 'body'

The patch below seems to fix this, please consider applying.

fix-reverse-body-attr.patch

diff --git a/urlscan/urlchoose.py b/urlscan/urlchoose.py
index 9e9c1e5..6b2ec7a 100644
--- a/urlscan/urlchoose.py
+++ b/urlscan/urlchoose.py
@@ -462,7 +462,7 @@ class URLChooser:
     def _reverse(self):
         """ R """
         # Reverse items
-        fpo = self.top.body.focus_position
+        fpo = self.top.base_widget.body.focus_position
         if self.compact is True:
             self.items.reverse()
         else:
@@ -475,8 +475,8 @@ class URLChooser:
                 else:
                     rev.insert(2, item)
             self.items = rev
-        self.top.body = urwid.ListBox(self.items)
-        self.top.body.focus_position = self._cur_focus(fpo)
+        self.top.base_widget.body = urwid.ListBox(self.items)
+        self.top.base_widget.body.focus_position = self._cur_focus(fpo)

     def _context(self):
         """ c """
firecat53 commented 3 years ago

Good catch and thanks so much for the patch!!