Make the prompt not null

pull/475/head
Arijit Basu 2 years ago committed by Arijit Basu
parent d2390285fb
commit 5f598648a8

@ -281,7 +281,7 @@ YAML: `FollowSymlink`
Set the input prompt temporarily, until the input buffer is reset.
Type: { SetInputPrompt = nullable string }
Type: { SetInputPrompt = string }
Example:

@ -154,7 +154,7 @@ pub struct LuaContextLight {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputBuffer {
pub buffer: Option<Input>,
pub prompt: Option<String>,
pub prompt: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -285,7 +285,7 @@ impl App {
let input = InputBuffer {
buffer: Default::default(),
prompt: config.general.prompt.format.clone(),
prompt: config.general.prompt.format.clone().unwrap_or_default(),
};
let mut app = Self {
@ -808,7 +808,7 @@ impl App {
}
}
fn set_input_prompt(mut self, p: Option<String>) -> Result<Self> {
fn set_input_prompt(mut self, p: String) -> Result<Self> {
self.input.prompt = p;
Ok(self)
}
@ -883,7 +883,13 @@ impl App {
fn reset_input_buffer(mut self) -> Result<Self> {
self.input = InputBuffer {
buffer: Default::default(),
prompt: self.config.general.prompt.format.clone(),
prompt: self
.config
.general
.prompt
.format
.to_owned()
.unwrap_or_default(),
};
Ok(self)
}

@ -242,13 +242,13 @@ pub enum ExternalMsg {
/// Set the input prompt temporarily, until the input buffer is reset.
///
/// Type: { SetInputPrompt = nullable string }
/// Type: { SetInputPrompt = string }
///
/// Example:
///
/// - Lua: `{ SetInputPrompt = "→" }`
/// - YAML: `SetInputPrompt: →`
SetInputPrompt(Option<String>),
SetInputPrompt(String),
/// Update the input buffer using cursor based operations.
///

@ -817,12 +817,7 @@ fn draw_input_buffer<B: Backend>(
1
} else {
0
} + app
.input
.prompt
.as_ref()
.map(|t| t.chars().count() as u16)
.unwrap_or(0);
} + app.input.prompt.chars().count() as u16;
let cursor_offset_right = if config
.borders
@ -841,7 +836,7 @@ fn draw_input_buffer<B: Backend>(
let input_buf = Paragraph::new(Spans::from(vec![
Span::styled(
app.input.prompt.to_owned().unwrap_or_default(),
app.input.prompt.to_owned(),
app.config.general.prompt.style.to_owned().into(),
),
Span::raw(input.value()),

Loading…
Cancel
Save