@setoelkahfi / svara / commits / 5ea6872

added closing saved tabs

mellobacon committed Dec 18, 2022 at 14:37 UTC 5ea6872ba496e36b51e15b803c34ea26252e7ffe
2 files changed +13 -4
src/components/Tabs/TabMenu.svelte
+5 -4
@@ -4,7 +4,7 @@
4 import CopyFile from "carbon-icons-svelte/lib/CopyFile.svelte";
5 import Cut from "carbon-icons-svelte/lib/Cut.svelte";
6 import { clipboard, path, invoke } from "@tauri-apps/api";
7 - import { closeAllTabs, closeTab, setActive } from "./scripts/Tab";
7 + import { closeAllTabs, closeSavedTabs, closeTab, setActive } from "./scripts/Tab";
8 export let id: number;
9 export let target;
10 export let filename: string;
@@ -32,7 +32,7 @@
32 }
33 setActive(id);
34 }} ></ContextMenuOption>
35 - <ContextMenuOption indented labelText="Close Saved Tabs" on:click={() => {}}>
35 + <ContextMenuOption indented labelText="Close Saved Tabs" on:click={() => {closeSavedTabs()}}>
36 <span class="contextshortcut" slot="shortcutText">Ctrl + X S</span>
37 </ContextMenuOption>
38 <ContextMenuOption indented labelText="Close All Tabs" on:click={() => {closeAllTabs()}}>
@@ -42,10 +42,11 @@
42 <ContextMenuOption on:click={() => copyToClipboard(filename)}>
43 <span slot="labelText" title={filename}>Copy File Name</span>
44 </ContextMenuOption>
45 - <ContextMenuOption on:click={() => copyToClipboard(filepath)}>
45 + <ContextMenuOption disabled={filepath === ""} on:click={() => copyToClipboard(filepath)}>
46 <span slot="labelText" title={filepath}>Copy Absolute Path</span>
47 </ContextMenuOption>
48 - <ContextMenuOption labelText="Show in Explorer" on:click={() => {
48 + <ContextMenuOption disabled={filepath === ""} labelText="Show in Explorer" on:click={() => {
49 + if (!filepath || filepath === "") return;
50 invoke("open_in_explorer",{ path:filepath})
51 }}></ContextMenuOption>
52 </ContextMenu>
src/components/Tabs/scripts/Tab.ts
+8
@@ -115,6 +115,14 @@ export function closeAllTabs() {
115 }
116 }
117
118 +export function closeSavedTabs() {
119 + for (const tab of tablist) {
120 + if (tab.saved) {
121 + closeTab(tab.id);
122 + }
123 + }
124 +}
125 +
126 function refreshTabs() {
127 if (tablist.length > 0) {
128 hidden.set(false);