Skip to content

Commit

Permalink
Merge pull request #1 from ysthakur/no-arc-mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
ysthakur authored Sep 12, 2023
2 parents 22609d0 + a086b4c commit 35f44ae
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::{Arc, Mutex};

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

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

transient_prompt: Option<Arc<Mutex<Box<dyn Prompt>>>>,
transient_prompt: Option<Box<dyn Prompt>>,

// Edit Mode: Vi, Emacs
edit_mode: Box<dyn EditMode>,
Expand Down Expand Up @@ -442,7 +440,7 @@ impl Reedline {
/// Set a different prompt to be used after submitting each line
#[must_use]
pub fn with_transient_prompt(mut self, transient_prompt: Box<dyn Prompt>) -> Self {
self.transient_prompt = Some(Arc::from(Mutex::from(transient_prompt)));
self.transient_prompt = Some(transient_prompt);
self
}

Expand Down Expand Up @@ -1712,16 +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 {
match transient_prompt.clone().lock() {
Ok(transient_prompt) => {
self.repaint(transient_prompt.as_ref())?;
}
Err(_) => {
// TODO log error
self.repaint(prompt)?;
}
}
if let Some(transient_prompt) = self.transient_prompt.take() {
self.repaint(transient_prompt.as_ref())?;
self.transient_prompt = Some(transient_prompt);
} else {
self.repaint(prompt)?;
}
Expand Down

0 comments on commit 35f44ae

Please sign in to comment.