From f491ea1e4335c6bdd8ef4802461d0b1709ffe1b4 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Thu, 14 May 2026 18:50:24 +0800 Subject: [PATCH] fix: keep saved-sql-root first after database pin/unpin (#267) orderPinnedFirst preserves relative order but doesn't account for saved-sql-root needing to stay first. After reordering pinned children, move saved-sql-root back to index 0 if it was displaced. --- src/stores/connectionStore.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts index 82618762fd..8c59cdfded 100644 --- a/src/stores/connectionStore.ts +++ b/src/stores/connectionStore.ts @@ -402,6 +402,10 @@ export const useConnectionStore = defineStore("connection", () => { const parent = findParentNode(treeNodes.value, id); if (parent?.children) { parent.children = orderPinnedFirst(parent.children, (child) => !!child.pinned); + const sqlRootIdx = parent.children.findIndex((c) => c.type === "saved-sql-root"); + if (sqlRootIdx > 0) { + parent.children.unshift(...parent.children.splice(sqlRootIdx, 1)); + } } } }