Store pattern in completion view, not model.
The pattern property is used for highlighting. It is purely display-related, so it should be in the view rather than the model.
This commit is contained in:
parent
262b028ee9
commit
fd07c571e5
@ -196,7 +196,8 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
||||
self._doc.setDocumentMargin(2)
|
||||
|
||||
if index.parent().isValid():
|
||||
pattern = index.model().pattern
|
||||
view = self.parent()
|
||||
pattern = view.pattern
|
||||
columns_to_filter = index.model().columns_to_filter(index)
|
||||
if index.column() in columns_to_filter and pattern:
|
||||
repl = r'<span class="highlight">\g<0></span>'
|
||||
|
@ -40,6 +40,7 @@ class CompletionView(QTreeView):
|
||||
headers, and children show as flat list.
|
||||
|
||||
Attributes:
|
||||
pattern: Current filter pattern, used for highlighting.
|
||||
_win_id: The ID of the window this CompletionView is associated with.
|
||||
_height: The height to use for the CompletionView.
|
||||
_height_perc: Either None or a percentage if height should be relative.
|
||||
@ -106,6 +107,7 @@ class CompletionView(QTreeView):
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
self.pattern = ''
|
||||
self._win_id = win_id
|
||||
# FIXME handle new aliases.
|
||||
# objreg.get('config').changed.connect(self.init_command_completion)
|
||||
@ -288,6 +290,7 @@ class CompletionView(QTreeView):
|
||||
self.expand(model.index(i, 0))
|
||||
|
||||
def set_pattern(self, pattern):
|
||||
self.pattern = pattern
|
||||
with debug.log_time(log.completion, 'Set pattern {}'.format(pattern)):
|
||||
self.model().set_pattern(pattern)
|
||||
self._resize_columns()
|
||||
|
@ -35,7 +35,6 @@ class CompletionModel(QAbstractItemModel):
|
||||
Attributes:
|
||||
column_widths: The width percentages of the columns used in the
|
||||
completion view.
|
||||
pattern: Current filter pattern, used for highlighting.
|
||||
_categories: The sub-categories.
|
||||
"""
|
||||
|
||||
@ -43,7 +42,6 @@ class CompletionModel(QAbstractItemModel):
|
||||
super().__init__(parent)
|
||||
self.column_widths = column_widths
|
||||
self._categories = []
|
||||
self.pattern = ''
|
||||
|
||||
def _cat_from_idx(self, index):
|
||||
"""Return the category pointed to by the given index.
|
||||
@ -180,8 +178,6 @@ class CompletionModel(QAbstractItemModel):
|
||||
pattern: The filter pattern to set.
|
||||
"""
|
||||
log.completion.debug("Setting completion pattern '{}'".format(pattern))
|
||||
# TODO: should pattern be saved in the view layer instead?
|
||||
self.pattern = pattern
|
||||
for cat in self._categories:
|
||||
cat.set_pattern(pattern)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user