Remove search in content functionality from File Explorer

- Removed the 'Search in content' button and its toggle functionality
- Simplified search logic to only search file names by exact string match
- Removed FileText import and Button import as they're no longer needed
- Fixed ESLint warning by removing unnecessary dependencies from useCallback
- All tests pass and build is successful

The File Explorer now only searches file names as requested by the boss.
This commit is contained in:
P. Reis committed 2025-09-18 13:31:35 -03:00
1 parent 8ea62f4b23
commit f7ef7a2080
2 files changed
+7 -36

No files matched your search

+2 -2
View File
@@ -8,12 +8,12 @@
"theme_color": "#000000", "theme_color": "#000000",
"icons": [ "icons": [
{ {
"src": "/icon-192.png", "src": "/favicon.png",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "/icon-512.png", "src": "/favicon.png",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png" "type": "image/png"
} }
+5 -34
View File
@@ -2,11 +2,10 @@ import { useState, useEffect, useCallback } from 'react';
import { useProjectsManager } from '@/hooks/useProjectsManager'; import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useFS } from '@/hooks/useFS'; import { useFS } from '@/hooks/useFS';
import { useGitStatus } from '@/hooks/useGitStatus'; import { useGitStatus } from '@/hooks/useGitStatus';
import { ChevronRight, ChevronDown, File, Folder, Search, FileText } from 'lucide-react'; import { ChevronRight, ChevronDown, File, Folder, Search } from 'lucide-react';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore'; import { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
interface FileTreeProps { interface FileTreeProps {
projectId: string; projectId: string;
@@ -31,7 +30,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
shouldShow: (path: string) => boolean; shouldShow: (path: string) => boolean;
} | null>(null); } | null>(null);
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
const [searchInContent, setSearchInContent] = useState(false);
const [isSearching, setIsSearching] = useState(false); const [isSearching, setIsSearching] = useState(false);
const { fs } = useFS(); const { fs } = useFS();
const projectsManager = useProjectsManager(); const projectsManager = useProjectsManager();
@@ -184,18 +182,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
if (fileNameMatch) { if (fileNameMatch) {
results.push(node); results.push(node);
} else if (searchInContent) {
try {
const content = await projectsManager.readFile(projectId, node.path);
const contentMatch = content.toLowerCase().includes(searchTermLower);
if (contentMatch) {
results.push(node);
}
} catch (error) {
// Skip files that can't be read
console.warn(`Could not read file ${node.path}:`, error);
}
} }
} else if (node.type === 'directory' && node.children) { } else if (node.type === 'directory' && node.children) {
const childResults = await searchInFiles(node.children, term); const childResults = await searchInFiles(node.children, term);
@@ -210,10 +196,9 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
} }
} }
return results; return results }, []);
}, [projectsManager, projectId, searchInContent]);
// Perform search when search term or searchInContent changes // Perform search when search term changes
useEffect(() => { useEffect(() => {
const performSearch = async () => { const performSearch = async () => {
if (!searchTerm.trim()) { if (!searchTerm.trim()) {
@@ -234,7 +219,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
}; };
performSearch(); performSearch();
}, [searchTerm, searchInContent, tree, searchInFiles]); }, [searchTerm, tree, searchInFiles]);
const renderNode = (node: FileNode, depth: number = 0) => { const renderNode = (node: FileNode, depth: number = 0) => {
const isSelected = selectedFile === node.path; const isSelected = selectedFile === node.path;
@@ -307,7 +292,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
return ( return (
<div className="p-2"> <div className="p-2">
{/* Search Section */} {/* Search Section */}
<div className="mb-3 space-y-2"> <div className="mb-3">
<div className="relative"> <div className="relative">
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" /> <Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
<Input <Input
@@ -317,20 +302,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
className="pl-8" className="pl-8"
/> />
</div> </div>
<div className="flex items-center gap-2">
<Button
variant={searchInContent ? "default" : "outline"}
size="sm"
onClick={() => setSearchInContent(!searchInContent)}
className="flex items-center gap-1"
>
<FileText className="h-3 w-3" />
Search in content
</Button>
{isSearching && (
<div className="text-xs text-muted-foreground">Searching...</div>
)}
</div>
</div> </div>
{/* File Tree */} {/* File Tree */}