mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix reopening last tab for splits
This commit is contained in:
parent
c1e1f3df24
commit
4eb4a44331
@ -14,6 +14,7 @@ export default class TabManager extends Component {
|
|||||||
|
|
||||||
this.activeNtxId = null;
|
this.activeNtxId = null;
|
||||||
|
|
||||||
|
// elements are arrays of note contexts for each tab (one main context + subcontexts [splits])
|
||||||
this.recentlyClosedTabs = [];
|
this.recentlyClosedTabs = [];
|
||||||
|
|
||||||
this.tabsUpdate = new SpacedUpdate(async () => {
|
this.tabsUpdate = new SpacedUpdate(async () => {
|
||||||
@ -301,12 +302,11 @@ export default class TabManager extends Component {
|
|||||||
// close dangling autocompletes after closing the tab
|
// close dangling autocompletes after closing the tab
|
||||||
$(".aa-input").autocomplete("close");
|
$(".aa-input").autocomplete("close");
|
||||||
|
|
||||||
const ntxIdsToRemove = noteContextToRemove.getSubContexts().map(nc => nc.ntxId);
|
const noteContextsToRemove = noteContextToRemove.getSubContexts();
|
||||||
|
const ntxIdsToRemove = noteContextsToRemove.map(nc => nc.ntxId);
|
||||||
|
|
||||||
await this.triggerEvent('beforeTabRemove', { ntxIds: ntxIdsToRemove });
|
await this.triggerEvent('beforeTabRemove', { ntxIds: ntxIdsToRemove });
|
||||||
|
|
||||||
this.recentlyClosedTabs.push(noteContextToRemove);
|
|
||||||
|
|
||||||
if (!noteContextToRemove.isMainContext()) {
|
if (!noteContextToRemove.isMainContext()) {
|
||||||
await this.activateNoteContext(noteContextToRemove.getMainContext().ntxId);
|
await this.activateNoteContext(noteContextToRemove.getMainContext().ntxId);
|
||||||
}
|
}
|
||||||
@ -326,6 +326,8 @@ export default class TabManager extends Component {
|
|||||||
|
|
||||||
this.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId));
|
this.children = this.children.filter(nc => !ntxIdsToRemove.includes(nc.ntxId));
|
||||||
|
|
||||||
|
this.recentlyClosedTabs.push(noteContextsToRemove);
|
||||||
|
|
||||||
this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove});
|
this.triggerEvent('noteContextRemoved', {ntxIds: ntxIdsToRemove});
|
||||||
|
|
||||||
this.tabsUpdate.scheduleUpdate();
|
this.tabsUpdate.scheduleUpdate();
|
||||||
@ -416,17 +418,23 @@ export default class TabManager extends Component {
|
|||||||
|
|
||||||
async reopenLastTabCommand() {
|
async reopenLastTabCommand() {
|
||||||
if (this.recentlyClosedTabs.length > 0) {
|
if (this.recentlyClosedTabs.length > 0) {
|
||||||
const noteContext = this.recentlyClosedTabs.pop();
|
const noteContexts = this.recentlyClosedTabs.pop();
|
||||||
|
|
||||||
this.child(noteContext);
|
for (const noteContext of noteContexts) {
|
||||||
|
this.child(noteContext);
|
||||||
await this.triggerEvent('newNoteContextCreated', {noteContext});
|
|
||||||
|
await this.triggerEvent('newNoteContextCreated', {noteContext});
|
||||||
this.activateNoteContext(noteContext.ntxId);
|
}
|
||||||
|
|
||||||
|
const noteContextToActivate = noteContexts.length === 1
|
||||||
|
? noteContexts[0]
|
||||||
|
: noteContexts.find(nc => nc.isMainContext());
|
||||||
|
|
||||||
|
this.activateNoteContext(noteContextToActivate.ntxId);
|
||||||
|
|
||||||
await this.triggerEvent('noteSwitched', {
|
await this.triggerEvent('noteSwitched', {
|
||||||
noteContext: noteContext,
|
noteContext: noteContextToActivate,
|
||||||
notePath: noteContext.notePath
|
notePath: noteContextToActivate.notePath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user