mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
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:
1 parent
8ea62f4b23
commit
f7ef7a2080
2 files changed
+7
-36
No files matched your search
@@ -2,11 +2,10 @@ import { useState, useEffect, useCallback } from 'react';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
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 { createGitignoreFilter, normalizePathForGitignore } from '@/lib/gitignore';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
interface FileTreeProps {
|
||||
projectId: string;
|
||||
@@ -31,7 +30,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
shouldShow: (path: string) => boolean;
|
||||
} | null>(null);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [searchInContent, setSearchInContent] = useState(false);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
const { fs } = useFS();
|
||||
const projectsManager = useProjectsManager();
|
||||
@@ -184,18 +182,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
|
||||
if (fileNameMatch) {
|
||||
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) {
|
||||
const childResults = await searchInFiles(node.children, term);
|
||||
@@ -210,10 +196,9 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}, [projectsManager, projectId, searchInContent]);
|
||||
return results }, []);
|
||||
|
||||
// Perform search when search term or searchInContent changes
|
||||
// Perform search when search term changes
|
||||
useEffect(() => {
|
||||
const performSearch = async () => {
|
||||
if (!searchTerm.trim()) {
|
||||
@@ -234,7 +219,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
};
|
||||
|
||||
performSearch();
|
||||
}, [searchTerm, searchInContent, tree, searchInFiles]);
|
||||
}, [searchTerm, tree, searchInFiles]);
|
||||
|
||||
const renderNode = (node: FileNode, depth: number = 0) => {
|
||||
const isSelected = selectedFile === node.path;
|
||||
@@ -307,7 +292,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
return (
|
||||
<div className="p-2">
|
||||
{/* Search Section */}
|
||||
<div className="mb-3 space-y-2">
|
||||
<div className="mb-3">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
|
||||
<Input
|
||||
@@ -317,20 +302,6 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
className="pl-8"
|
||||
/>
|
||||
</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>
|
||||
|
||||
{/* File Tree */}
|
||||
|
||||
Reference in new issue
Block a user