From 9a7a1f2b82a53834799b48123dda36d6f20416ee Mon Sep 17 00:00:00 2001 From: Rokojori Date: Fri, 17 Jul 2026 22:36:49 +0200 Subject: [PATCH] file-tree: focus existing panel if file already open; exclude pinned from available slots Co-Authored-By: Claude Sonnet 4.6 --- .../file-tree-panel/file-tree-panel.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/components/file-tree-panel/file-tree-panel.ts b/source/components/file-tree-panel/file-tree-panel.ts index 6d60e04..870c114 100644 --- a/source/components/file-tree-panel/file-tree-panel.ts +++ b/source/components/file-tree-panel/file-tree-panel.ts @@ -118,6 +118,20 @@ class FileTreePanel extends HTMLElement { if ( editorTag ) { const containers = Array.from( document.querySelectorAll( 'tab-container' ) ); + + for ( const tc of containers ) + { + const tabs = ( tc as any ).tabs as Array<{ id: string; element: HTMLElement }>; + for ( const tab of tabs ) + { + if ( ( tab.element as any ).currentPath === path ) + { + ( tc as any ).activateTab( tab.id ); + return; + } + } + } + let found: { panel: HTMLElement; tc: any; tabId: string } | null = null; for ( const tc of containers ) @@ -125,7 +139,7 @@ class FileTreePanel extends HTMLElement { const tabs = ( tc as any ).tabs as Array<{ id: string; element: HTMLElement; dirty: boolean }>; for ( const tab of tabs ) { - if ( tab.element.tagName.toLowerCase() === editorTag && !tab.dirty ) + if ( tab.element.tagName.toLowerCase() === editorTag && !tab.dirty && !( tab.element as any )._pinned ) { found = { panel: tab.element, tc, tabId: tab.id }; break;