From 76638d0562794c571b085e775b2ed5442494073e Mon Sep 17 00:00:00 2001 From: Abogical Date: Mon, 14 Nov 2016 14:56:34 +0200 Subject: [PATCH] If there is a small space for ellipsis_truncate, show '...' only --- src/borg/helpers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 853d3625b..f2dd59ad0 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1200,6 +1200,8 @@ def ellipsis_truncate(msg, space): from .platform import swidth ellipsis_width = swidth('...') msg_width = swidth(msg) + if space < 8: + return '...' + ' ' * (space - ellipsis_width) if space < ellipsis_width + msg_width: return '%s...%s' % (swidth_slice(msg, space // 2 - ellipsis_width), swidth_slice(msg, -space // 2)) @@ -1262,10 +1264,7 @@ class ProgressIndicatorPercent: terminal_space = get_terminal_size(fallback=(-1, -1))[0] if terminal_space != -1: space = terminal_space - len(self.msg % tuple([pct] + info[:-1] + [''])) - if space < 8: - info[-1] = ' ' * space - else: - info[-1] = ellipsis_truncate(info[-1], space) + info[-1] = ellipsis_truncate(info[-1], space) return self.output(self.msg % tuple([pct] + info), justify=False) return self.output(self.msg % pct)