mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-28 21:32:39 +00:00
Cap the size of the Supermaven states buffer (#19246)
Caps the size of the Supermaven states buffer to 1000 elements. Previously, the buffer would grow unbounded so for long sessions the number of states that the Supermaven autocomplete provider maintains can be quite large. In practice, states that are sufficiently old are so unlikely to be visited again that we can regenerate the completion. Thus, we can cap the buffer to 1000 elements. Release Notes: - N/A
This commit is contained in:
parent
d0bc84eb33
commit
6c7e79eff6
1 changed files with 8 additions and 0 deletions
|
@ -147,6 +147,14 @@ impl Supermaven {
|
|||
updates_tx,
|
||||
},
|
||||
);
|
||||
// ensure the states map is max 1000 elements
|
||||
if agent.states.len() > 1000 {
|
||||
// state id is monotonic so it's sufficient to remove the first element
|
||||
agent
|
||||
.states
|
||||
.remove(&agent.states.keys().next().unwrap().clone());
|
||||
}
|
||||
|
||||
let _ = agent
|
||||
.outgoing_tx
|
||||
.unbounded_send(OutboundMessage::StateUpdate(StateUpdateMessage {
|
||||
|
|
Loading…
Reference in a new issue