Don't crash on tab with no completions.
first_item and last_item return an invalid index when there are no items in the completion, and the completionwidget will throw on an invalid index. However, setting an invalid index on the selection view is fine, so just remove the assertion. Resolves #1731.
This commit is contained in:
parent
ef439bb916
commit
6e2d78b826
@ -193,9 +193,8 @@ class CompletionView(QTreeView):
|
||||
prev: True for prev item, False for next one.
|
||||
"""
|
||||
idx = self._next_idx(prev)
|
||||
qtutils.ensure_valid(idx)
|
||||
self.selectionModel().setCurrentIndex(
|
||||
idx, QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows)
|
||||
self.selectionModel().setCurrentIndex(idx,
|
||||
QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows)
|
||||
|
||||
def set_model(self, 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'),
|
||||
([[]], 1, None),
|
||||
([[]], -1, None),
|
||||
])
|
||||
def test_completion_item_next_prev(tree, count, expected, completionview):
|
||||
"""Test that on_next_prev_item moves the selection properly.
|
||||
|
Loading…
Reference in New Issue
Block a user