# Add persistence to command palette history \(\#26948\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 16f625bd07eacd071ce21f669b6baf4847e20ab6

Requested commit: 16f625bd07eacd071ce21f669b6baf4847e20ab6

Commit: 16f625bd07eacd071ce21f669b6baf4847e20ab6

Tree: b1616aad7a2bd409024f58fe58f919a403d5826e

Author: KyleBarton

Committer: GitHub

## Message

```
Add persistence to command palette history (#26948)

Closes #20391

### Summary
This adds a persistence layer to the command palette so that usages can
persist after Zed is closed and re-opened.

The current "usage" algorithm is unchanged, e.g.:
- Sorts by number of usages descending (no recency preference)
- Once a user's query is active, removes these suggestions in favor of
fuzzy matching

There are some additional considerations in order to keep the DB from
growing uncontrollably (and to make long-term use ergonomic):
- The "invocations" count handles max values (though at u16, it seems
unlikely a user will deal with this)
- If a command is un-invoked for more than a month, it stops being
considered a recent usage, and its next update will update its usages
back to 1

### Future Considerations
- Could make the "command expiry" configurable in settings, so the user
can decide how long to hold onto recent usages
- Could make a more sophisticated algorithm which balances recency and
total invocations - e.g. if I've used COMMAND_A 100 times in the last
month, but COMMAND_B 10 times today, should COMMAND_B actually be
preferred?
- Could do preferential fuzzy-matching against these matches once the
user starts a query.

Release Notes:

- Added persistent history of command palette usages.

---------

Co-authored-by: Peter Finn <mastion11@gmail.com>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
```

## Parents

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

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