Skip to content

Commit

Permalink
Stopped memory leak.
Browse files Browse the repository at this point in the history
Removed some heap allocations.
Split up how we process command vs user completions
  • Loading branch information
ryanc@lastyard.com committed Jul 5, 2023
1 parent 5ab2cc2 commit d8a421e
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 115 deletions.
7 changes: 3 additions & 4 deletions src/widget/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ where
type Event = Event;

fn update(&mut self, state: &mut Self::State, event: Self::Event) -> Option<Message> {
let users = &self.users;
match event {
Event::Input(input) => {
// Reset error state
Expand All @@ -84,7 +83,7 @@ where

state.input = input;

state.completion.process(&state.input, users.clone());
state.completion.process(&state.input, &self.users[..]);

None
}
Expand Down Expand Up @@ -139,7 +138,7 @@ where
.get(state.selected_history.unwrap())
.unwrap()
.clone();
state.completion.process(&state.input);
state.completion.process(&state.input, &self.users);

return Some(self.on_completion.clone());
}
Expand All @@ -156,7 +155,7 @@ where
} else {
*index -= 1;
state.input = state.history.get(*index).unwrap().clone();
state.completion.process(&state.input);
state.completion.process(&state.input, &self.users);
}

return Some(self.on_completion.clone());
Expand Down
Loading

0 comments on commit d8a421e

Please sign in to comment.