--- a/QScintilla/QsciScintillaCompat.py Thu May 31 19:27:56 2018 +0200 +++ b/QScintilla/QsciScintillaCompat.py Thu May 31 23:06:41 2018 +0200 @@ -1529,38 +1529,39 @@ return width = 0 + maxItemHeight = 0 for item in all_items: - itemWidth = ch.visualItemRect(item).width() + visualRect = ch.visualItemRect(item) + itemWidth = visualRect.width() if itemWidth > width: width = itemWidth - - width += 4 # Borders + itemHeight = visualRect.height() + if itemHeight > maxItemHeight: + maxItemHeight = itemHeight - itemHeight = ch.visualItemRect(all_items[0]).height() - height = min(self.maxLines, len(all_items)) * itemHeight + height = min(self.maxLines, len(all_items)) * maxItemHeight # Just a fiddling factor: 2 for better readability, # e.g. underscores at the end of the list. height += 2 + # Borders + borders = geom.size() - ch.contentsRect().size() + width += borders.width() + height += borders.height() + font = ch.font() fm = QFontMetrics(font) averageCharWidth = fm.averageCharWidth() maxWidth = averageCharWidth * self.maxChars if width > maxWidth: width = maxWidth + height += ch.horizontalScrollBar().sizeHint().height() # 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) - hsb = self.horizontalScrollBar() - if hsb.isVisible(): - hsbHeight = hsb.sizeHint().height() - height += hsbHeight - - vsb = self.verticalScrollBar() - if vsb.isVisible(): - vsbWidth = vsb.sizeHint().width() - width += vsbWidth + if len(all_items) > self.maxLines: + width += ch.verticalScrollBar().sizeHint().width() # Special case, where the space below current line where to less yPos = geom.y()