changeset 33813:1e71a27dee97

crecord: fixes the formatting of the select status in the status line The status line in the crecord has the "space" status field which has variable length depending on the length of the status label in the language of choice. In English, the status labels are "space: deselect" and "space:select". The "deselect" label is 2 glyphs longer. This makes the terminal output jump around if the terminal width is just right so that the shorter label makes the status line 1 line long, and the longer label makes it 2 lines long. This patch formats the selected status into a fixed-width field. The field width is the maximum of the lengths of the two possible labels, to account for differing translations and label lengths. This should make the label behavior uniform across localizations. There does not seem to be a test for crecord, so I verified the change manually with a local build of 'hg'.
author Filip Filmar <filmil@gmail.com>
date Sun, 13 Aug 2017 00:17:13 -0700
parents 4ba863c88135
children 81b12f69ef5b
files mercurial/crecord.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/crecord.py	Mon Aug 14 13:35:26 2017 +0900
+++ b/mercurial/crecord.py	Sun Aug 13 00:17:13 2017 -0700
@@ -1010,6 +1010,13 @@
     def _getstatuslinesegments(self):
         """-> [str]. return segments"""
         selected = self.currentselecteditem.applied
+        spaceselect = _('space: select')
+        spacedeselect = _('space: deselect')
+        # Format the selected label into a place as long as the longer of the
+        # two possible labels.  This may vary by language.
+        spacelen = max(len(spaceselect), len(spacedeselect))
+        selectedlabel = '%-*s' % (spacelen,
+                                  spacedeselect if selected else spaceselect)
         segments = [
             _headermessages[self.operation],
             '-',
@@ -1017,7 +1024,7 @@
             _('c: confirm'),
             _('q: abort'),
             _('arrow keys: move/expand/collapse'),
-            _('space: deselect') if selected else _('space: select'),
+            selectedlabel,
             _('?: help'),
         ]
         return segments