From 98dd8ca5f7e9063d26bffea636fe0fe6164e84df Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Mon, 4 May 2020 20:11:10 +0200 Subject: [PATCH] [core/decorators] reset scrolling if content changes see #622 --- core/decorators.py | 6 ++++++ tests/core/test_decorators.py | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/core/decorators.py b/core/decorators.py index 56b2ead..76cb9c8 100644 --- a/core/decorators.py +++ b/core/decorators.py @@ -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)) ) diff --git a/tests/core/test_decorators.py b/tests/core/test_decorators.py index bbf7691..fb2878d 100644 --- a/tests/core/test_decorators.py +++ b/tests/core/test_decorators.py @@ -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