diff options
-rw-r--r-- | ttystatus/status.py | 2 | ||||
-rw-r--r-- | ttystatus/status_tests.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ttystatus/status.py b/ttystatus/status.py index b0b93dd..b98fecd 100644 --- a/ttystatus/status.py +++ b/ttystatus/status.py @@ -91,7 +91,7 @@ class TerminalStatus(object): texts[i] = w.render(remaining) remaining -= len(texts[i]) - return ''.join(texts) + return (''.join(texts))[:self._m.width] def _write(self): '''Render and output current state of all widgets.''' diff --git a/ttystatus/status_tests.py b/ttystatus/status_tests.py index aa8c021..ab27ca9 100644 --- a/ttystatus/status_tests.py +++ b/ttystatus/status_tests.py @@ -138,3 +138,12 @@ class TerminalStatusTests(unittest.TestCase): text = self.ts._render() self.assertEqual(len(text), self.ts._m.width) + def test_renders_from_beginning_if_there_is_not_enough_space(self): + w1 = ttystatus.Literal('foo') + w2 = ttystatus.Literal('bar') + self.ts.add(w1) + self.ts.add(w2) + self.ts._m.width = 4 + text = self.ts._render() + self.assertEqual(text, 'foob') + |