From bbe581e33db0b94add9f107fb81f39748b1ba90e Mon Sep 17 00:00:00 2001 From: oxdc <29519076+oxdc@users.noreply.github.com> Date: Sat, 18 Jan 2025 12:41:33 +0800 Subject: [PATCH] patch: keep ephemeral states after moving tabs --- src/services/MoveTab.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/services/MoveTab.ts b/src/services/MoveTab.ts index 35c5191..e89de74 100644 --- a/src/services/MoveTab.ts +++ b/src/services/MoveTab.ts @@ -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) { @@ -54,6 +62,7 @@ export function moveTab( removeChild(sourceParent, sourceIndex); insertChild(targetParent, sourceLeaf, insertIndex); app.workspace.onLayoutChange(); + reapplyEphemeralState(sourceLeaf); return sourceLeaf; } @@ -69,6 +78,7 @@ export function moveTabToEnd( removeChild(sourceParent, sourceIndex); insertChild(targetParent, sourceLeaf); app.workspace.onLayoutChange(); + reapplyEphemeralState(sourceLeaf); return sourceLeaf; } @@ -88,6 +98,7 @@ export async function moveTabToNewGroup( preferredDirection ); targetLeaf.setPinned(!!sourceLeaf.getViewState().pinned); + reapplyEphemeralState(targetLeaf, sourceLeaf.getEphemeralState()); sourceLeaf.detach(); return targetLeaf; }