# Clear search results on invalid query input \(\#7958\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 6d9b8cc5950cec7bede4e287ec0ebdf3aeeb4e5d

Requested commit: 6d9b8cc5950cec7bede4e287ec0ebdf3aeeb4e5d

Commit: 6d9b8cc5950cec7bede4e287ec0ebdf3aeeb4e5d

Tree: acf9865395c6b6a1386119ddbe8cbcdb7f3541e5

Author: Andrew Lygin

Committer: GitHub

## Message

```
Clear search results on invalid query input (#7958)

Fixes a bug in the buffer search bar: Clears results of a previous
successfull search when the user enters invalid search request.

Steps to reproduce the bug:
1. Switch to Regex search mode.
2. Enter a valid search query that produces several matches.
3. Add a symbol to the search query that makes it an invalid regexp.
4. Switch to the editor and walk through the code back and forth.

Expected result: All the match highlightings after step 2 are cleared,
search bar indicates absence of the last search matches.

Actual: The results from the last valid search are highlighted, search
bar indicates presence of matches.

Potentially, the same effect may occur when searching in the simple text
mode, or when clearing the search query in some circumstances, so I made
the fix for all those cases, though I wasn't able to reproduce them
manually.

The bug:


https://github.com/zed-industries/zed/assets/2101250/1c50b98c-ae8e-4a9c-8ff5-1e5c63027ec3

After the fix:


https://github.com/zed-industries/zed/assets/2101250/e3eedf8c-2e3e-41ee-81cc-c2c9d919fba3

Release Notes:
- Clear search results on invalid query input
```

## Parents

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

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