INNER CODE UNIT · Python
on_search_changed
idoavrah/terraform-tui · src/tftui/app.py:243
def on_search_changed(self, event: Input.Changed) -> None:
"""Filter the tree, or highlight in place within a resource or plan."""
pane = self._searchable
if pane is None:
if self.state_tree.loading:
return
self.state_tree.rebuild(event.value.strip())
return
count = pane.search(event.value)
self.switcher.border_title = self._search_title()
self.search_input.set_class(bool(event.value) and not count, "nomatch")
@on(Input.Submitted, "#search")
def on_search_submitted(self) -> None:
"""Enter hands focus to the pane so n/N and scrolling work."""
pane = self._searchable
(pane or self.state_tree).focus()