Fix deduplication changing current tab

Fixes #56
This commit is contained in:
Jesse Hines 2026-03-30 19:56:13 -04:00
parent 4d067e07c7
commit 445560e029
No known key found for this signature in database

View file

@ -268,7 +268,15 @@ export default class OpenTabSettingsPlugin extends Plugin {
// If the leaf is still empty, close it. This can happen if the file was de-duplicated while
// "openInNewTab" is enabled, or if you open a file "in default app" in a new tab.
if (isEmptyLeaf(this) && this.parent.children.length > 1) {
const tabGroup = this.parent;
const wasCurrentTab = tabGroup.children[tabGroup.currentTab] === this;
const lastActiveTab = tabGroup.children
.filter(l => l !== this)
.reduce((max, l) => l.activeTime > max.activeTime ? l : max);
this.detach();
if (wasCurrentTab) {
tabGroup.selectTabIndex(tabGroup.children.findIndex(c => c === lastActiveTab));
}
}
delete this.openTabSettings;