Merge branch 'fix_completion_crashes' of https://github.com/rcorre/qutebrowser into rcorre-fix_completion_crashes
This commit is contained in:
commit
fc6e600e6d
@ -192,10 +192,13 @@ class CompletionView(QTreeView):
|
|||||||
Args:
|
Args:
|
||||||
prev: True for prev item, False for next one.
|
prev: True for prev item, False for next one.
|
||||||
"""
|
"""
|
||||||
idx = self._next_idx(prev)
|
# selmodel can be None if 'show' and 'auto-open' are set to False
|
||||||
qtutils.ensure_valid(idx)
|
# https://github.com/The-Compiler/qutebrowser/issues/1731
|
||||||
self.selectionModel().setCurrentIndex(
|
selmodel = self.selectionModel()
|
||||||
idx, QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows)
|
if (selmodel is not None):
|
||||||
|
idx = self._next_idx(prev)
|
||||||
|
selmodel.setCurrentIndex(idx,
|
||||||
|
QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows)
|
||||||
|
|
||||||
def set_model(self, model):
|
def set_model(self, model):
|
||||||
"""Switch completion to a new model.
|
"""Switch completion to a new model.
|
||||||
|
@ -119,6 +119,8 @@ def test_maybe_resize_completion(completionview, config_stub, qtbot):
|
|||||||
([['Aa'], []], -1, 'Aa'),
|
([['Aa'], []], -1, 'Aa'),
|
||||||
([['Aa'], [], []], 1, 'Aa'),
|
([['Aa'], [], []], 1, 'Aa'),
|
||||||
([['Aa'], [], []], -1, 'Aa'),
|
([['Aa'], [], []], -1, 'Aa'),
|
||||||
|
([[]], 1, None),
|
||||||
|
([[]], -1, None),
|
||||||
])
|
])
|
||||||
def test_completion_item_next_prev(tree, count, expected, completionview):
|
def test_completion_item_next_prev(tree, count, expected, completionview):
|
||||||
"""Test that on_next_prev_item moves the selection properly.
|
"""Test that on_next_prev_item moves the selection properly.
|
||||||
@ -146,3 +148,13 @@ def test_completion_item_next_prev(tree, count, expected, completionview):
|
|||||||
completionview.completion_item_next()
|
completionview.completion_item_next()
|
||||||
idx = completionview.selectionModel().currentIndex()
|
idx = completionview.selectionModel().currentIndex()
|
||||||
assert filtermodel.data(idx) == expected
|
assert filtermodel.data(idx) == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_completion_item_next_prev_no_model(completionview):
|
||||||
|
"""Test that next/prev won't crash with no model set.
|
||||||
|
|
||||||
|
This can happen if completion.show and completion.auto-open are False.
|
||||||
|
Regression test for issue #1722.
|
||||||
|
"""
|
||||||
|
completionview.completion_item_prev()
|
||||||
|
completionview.completion_item_next()
|
||||||
|
Loading…
Reference in New Issue
Block a user