diff --git a/containermap.go b/containermap.go index 67f5ad2..37a0363 100644 --- a/containermap.go +++ b/containermap.go @@ -104,9 +104,15 @@ func (cm *ContainerMap) All() []*Container { re := regexp.MustCompile(fmt.Sprintf(".*%s", filter)) for _, c := range cm.containers { - if re.FindAllString(c.name, 1) != nil { - containers = append(containers, c) + // Apply name filter + if re.FindAllString(c.name, 1) == nil { + continue } + // Apply state filter + if !config.GetSwitchVal("allContainers") && c.state != "running" { + continue + } + containers = append(containers, c) } sort.Sort(containers) diff --git a/grid.go b/grid.go index cba968c..56cdcf9 100644 --- a/grid.go +++ b/grid.go @@ -82,9 +82,6 @@ func (g *Grid) redrawRows() { } ui.Body.AddRows(fieldHeader()) for _, c := range g.containers { - if !config.GetSwitchVal("allContainers") && c.state != "running" { - continue - } ui.Body.AddRows(c.widgets.Row()) }