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 @@
{#each tabs as tab, i (tab.id)} - + {/each}
{/if} diff --git a/src/lib/components/Tab.svelte b/src/lib/components/Tab.svelte index dc0b0da..a83020d 100644 --- a/src/lib/components/Tab.svelte +++ b/src/lib/components/Tab.svelte @@ -3,7 +3,6 @@ import { removeTab, selectTab } from "$lib/utils"; import { slide } from "svelte/transition"; import Close from "$lib/icons/Close.svelte"; - import Button from "./Button.svelte"; export let active = false; export let tab: StateTab; @@ -16,12 +15,20 @@
(hovered = true)} on:mouseleave={() => (hovered = false)} role="tab" tabindex={id} > + {#if hovered} + + {/if} + - - {#if hovered} - - {/if}
diff --git a/src/lib/components/TopBar.svelte b/src/lib/components/TopBar.svelte index 0628366..ce54797 100644 --- a/src/lib/components/TopBar.svelte +++ b/src/lib/components/TopBar.svelte @@ -20,6 +20,7 @@ topBarInput.subscribe((val) => { input = val; + currentInput = val; }); let iEl: HTMLInputElement;