# LibTmux.Selection.where/2

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/66b9b1c3f3f3186428abdfda2c76f5cf87446710/lib/libtmux/selection.ex#L55
- **Page:** https://libtmux.org/en/elixir/latest/reference/libtmux-selection-where-2/

```
where(selection, criteria)
@spec where(t(item), LibTmux.Filter.input()) :: t(item)
      when item: LibTmux.Schema.observation()
```

Filters validated data while retaining order and captured graph context.

## Examples

One pane must satisfy both conditions inside `some`. Window `@0` has an active shell and an inactive editor; only `@1` has an active editor. See [filtering](filtering.html#predicate-grammar) for the complete semantics.

```elixir
iex> alias LibTmux.{Selection, Snapshot}
iex> rows = %{window: [%{id: "@0"}, %{id: "@1"}], pane: [
...>   %{id: "%0", window_id: "@0", active: true, current_command: "bash"},
...>   %{id: "%1", window_id: "@0", active: false, current_command: "nvim"},
...>   %{id: "%2", window_id: "@1", active: true, current_command: "nvim"}]}
iex> {:ok, snapshot} = Snapshot.new(rows,
...>   server_instance: "example", captured_from: 0, captured_until: 0,
...>   complete: [:pane], fields: %{pane: [:window_id, :active, :current_command]})
iex> snapshot |> Snapshot.windows()
...> |> Selection.where(panes: [some: [active: true, current_command: "nvim"]])
...> |> Enum.map(& &1.id)
["@1"]
```

## Type parameters

- `item` (bound `LibTmux.Schema.observation()`)

## Parameters

- `selection` (`t(item)`)
- `criteria` (`LibTmux.Filter.input()`)
