diff --git a/client/src/state/app/buffer.rs b/client/src/state/app/buffer.rs index 753b15e..111f93c 100644 --- a/client/src/state/app/buffer.rs +++ b/client/src/state/app/buffer.rs @@ -8,7 +8,7 @@ pub enum AppView { Admin, AddTable, AddLogic, - Form, // Remove the String parameter + Form, Scratch, } @@ -23,7 +23,7 @@ impl AppView { AppView::Admin => "Admin_Panel", AppView::AddTable => "Add_Table", AppView::AddLogic => "Add_Logic", - AppView::Form => "Form", // Default fallback + AppView::Form => "Form", AppView::Scratch => "*scratch*", } } @@ -41,7 +41,6 @@ impl AppView { } } -// Rest of BufferState implementation remains the same #[derive(Debug, Clone)] pub struct BufferState { pub history: Vec, @@ -81,11 +80,8 @@ impl BufferState { } let current_index = self.active_index; - if matches!(self.history.get(current_index), Some(AppView::Intro)) { - return false; - } - self.history.remove(current_index); + if self.history.is_empty() { self.history.push(AppView::Intro); self.active_index = 0; @@ -97,8 +93,12 @@ impl BufferState { pub fn close_buffer_with_intro_fallback(&mut self, current_table_name: Option<&str>) -> String { let current_view_cloned = self.get_active_view().cloned(); + if let Some(AppView::Intro) = current_view_cloned { - return "Cannot close intro buffer".to_string(); + if self.history.len() == 1 { + self.close_active_buffer(); + return "Intro buffer reset".to_string(); + } } let closed_name = current_view_cloned @@ -108,12 +108,12 @@ impl BufferState { if self.close_active_buffer() { if self.history.len() == 1 && matches!(self.history.get(0), Some(AppView::Intro)) { - format!("Closed '{}' - returned to intro", closed_name) + format!("Closed '{}' - returned to Intro", closed_name) } else { format!("Closed '{}'", closed_name) } } else { - format!("Cannot close buffer: {}", closed_name) + format!("Buffer '{}' could not be closed", closed_name) } } }