Skip to content

make ScrollBar check wrapped widgets for SupportsScroll (Fixes #878)#879

Merged
penguinolog merged 5 commits into
urwid:masterfrom
rsekman:fix/attrmap_scrollable
May 14, 2024
Merged

make ScrollBar check wrapped widgets for SupportsScroll (Fixes #878)#879
penguinolog merged 5 commits into
urwid:masterfrom
rsekman:fix/attrmap_scrollable

Conversation

@rsekman
Copy link
Copy Markdown
Contributor

@rsekman rsekman commented Apr 30, 2024

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)
Description:

Fixes #878 .

Comment thread urwid/widget/scrollable.py Outdated
Comment thread urwid/widget/scrollable.py
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 30, 2024

Pull Request Test Coverage Report for Build 9075496246

Details

  • 9 of 10 (90.0%) changed or added relevant lines in 1 file are covered.
  • 64 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.04%) to 74.72%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/widget/scrollable.py 9 10 90.0%
Files with Coverage Reduction New Missed Lines %
urwid/widget/widget_decoration.py 7 80.6%
urwid/display/_raw_display_base.py 57 50.0%
Totals Coverage Status
Change from base Build 8873706490: 0.04%
Covered Lines: 9401
Relevant Lines: 12728

💛 - Coveralls

penguinolog: `w.original_widget` can point to `w`, we need to filter such behaviour to prevent infinite loop
if w in visited:
break
visited.add(w)
yield w
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are there decorations that are scrollable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://urwid.org/reference/widget.html#urwid.WidgetDecoration.base_widget exists to get the "most" .original_widget

Looking at the code, it is implemented like this generator was originally, i.e., vulnerable to infinite loops. So the fix in e5377cf should be applied also in widget_decoration.py, at least.

I have no idea if there are scrollable decorations; this is my first time working with the urwid code. It seems like a silly thing to implement, but if someone did they might be hit with an extremely confusing bug if we only check the base_widget.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or are there decorations that are scrollable?

Scrollable is a decoration adding scroll support to the widgets:

class Scrollable(WidgetDecoration[WrappedWidget]):

Comment thread urwid/widget/scrollable.py Outdated
Fix static checker warning
@penguinolog penguinolog merged commit d9a762d into urwid:master May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ListBox wrapped in AttrMap is not scrollable with ScrollBar

4 participants