Skip to content

Commit

Permalink
Merge pull request #73 from MilhoNerfado/72-delete-key
Browse files Browse the repository at this point in the history
Add `delete` key support
  • Loading branch information
matheuswhite authored May 9, 2024
2 parents 9fedcbd + 2f397b1 commit 1c573ef
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/command_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ impl CommandBar {
}

if self.command_line_idx > 0 {
self.update_command_list();
self.command_line_idx -= 1;
self.command_line = self
.command_line
Expand All @@ -370,7 +369,35 @@ impl CommandBar {
}
})
.collect();
self.update_command_list();
}

if self.command_line.chars().count() > 0
&& self.command_line.chars().all(|x| x.is_whitespace())
{
self.command_line.clear();
self.command_line_idx = 0;
self.show_hint();
}
}
KeyCode::Delete => {
if self.command_line.chars().count() == 0 {
self.show_hint();
}

self.command_line = self
.command_line
.chars()
.enumerate()
.filter_map(|(i, c)| {
if i != self.command_line_idx {
Some(c)
} else {
None
}
})
.collect();
self.update_command_list();

if self.command_line.chars().count() > 0
&& self.command_line.chars().all(|x| x.is_whitespace())
Expand Down

0 comments on commit 1c573ef

Please sign in to comment.