Skip to content

Commit a906e56

Browse files
committed
revert: revert all file tree changes
1 parent c0536df commit a906e56

3 files changed

Lines changed: 6 additions & 21 deletions

File tree

anycode/App.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,26 @@ const App: React.FC = () => {
113113
}, [editors.flushAllPendingChanges]);
114114

115115
useEffect(() => {
116+
if (!editors.activeFileId) {
117+
return;
118+
}
119+
116120
fileTree.setActiveNode(editors.activeFileId);
117121
}, [editors.activeFileId, fileTree.setActiveNode]);
118122

119123
useEffect(() => {
120124
if (!editors.activeFileId) {
121-
fileTree.clearFileSelection();
122125
return;
123126
}
124127

125128
const node = fileTree.findNodeByPath(fileTree.fileTree, editors.activeFileId);
126-
if (!node) {
127-
fileTree.clearFileSelection();
128-
return;
129-
}
130-
131-
if (node.isSelected) {
129+
if (!node || node.isSelected) {
132130
return;
133131
}
134132

135133
fileTree.selectNode(node.id);
136134
}, [editors.activeFileId, fileTree.fileTree,
137-
fileTree.findNodeByPath, fileTree.selectNode, fileTree.clearFileSelection]);
135+
fileTree.findNodeByPath, fileTree.selectNode]);
138136

139137
useEffect(() => {
140138
saveItem('terminals', terminals.terminals);
@@ -160,7 +158,6 @@ const App: React.FC = () => {
160158
const handleSelectFile = useEvent((fileId: string) => {
161159
const paneId = resolveEditorPaneId();
162160
if (!paneId) return;
163-
if (editors.activeFileId === fileId) return;
164161
editors.setActiveFileId(fileId, paneId);
165162
});
166163

anycode/components/TreeNodeComponent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const TreeNodeComponentImpl: React.FC<TreeNodeComponentProps> = ({
5959

6060
const handleNameClick = (e: React.MouseEvent) => {
6161
e.stopPropagation();
62-
if (isSelected) return;
6362
onActivate(node.id);
6463

6564
if (node.type === 'file') {

anycode/hooks/useFileTree.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,7 @@ export const useFileTree = () => {
249249
}, []);
250250

251251
const clearFileSelection = useCallback(() => {
252-
const hasSelection = (nodes: TreeNode[]): boolean => {
253-
for (const node of nodes) {
254-
if (node.isSelected) return true;
255-
if (node.children && hasSelection(node.children)) return true;
256-
}
257-
return false;
258-
};
259-
260252
setFileTree((prevTree) => {
261-
if (!hasSelection(prevTree)) {
262-
return prevTree;
263-
}
264253
const clearSelection = (nodes: TreeNode[]): TreeNode[] => {
265254
return nodes.map((node) => {
266255
const updatedChildren = node.children ? clearSelection(node.children) : undefined;

0 commit comments

Comments
 (0)