[core/decorators] reset scrolling if content changes

see #622
This commit is contained in:
tobi-wan-kenobi 2020-05-04 20:11:10 +02:00
parent 49c1465b65
commit 98dd8ca5f7
2 changed files with 14 additions and 0 deletions

View file

@ -27,6 +27,12 @@ def scrollable(func):
text = func(module, widget)
if not text:
return text
if text != widget.get("__content__", text):
widget.set("scrolling.start", 0)
widget.set("scrolling.direction", "right")
widget.set("__content__", text)
width = widget.get(
"theme.width", util.format.asint(module.parameter("width", 30))
)

View file

@ -62,5 +62,13 @@ class config(unittest.TestCase):
self.assertEqual("bc", self.module.get(self.widget))
self.assertEqual("cd", self.module.get(self.widget))
def test_changed_data(self):
self.module.text = "abcd"
self.module.set("width", 2)
self.assertEqual("ab", self.module.get(self.widget))
self.assertEqual("bc", self.module.get(self.widget))
self.module.text = "wxyz"
self.assertEqual("wx", self.module.get(self.widget))
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4