QScintilla/QsciScintillaCompat.py

changeset 6309
acaae2a2f1cb
parent 6305
7652b925c25e
child 6312
5d3c401188c6
--- a/QScintilla/QsciScintillaCompat.py	Tue May 29 09:41:52 2018 +0200
+++ b/QScintilla/QsciScintillaCompat.py	Tue May 29 14:25:12 2018 +0200
@@ -1538,24 +1538,29 @@
         
         itemHeight = ch.visualItemRect(all_items[0]).height()
         height = min(self.maxLines, len(all_items)) * itemHeight
-        # Just a fiddling factor: 4 for the borders, 2 for better readability,
+        # Just a fiddling factor: 2 for better readability,
         # e.g. underscores at the end of the list.
-        height += 6
+        height += 2
         
-        sbSize = self.verticalScrollBar().sizeHint().width()
         font = ch.font()
         fm = QFontMetrics(font)
         averageCharWidth = fm.averageCharWidth()
         maxWidth = averageCharWidth * self.maxChars
-        if width > (maxWidth):
+        if width > maxWidth:
             width = maxWidth
-            height += sbSize
             # List box doesn't honor limited size to show scroll bars, e.g.
             # Python 2 on Win 10. So just force it.
             ch.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
         
-        if len(all_items) > self.maxLines:
-            width += sbSize
+        hsb = self.horizontalScrollBar()
+        if hsb.isVisible():
+            hsbHeight = hsb.sizeHint().height()
+            height += hsbHeight
+        
+        vsb = self.verticalScrollBar()
+        if vsb.isVisible():
+            vsbWidth = vsb.sizeHint().width()
+            width += vsbWidth
         
         # Special case, where the space below current line where to less
         yPos = geom.y()

eric ide

mercurial