From d52c4a3ca6e15b80b3ffc050f9edca0329ddf2a7 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Thu, 19 Sep 2024 08:51:32 +0530 Subject: [PATCH] Clean comments --- tui/src/running_command.rs | 7 +++---- tui/src/state.rs | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tui/src/running_command.rs b/tui/src/running_command.rs index 7d09a56fd..c605b204a 100644 --- a/tui/src/running_command.rs +++ b/tui/src/running_command.rs @@ -139,19 +139,18 @@ impl RunningCommand { pub fn new(commands: Vec) -> Self { let pty_system = NativePtySystem::default(); - // Create a command to execute all the selected commands + // Build the command based on the provided Command enum variant let mut cmd: CommandBuilder = CommandBuilder::new("sh"); cmd.arg("-c"); - // Initialize an empty string to hold the merged commands // All the merged commands are passed as a single argument to reduce the overhead of rebuilding the command arguments for each and every command let mut script = String::new(); for command in commands { match command { - Command::Raw(prompt) => script.push_str(&format!("{}\n", prompt)), // Merge raw commands + Command::Raw(prompt) => script.push_str(&format!("{}\n", prompt)), Command::LocalFile(file) => { if let Some(parent) = file.parent() { - script.push_str(&format!("cd {}\n", parent.display())); // Merge local file path + script.push_str(&format!("cd {}\n", parent.display())); } script.push_str(&format!("sh {}\n", file.display())); } diff --git a/tui/src/state.rs b/tui/src/state.rs index d18e127a4..27b61d732 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -279,7 +279,7 @@ impl AppState { match key.code { KeyCode::Tab => { if self.current_tab.selected().unwrap() == self.tabs.len() - 1 { - self.current_tab.select_first(); // Select first tab when it is at last + self.current_tab.select_first(); } else { self.current_tab.select_next(); } @@ -287,7 +287,7 @@ impl AppState { } KeyCode::BackTab => { if self.current_tab.selected().unwrap() == 0 { - self.current_tab.select(Some(self.tabs.len() - 1)); // Select last tab when it is at first + self.current_tab.select(Some(self.tabs.len() - 1)); } else { self.current_tab.select_previous(); } @@ -525,7 +525,6 @@ impl AppState { fn handle_enter(&mut self) { if self.selected_item_is_cmd() { - // If no commands are selected, run the selected by pushing them into vector if self.selected_commands.is_empty() { if let Some(cmd) = self.get_selected_command() { self.selected_commands.push(cmd);