Skip to content

Commit

Permalink
fix: fix for placeholder display bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wadackel committed Jan 14, 2024
1 parent 443216b commit d63d5f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions src/themes/fancy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ impl FancyTheme {
}

fn fmt_placeholder(&self, placeholder: String) -> String {
let mut chars = placeholder.char_indices();
let cursor = chars.nth(0).unwrap_or((0, ' '));
let second = chars.nth(1).unwrap_or((0, ' '));
let rest = &placeholder[second.0..];
let input = InputCursor::new(placeholder, 0);
let (_, cursor, right) = input.split();
format!(
"{}{}",
Styled::new(cursor.1).rev(),
Styled::new(rest).fg(Color::DarkGrey),
Styled::new(cursor).rev(),
Styled::new(right).fg(Color::DarkGrey),
)
}

Expand All @@ -91,7 +89,7 @@ impl FancyTheme {
self.fmt_line(color, input)
}
PromptInput::Cursor(c) => {
let input = if c.is_empty() {
let input = if c.value().is_empty() {
self.fmt_placeholder(placeholder.unwrap_or_default())
} else {
self.fmt_cursor(c)
Expand Down
12 changes: 5 additions & 7 deletions src/themes/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ impl MinimalTheme {
}

fn fmt_placeholder(&self, placeholder: String) -> String {
let mut chars = placeholder.char_indices();
let cursor = chars.nth(0).unwrap_or((0, ' '));
let second = chars.nth(1).unwrap_or((0, ' '));
let rest = &placeholder[second.0..];
let input = InputCursor::new(placeholder, 0);
let (_, cursor, right) = input.split();
format!(
"{}{}",
Styled::new(cursor.1).rev(),
Styled::new(rest).fg(Color::DarkGrey),
Styled::new(cursor).rev(),
Styled::new(right).fg(Color::DarkGrey),
)
}

Expand All @@ -62,7 +60,7 @@ impl MinimalTheme {
self.fmt_input_layout(input)
}
PromptInput::Cursor(c) => {
let input = if c.is_empty() {
let input = if c.value().is_empty() {
self.fmt_placeholder(placeholder.unwrap_or_default())
} else {
self.fmt_cursor(c)
Expand Down

0 comments on commit d63d5f6

Please sign in to comment.