Skip to content

Commit

Permalink
Костыли для гарантированного переключения вкладок
Browse files Browse the repository at this point in the history
  • Loading branch information
lintest committed Jan 18, 2021
1 parent c9db58b commit 8ee60f2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/vanessa-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class VanessaTabItem {
this.domTitle.innerText = title;
this.domItem.setAttribute("title", title);
this.registerOnDidChangeContent();
setTimeout(() => this.showEditor(), 100);
setTimeout(() => this.showEditor(), 1000);
this.showEditor();
return this;
}

Expand Down Expand Up @@ -104,9 +103,14 @@ class VanessaTabItem {
}

private showEditor() {
clearTimeout(this.owner.timer);
let node = this.editor.domNode();
if (node.nextSibling)
node.parentElement.appendChild(node);
let show = () => {
if (node.nextSibling)
node.parentElement.appendChild(node);
}
setTimeout(() => show(), 100);
this.owner.timer = setTimeout(() => show(), 1000);
};

public select = () => {
Expand All @@ -118,11 +122,10 @@ class VanessaTabItem {
}
this.domNode.classList.add(className);
this.domNode.scrollIntoView();
setTimeout(() => this.showEditor(), 100);
setTimeout(() => this.showEditor(), 1000);
const index = this.owner.tabStack.indexOf(this);
if (index >= 0) this.owner.tabStack.splice(index, 1);
this.owner.tabStack.push(this);
this.showEditor();
EventsManager.fireEvent(this.editor, VanessaEditorEvent.ON_TAB_SELECT, this.getEventData());
return this.editor;
}
Expand Down Expand Up @@ -250,6 +253,7 @@ export class VanessaTabs {
public tabStack: Array<VanessaTabItem> = [];
private hiddenEditors: Array<IVanessaEditor> = [];
private checkSyntax: boolean = true;
public timer: NodeJS.Timeout;

public static createStandalone() {
if (this.standaloneInstance) return this.standaloneInstance;
Expand Down

0 comments on commit 8ee60f2

Please sign in to comment.