# csv_preview: Make filter unavailability order-independent \(\#61796\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/17d71d2b6d42efe361d147fc5c3119831e0a6723)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 17d71d2b6d42efe361d147fc5c3119831e0a6723

Requested commit: 17d71d2b6d42efe361d147fc5c3119831e0a6723

Commit: 17d71d2b6d42efe361d147fc5c3119831e0a6723

Tree: 662c1948fe12698fd2101ac6560bccc5d09a3012

Author: Oleksandr Kholiavko

Committer: GitHub

## Message

````
csv_preview: Make filter unavailability order-independent (#61796)

# Objective

A column's filter popover grays out values that would leave zero rows
given other active filters.
That check only looked at columns filtered _before_ the one being
viewed, so reopening a filter on a column filtered earlier than another
still-active one showed a value as available with count `0` —
selectable, but guaranteed to empty the table.

Separately, values already checked when they became blocked lost their
checkmark and couldn't be unchecked from the popover (matches IntelliJ's
reference behavior of always keeping values checkable with an honest
count, never fully disabled).

## Solution

- Availability now reuses the same `rows_passing_other_filters` set
already used for counts (every other active column's filter, own filter
excluded) instead of the old order-dependent cascade over
`activation_order`. Removed `activation_order` entirely — now dead code.
- `Unavailable` carries `is_applied`, same as `Available`.
Hidden-and-applied rows stay checked and toggleable (to uncheck); only
hidden-and-unapplied rows stay disabled.
- Filter popover footer no longer disappears when a filter's count drops
to `0` (`has_active_filters` instead of `selected_rows == 0`).

## Testing

Fixture:

```csv
A,C
1,red
2,red
1,blue
1,blue
```

Rendered as:
<img width="381" height="165" alt="image"
src="https://github.com/user-attachments/assets/fc12d1d3-26e6-4f8e-97f0-5522f67e70ea"
/>


Manual:
apply filters:
- C=red,blue
- A=2
reopening C's popover shows the blocked `blue` value grayed with count
`0`, stays checked and uncheckable.

## Demo

| Before (counds not updated) | After (counts reflect reality) |
| --- | --- |
| <img width="631" height="190" alt="image"
src="https://github.com/user-attachments/assets/df433449-826d-4f7e-8c35-d3779911b7fa"
/> | <img width="615" height="217" alt="image"
src="https://github.com/user-attachments/assets/ce067fb9-3fd5-4d2a-9689-8defc587f617"
/> |


Release Notes:

- Fixed CSV preview column filters showing incorrect availability/counts
depending on which filter was applied first
````

## Parents

- [18be72fd68510984fe6f67d0d21de4e38a836747](https://git.cafe/gitcafe/zed/commit/18be72fd68510984fe6f67d0d21de4e38a836747?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/17d71d2b6d42efe361d147fc5c3119831e0a6723?format=markdown)
