From 3a72694e5ac424cb8129eec3b0c5399ac60ca4f1 Mon Sep 17 00:00:00 2001 From: Gu1llaum-3 Date: Wed, 3 Sep 2025 10:04:24 +0200 Subject: [PATCH] fix: preserve search filter after host operations --- internal/ui/update.go | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/internal/ui/update.go b/internal/ui/update.go index eae25b6..a7cc10b 100644 --- a/internal/ui/update.go +++ b/internal/ui/update.go @@ -70,7 +70,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit } m.hosts = m.sortHosts(hosts) - m.filteredHosts = m.hosts + + // Reapply search filter if there is one active + if m.searchInput.Value() != "" { + m.filteredHosts = m.filterHosts(m.searchInput.Value()) + } else { + m.filteredHosts = m.hosts + } + m.updateTableRows() m.viewMode = ViewList m.addForm = nil @@ -107,7 +114,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit } m.hosts = m.sortHosts(hosts) - m.filteredHosts = m.hosts + + // Reapply search filter if there is one active + if m.searchInput.Value() != "" { + m.filteredHosts = m.filterHosts(m.searchInput.Value()) + } else { + m.filteredHosts = m.hosts + } + m.updateTableRows() m.viewMode = ViewList m.editForm = nil @@ -234,7 +248,14 @@ func (m Model) handleListViewKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) { return m, nil } m.hosts = m.sortHosts(hosts) - m.filteredHosts = m.hosts + + // Reapply search filter if there is one active + if m.searchInput.Value() != "" { + m.filteredHosts = m.filterHosts(m.searchInput.Value()) + } else { + m.filteredHosts = m.hosts + } + m.updateTableRows() m.deleteMode = false m.deleteHost = ""