Skip to content

Commit

Permalink
Fixing the command history
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohnson5 committed Aug 6, 2024
1 parent c02a797 commit f993b67
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions blast_cli/src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl BlastTab for ConfigureTab {
} else {
// Otherwise, run the command and show the output
self.history.push(command.clone());
self.history_index = self.history.len() - 1;
self.history_index = self.history.len();
self.messages.clear();
self.input.clear();
self.reset_cursor();
Expand Down Expand Up @@ -268,17 +268,13 @@ impl BlastTab for ConfigureTab {
}
}
KeyCode::Up => {
self.messages.push(self.history_index.to_string());
match self.current_section {
ConfigureSection::Command => {
if self.history_index == self.history.len() {
if self.history_index != 0 {
self.history_index -= 1;
}
self.input = self.history.get(self.history_index).unwrap_or(&String::from("")).to_string();
self.character_index = self.input.len();
if self.history_index != 0 {
self.history_index -= 1;
}
}
ConfigureSection::Events => {
self.events.previous();
Expand All @@ -292,13 +288,12 @@ impl BlastTab for ConfigureTab {
}
}
KeyCode::Down => {
self.messages.push(self.history_index.to_string());
match self.current_section {
ConfigureSection::Command => {
if self.history_index <= self.history.len() - 1 {
self.history_index += 1;
self.input = self.history.get(self.history_index).unwrap_or(&String::from("")).to_string();
self.character_index = self.input.len();
self.history_index += 1;
}
}
ConfigureSection::Events => {
Expand Down

0 comments on commit f993b67

Please sign in to comment.