more cleanup

This commit is contained in:
randogoth 2025-02-21 23:07:02 +02:00
parent f728cc6e66
commit 05026b3fe2
2 changed files with 0 additions and 51 deletions

View file

@ -1,21 +0,0 @@
import 'dart:io';
class SearchService {
static List<File> searchNotes(String query, List<File> notes) {
if (query.isEmpty) return notes;
final lowerQuery = query.toLowerCase();
return notes.where((note) {
final fileName = note.uri.pathSegments.last.replaceAll('.md', '').toLowerCase();
final content = note.readAsStringSync().toLowerCase();
// Fuzzy search: Match if all words in the query are found in either the title or content
return _matchesFuzzy(lowerQuery, fileName) || _matchesFuzzy(lowerQuery, content);
}).toList();
}
static bool _matchesFuzzy(String query, String text) {
final words = query.split(RegExp(r'\s+')).where((word) => word.isNotEmpty);
return words.every((word) => text.contains(word));
}
}