From f0dc15833902b8ddea108327d129b2b644bfdaae Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 18 Oct 2018 22:49:30 -0700 Subject: [PATCH] cmds: word-wrap the list of files when removing files The list of files can grow very large, which then leads to a dialog with a very long text string. Avoid this problem by word-wrapping the list of files in the prompt. Closes #895 Reported-by: Thomas A. F. Thorne Signed-off-by: David Aguilar --- cola/cmds.py | 9 +++++++-- share/doc/git-cola/relnotes.rst | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cola/cmds.py b/cola/cmds.py index c8abcfea..34cda582 100644 --- a/cola/cmds.py +++ b/cola/cmds.py @@ -16,6 +16,7 @@ from . import core from . import gitcmds from . import icons from . import resources +from . import textwrap from . import utils from .diffparse import DiffParser from .git import STDOUT @@ -648,7 +649,8 @@ def file_summary(files): txt = core.list2cmdline(files) if len(txt) > 768: txt = txt[:768].rstrip() + '...' - return txt + wrap = textwrap.TextWrapper() + return '\n'.join(wrap.wrap(txt)) class RemoteCommand(ConfirmAction): @@ -828,7 +830,8 @@ class RemoveFiles(ContextCommand): if bad_filenames: Interaction.information( - N_('Error'), N_('Deleting "%s" failed') % file_summary(files)) + N_('Error'), + N_('Deleting "%s" failed') % file_summary(bad_filenames)) if rescan: self.model.update_file_status() @@ -845,6 +848,8 @@ class Delete(RemoveFiles): if not files: return + wrap = textwrap.TextWrapper() + title = N_('Delete Files?') msg = N_('The following files will be deleted:') + '\n\n' msg += file_summary(files) diff --git a/share/doc/git-cola/relnotes.rst b/share/doc/git-cola/relnotes.rst index 3b225f9a..568d3941 100644 --- a/share/doc/git-cola/relnotes.rst +++ b/share/doc/git-cola/relnotes.rst @@ -34,6 +34,12 @@ Usability, bells and whistles Fixes ----- +* The "Delete Files" feature was creating an unreadable display when + many files were selected. Word-wrap the list of files so that the + display stays within a sensible size. + + https://github.com/git-cola/git-cola/issues/895 + * Spelling and grammar fixes. https://github.com/git-cola/git-cola/pull/891 -- 2.11.4.GIT