Skip to content

Commit

Permalink
keep the order and ephemeral state after tab deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdc committed Jan 18, 2025
1 parent cce1308 commit 15e36a7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/services/DeduplicateTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useViewState } from "src/models/ViewState";
import { getOpenFileOfLeaf } from "./GetTabs";
import { Identifier } from "src/models/VTWorkspace";
import { DefaultRecord } from "src/utils/DefaultRecord";
import { moveTab, reapplyEphemeralState } from "./MoveTab";

const EXCLUSION_LIST = new Set([
"file-explorer",
Expand Down Expand Up @@ -72,6 +73,12 @@ export function deduplicateTabForTargets(
const { backHistory, forwardHistory } = latestOldLeaf.history;
leafToKeep.history.backHistory = backHistory;
leafToKeep.history.forwardHistory = forwardHistory;
reapplyEphemeralState(leafToKeep, latestOldLeaf.getEphemeralState());
const sourceParent = latestOldLeaf.parent;
const targetParent = leafToKeep.parent;
if (sourceParent?.id === targetParent?.id) {
moveTab(app, leafToKeep.id, latestOldLeaf.id);
}
}
sortedLeaves.forEach((leaf) => leaf.detach());
loadDeferredLeaf(leafToKeep);
Expand Down

0 comments on commit 15e36a7

Please sign in to comment.