Skip to content

Commit

Permalink
patch: keep ephemeral states after moving tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdc committed Jan 18, 2025
1 parent 082c04f commit bbe581e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/services/MoveTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import {
import { Identifier } from "src/models/VTWorkspace";
import { VIEW_TYPE } from "src/navigation";

export function reapplyEphemeralState(
leaf: WorkspaceLeaf,
state: unknown = null
) {
const ephemeralState = state ?? leaf.getEphemeralState();
leaf.setEphemeralState(ephemeralState);
}

function removeChild(parent: WorkspaceParent, index: number) {
parent.children.splice(index, 1);
if (parent.children.length === 0) {
Expand Down Expand Up @@ -54,6 +62,7 @@ export function moveTab(
removeChild(sourceParent, sourceIndex);
insertChild(targetParent, sourceLeaf, insertIndex);
app.workspace.onLayoutChange();
reapplyEphemeralState(sourceLeaf);
return sourceLeaf;
}

Expand All @@ -69,6 +78,7 @@ export function moveTabToEnd(
removeChild(sourceParent, sourceIndex);
insertChild(targetParent, sourceLeaf);
app.workspace.onLayoutChange();
reapplyEphemeralState(sourceLeaf);
return sourceLeaf;
}

Expand All @@ -88,6 +98,7 @@ export async function moveTabToNewGroup(
preferredDirection
);
targetLeaf.setPinned(!!sourceLeaf.getViewState().pinned);
reapplyEphemeralState(targetLeaf, sourceLeaf.getEphemeralState());
sourceLeaf.detach();
return targetLeaf;
}
Expand Down

0 comments on commit bbe581e

Please sign in to comment.