From 58043b5653e50a79ca76a587d31154facc66548b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 14 Dec 2017 09:13:34 +0100 Subject: [PATCH] Always subtract scroll bar width from completion view The situation where there's no scroll bar at the point the column widths are calculated is a very rare one. What happens more often is that the scroll bar disappears due to filtering, in which case we didn't recalculate the column widths anyways. Furthermore, we can even go wrong with this calculation, when we calculate the column widths while the entire completion is invisible - then the scroll bar won't be visible either, and we won't subtract the space needed for it. Let's not try to optimize for this uncommon case, and just always subtract the scrollbar, even if it's not there initially. Fixes #3359 Closes #3389 --- qutebrowser/completion/completionwidget.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 29471597f..2cfc6db7a 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -152,12 +152,12 @@ class CompletionView(QTreeView): column_widths = self.model().column_widths pixel_widths = [(width * perc // 100) for perc in column_widths] - if self.verticalScrollBar().isVisible(): - delta = self.style().pixelMetric(QStyle.PM_ScrollBarExtent) + 5 - if pixel_widths[-1] > delta: - pixel_widths[-1] -= delta - else: - pixel_widths[-2] -= delta + delta = self.style().pixelMetric(QStyle.PM_ScrollBarExtent) + 5 + if pixel_widths[-1] > delta: + pixel_widths[-1] -= delta + else: + pixel_widths[-2] -= delta + for i, w in enumerate(pixel_widths): assert w >= 0, i self.setColumnWidth(i, w)