| 503 | } |
| 504 | |
| 505 | pub fn take_input(&mut self) -> String { |
| 506 | let input = std::mem::take(&mut self.input); |
| 507 | let trimmed = input.trim(); |
| 508 | if !trimmed.is_empty() { |
| 509 | self.push_history(input.clone()); |
| 510 | self.bump_frecency(trimmed); |
| 511 | if let Some(first) = trimmed.split_whitespace().next() { |
| 512 | if first.starts_with('/') || first.starts_with('@') { |
| 513 | self.bump_frecency(first); |
| 514 | } |
| 515 | } |
| 516 | store_history(&self.history_path, &self.history); |
| 517 | store_frecency(&self.frecency_path, &self.frecency); |
| 518 | } |
| 519 | self.cursor_position = 0; |
| 520 | self.history_index = None; |
| 521 | self.history_draft = None; |
| 522 | self.suggestions.clear(); |
| 523 | self.suggestion_index = None; |
| 524 | self.mode = PromptMode::Normal; |
| 525 | self.reset_interrupt_confirmation(); |
| 526 | input |
| 527 | } |
| 528 | |
| 529 | pub fn clear(&mut self) { |
| 530 | self.input.clear(); |