fix: close tab context item works correctly
mellbacon committed
Aug 29, 2023 at 22:14 UTC
5ccf014792bd78dec0600d6b8b0329b0a21013b6
2 files changed
+8
-9
src/config/commands.ts
+7
-8
@@ -1,6 +1,7 @@
1
+import { fs } from "@tauri-apps/api";
2
import { openRenameModal } from "../App.svelte";
3
import { append, copy, cut, deleteChars, redoChange, undoChange } from "../lib/Editor.svelte";
3
-import { addEditorTab, closeActiveTab, closeAllTabs } from "../lib/EditorTabList.svelte";
4
+import { addEditorTab, closeAllTabs } from "../lib/EditorTabList.svelte";
5
import { saveFile, openFile, openFolder, openInExplorer, renameFile } from "../lib/File";
6
import { appWindow } from "@tauri-apps/api/window";
7
@@ -178,9 +179,7 @@ export const commands = {
179
},
180
"closeTab": {
181
"keybind": "Control+F4",
181
- "command": () => {
182
- closeActiveTab();
183
- }
182
+ "command": () => {}
183
},
184
"closeAllTabs": {
185
"keybind": "",
@@ -190,8 +189,8 @@ export const commands = {
189
},
190
"renameFile": {
191
"keybind": "F2",
193
- "command": (filename, oldpath) => {
194
- if (!oldpath || oldpath === "") return;
192
+ "command": async (filename, oldpath) => {
193
+ if (!await fs.exists(oldpath)) return;
194
openRenameModal(`Rename ${filename}`,
195
`Give a new name to ${filename}`, [
196
{name: "Rename", action: async () => {await renameFile(filename, oldpath)}},
@@ -201,8 +200,8 @@ export const commands = {
200
},
201
"openInExplorer": {
202
"keybind": "",
204
- "command": (path) => {
205
- if (!path || path === "") return;
203
+ "command": async (path) => {
204
+ if (!await fs.exists(path)) return;
205
openInExplorer(path);
206
}
207
}
src/lib/Tab/Tab.svelte
+1
-1
@@ -21,7 +21,7 @@
21
22
let contextmenu = false;
23
let contextmenuitems = [
24
- {name: "Close Tab", shortcut: commands.closeTab.keybind, action: commands.closeTab.command},
24
+ {name: "Close Tab", shortcut: commands.closeTab.keybind, action: () => {handleClose(id)}},
25
{name: "Close All Tabs", shortcut: "", action: commands.closeAllTabs.command},
26
{name: "Open In Explorer", shortcut: commands.openInExplorer.keybind, action: () => {commands.openInExplorer.command(path)}},
27
{name: "Rename File", shortcut: commands.renameFile.keybind, action: () => {commands.renameFile.command(label, path)}},