# HG changeset patch # User Filip Filmar # Date 2017-08-13 07:17:13 # Node ID 1e71a27dee970ec9ef02c004f662b5a99182f69b # Parent 4ba863c88135a2fd2f44c8b463ef6956763fd81e 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'. diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -1010,6 +1010,13 @@ class curseschunkselector(object): 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 @@ class curseschunkselector(object): _('c: confirm'), _('q: abort'), _('arrow keys: move/expand/collapse'), - _('space: deselect') if selected else _('space: select'), + selectedlabel, _('?: help'), ] return segments