@@ -113,26 +113,28 @@ const App: React.FC = () => {
113113 } , [ editors . flushAllPendingChanges ] ) ;
114114
115115 useEffect ( ( ) => {
116- if ( ! editors . activeFileId ) {
117- return ;
118- }
119-
120116 fileTree . setActiveNode ( editors . activeFileId ) ;
121117 } , [ editors . activeFileId , fileTree . setActiveNode ] ) ;
122118
123119 useEffect ( ( ) => {
124120 if ( ! editors . activeFileId ) {
121+ fileTree . clearFileSelection ( ) ;
125122 return ;
126123 }
127124
128125 const node = fileTree . findNodeByPath ( fileTree . fileTree , editors . activeFileId ) ;
129- if ( ! node || node . isSelected ) {
126+ if ( ! node ) {
127+ fileTree . clearFileSelection ( ) ;
128+ return ;
129+ }
130+
131+ if ( node . isSelected ) {
130132 return ;
131133 }
132134
133135 fileTree . selectNode ( node . id ) ;
134136 } , [ editors . activeFileId , fileTree . fileTree ,
135- fileTree . findNodeByPath , fileTree . selectNode ] ) ;
137+ fileTree . findNodeByPath , fileTree . selectNode , fileTree . clearFileSelection ] ) ;
136138
137139 useEffect ( ( ) => {
138140 saveItem ( 'terminals' , terminals . terminals ) ;
@@ -158,6 +160,7 @@ const App: React.FC = () => {
158160 const handleSelectFile = useEvent ( ( fileId : string ) => {
159161 const paneId = resolveEditorPaneId ( ) ;
160162 if ( ! paneId ) return ;
163+ if ( editors . activeFileId === fileId ) return ;
161164 editors . setActiveFileId ( fileId , paneId ) ;
162165 } ) ;
163166
0 commit comments