use crate::app::window_state::WindowState;
use std::collections::HashMap;
impl WindowState {
pub(crate) fn execute_insert_text_action(
&mut self,
text: String,
variables: HashMap<String, String>,
) -> bool {
let substituted_text =
match crate::snippets::VariableSubstitutor::new().substitute(&text, &variables) {
Ok(content) => content,
Err(e) => {
log::error!("Failed to substitute variables in action: {}", e);
self.show_toast(format!("Action Error: {}", e));
return false;
}
};
if let Some(tab) = self.tab_manager.active_tab_mut() {
if let Ok(terminal) = tab.terminal.try_write() {
if let Err(e) = terminal.write(substituted_text.as_bytes()) {
log::error!("Failed to write action text to terminal: {}", e);
return false;
}
log::info!("Executed insert text action");
return true;
} else {
log::error!("Failed to lock terminal for action execution");
return false;
}
}
false
}
}