Skip to content

Commit

Permalink
fix: input - remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
roele committed Jan 23, 2024
1 parent 58c1e51 commit 9f3ca17
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ impl<'a> Input<'a> {

fn handle_backspace(&mut self) -> io::Result<()> {
let chars_count = self.input.chars().count();
if chars_count > 1 {
self.term.move_cursor_left(1)?;
}
if chars_count > 0 && self.cursor > 0 {
self.input.remove(self.cursor - 1);
}
Expand All @@ -150,15 +147,13 @@ impl<'a> Input<'a> {

fn handle_arrow_left(&mut self) -> io::Result<()> {
if self.cursor > 0 {
self.term.move_cursor_left(1)?;
self.cursor -= 1;
}
Ok(())
}

fn handle_arrow_right(&mut self) -> io::Result<()> {
if self.cursor < self.input.chars().count() {
self.term.move_cursor_right(1)?;
self.cursor += 1;
}
Ok(())
Expand Down Expand Up @@ -212,8 +207,6 @@ impl<'a> Input<'a> {
if !self.placeholder.is_empty() && self.input.is_empty() {
out.set_color(&self.theme.input_placeholder)?;
write!(out, "{}", &self.placeholder)?;
self.term
.move_cursor_left(self.placeholder.chars().count())?;
out.reset()?;
}

Expand Down

0 comments on commit 9f3ca17

Please sign in to comment.