Skip to content

Commit

Permalink
Don't use Cell
Browse files Browse the repository at this point in the history
  • Loading branch information
ysthakur committed Aug 31, 2023
1 parent 46090a9 commit c567bce
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::cell::Cell;

use crossterm::event::{DisableBracketedPaste, EnableBracketedPaste};
use crossterm::execute;

Expand Down Expand Up @@ -112,7 +110,7 @@ pub struct Reedline {
// Stdout
painter: Painter,

transient_prompt: Cell<Option<Box<dyn Prompt>>>,
transient_prompt: Option<Box<dyn Prompt>>,

// Edit Mode: Vi, Emacs
edit_mode: Box<dyn EditMode>,
Expand Down Expand Up @@ -201,7 +199,7 @@ impl Reedline {
history_cursor_on_excluded: false,
input_mode: InputMode::Regular,
painter,
transient_prompt: Cell::new(None),
transient_prompt: None,
edit_mode,
completer,
quick_completions: false,
Expand Down Expand Up @@ -441,8 +439,8 @@ impl Reedline {

/// Set a different prompt to be used after submitting each line
#[must_use]
pub fn with_transient_prompt(self, transient_prompt: Box<dyn Prompt>) -> Self {
self.transient_prompt.set(Some(transient_prompt));
pub fn with_transient_prompt(mut self, transient_prompt: Box<dyn Prompt>) -> Self {
self.transient_prompt = Some(transient_prompt);
self
}

Expand Down Expand Up @@ -1712,9 +1710,9 @@ impl Reedline {
let buffer = self.editor.get_buffer().to_string();
self.hide_hints = true;
// Additional repaint to show the content without hints etc.
if let Some(transient_prompt) = self.transient_prompt.take() {
if let Some(transient_prompt) = std::mem::replace(&mut self.transient_prompt, None) {
self.repaint(transient_prompt.as_ref())?;
self.transient_prompt.set(Some(transient_prompt));
self.transient_prompt = Some(transient_prompt);
} else {
self.repaint(prompt)?;
}
Expand Down

0 comments on commit c567bce

Please sign in to comment.