@setoelkahfi / svara / commits / d03cfee

#9 fix UI problems

- refresh tab title after saving - use proper "untitled-<id>" for new files

Frank Schmitt committed Oct 22, 2022 at 17:47 UTC d03cfee087512a9bc21d91b540bdbb73bd981a11
1 file changed +5 -3
src/components/Content/Editor/Tabs.ts
+5 -3
@@ -31,7 +31,7 @@ class Tab {
31 console.log(`${this.label} saved`);
32 }
33 else {
34 - console.log('unnamed buffer ${this.label}, not saving');
34 + console.log(`unnamed buffer ${this.label}, not saving`);
35 }
36 }, 1000)
37 })
@@ -61,7 +61,7 @@ export async function addTab(f: string) {
61 export async function addNewFileTab() {
62 let content = "";
63 let editor = new CodeMirrorEditor({ target: document.getElementById("tabview"), props: { content: content } });
64 - let tab = new Tab(id, null, null, editor, content);
64 + let tab = new Tab(id, "", "", editor, content);
65 tablist = [...tablist, tab];
66 if (tablist.length > 0) {
67 hidden.set(false);
@@ -72,7 +72,7 @@ export async function addNewFileTab() {
72 }
73
74 export async function saveFileAs(filePath: string) {
75 - console.log('saveFileAs ${filePath}');
75 + console.log(`saveFileAs ${filePath}`);
76 for (let tab of tablist) {
77 if (tab.active) {
78 console.log("found active tab");
@@ -80,6 +80,8 @@ export async function saveFileAs(filePath: string) {
80 tab.label = filePath;
81 }
82 }
83 + // refresh tab list (to ensure we display the correct filename)
84 + tabs.set(tablist);
85 }
86
87 export function setActive(id) {