@setoelkahfi / svara / commits / ff252a0

prevented opening of the same file. it just navigates to it instead

mellobacon committed Sep 30, 2022 at 15:04 UTC ff252a0ae47156c51850cc175bc2d262f76784ba
1 file changed +5 -1
src/components/Content/Editor/Tabs.ts
+5 -1
@@ -36,7 +36,11 @@ class Tab {
36 let id = 0;
37 let activeid;
38 let tablist: Tab[] = [];
39 -export async function addTab(f) {
39 +export async function addTab(f: string) {
40 + if (tablist.find(file => file.path === f)) {
41 + setActive(tablist.find(file => file.path === f).id);
42 + return;
43 + }
44 let file = await loadFile(f);
45 let editor = new CodeMirrorEditor({ target: document.getElementById("tabview"), props: { content: file.content } });
46 let tab = new Tab(id, file.filename, file.path, editor, file.content);