@setoelkahfi / svara / commits / cd9b03a

update tab on file rename

mellobacon committed Oct 24, 2022 at 13:49 UTC cd9b03a505605ce17089fdbadc51fcf1234873d5
2 files changed +11
src/components/Content/Editor/scripts/Tabs.ts
+7
@@ -126,6 +126,13 @@ export async function saveFile() {
126 }
127 }
128
129 +export function renameFile(label, path) {
130 + let tab = tablist.find(t => t.active);
131 + tab.label = label;
132 + tab.path = path;
133 + setActive(tab.id);
134 +}
135 +
136 export function setLanguage(language) {
137 for (let tab of tablist) {
138 if (tab.active) {
src/components/Modal/RenameModel.svelte
+4
@@ -5,6 +5,8 @@
5 import { updateTree } from "../FileTree/scripts/TreeData";
6 import langlist from "../../scripts/languages/languages.json";
7 import { sep } from "@tauri-apps/api/path";
8 + import { renameFile, setLanguage } from "../Content/Editor/scripts/Tabs";
9 + import { getLang } from "../Content/Editor/scripts/Editor";
10 export let open = false;
11 export let filename = "";
12 export let path = "/";
@@ -91,6 +93,8 @@
93 path = newpath.join(sep);
94
95 await fs.renameFile(oldpath, path);
96 + renameFile(filenameinput, path);
97 + setLanguage(extinput);
98 await updateTree();
99 open = false;
100 }}