Commits

Angel Ezquerra  committed b75b832

repowidget: limit infobar error messages to 2 lines of up to 140 chars by default

Longer lines and longer messages are cut with a '...' string appended at their
ends.

  • Participants
  • Parent commits 67f8b46

Comments (0)

Files changed (1)

File tortoisehg/hgqt/repowidget.py

             return False
 
     @pyqtSlot(unicode, unicode)
-    def _showOutputOnInfoBar(self, msg, label):
+    def _showOutputOnInfoBar(self, msg, label, maxlines=2, maxwidth=140):
         labelslist = unicode(label).split()
         if 'ui.error' in labelslist:
-            self.setInfoBar(qtlib.CommandErrorInfoBar, unicode(msg).strip())
+            # Limit the text shown on the info bar to maxlines lines of up to maxwidth chars
+            msglines = unicode(msg).strip().splitlines()
+            infolines = []
+            for line in msglines[0:maxlines]:
+                if len(line) > maxwidth:
+                    line = line[0:maxwidth] + ' ...'
+                infolines.append(line)
+            if len(msglines) > maxlines and not infolines[-1].endswith('...'):
+                infolines[-1] += ' ...'
+            self.setInfoBar(qtlib.CommandErrorInfoBar, '\n'.join(infolines))
 
     @pyqtSlot(unicode)
     def _showMessageOnInfoBar(self, msg):