diff --git a/src-tauri/src/types.rs b/src-tauri/src/types.rs index c52764a..f02fe8a 100644 --- a/src-tauri/src/types.rs +++ b/src-tauri/src/types.rs @@ -91,19 +91,24 @@ impl VigiState { self.write_id_counter()?; write_tabs(&self.local_tabs_path, &self.tabs)?; + + self.current_tab_index = self.tabs.len() - 1; + self.write_current_tab_index()?; + Ok(()) } pub fn remove_tab(&mut self, index: usize) -> Result<(), VigiError> { - if self.tabs.len() == 1 { - self.current_tab_index = 0; - } else { - self.current_tab_index = self.current_tab_index + 1; + if self.tabs.len() - 1 == index && self.current_tab_index == index { + if self.current_tab_index > 0 { + self.current_tab_index -= 1; + + self.write_current_tab_index()?; + } } self.tabs.remove(index); write_tabs(&self.local_tabs_path, &self.tabs)?; - self.write_current_tab_index()?; Ok(()) } diff --git a/src/app.css b/src/app.css index 9b85c1c..169d6b0 100644 --- a/src/app.css +++ b/src/app.css @@ -97,7 +97,7 @@ input::placeholder { @apply hover:px-4; - @apply flex items-center justify-between gap-2 w-full; + @apply flex items-center justify-between gap-2 w-full truncate; } .close-button { @@ -121,10 +121,6 @@ input::placeholder { @apply hover:bg-vigi-45; } -.tab-title { - @apply truncate; -} - ::selection { @apply bg-vigi-60; } diff --git a/src/lib/components/Sidebar.svelte b/src/lib/components/Sidebar.svelte index 6d66a36..03194c3 100644 --- a/src/lib/components/Sidebar.svelte +++ b/src/lib/components/Sidebar.svelte @@ -16,7 +16,7 @@ let currentTabIndex = 0; state.subscribe(async (state) => { - tabs = state.tabs; + tabs = state.tabs.toReversed(); currentTabIndex = state.current_tab_index; if (tabs.length === 0) { @@ -38,7 +38,11 @@