mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- Try use ReadOnlySpan<char> instead of String for applicable API - Use Customized Exception to return error result
53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using System;
|
|
using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Flow.Launcher.Plugin.Explorer.Search.IProvider;
|
|
|
|
namespace Flow.Launcher.Plugin.Explorer.Search.Everything
|
|
{
|
|
public class EverythingSearchManager : IIndexProvider, IContentIndexProvider, IPathIndexProvider
|
|
{
|
|
private Settings Settings { get; }
|
|
|
|
public EverythingSearchManager(Settings settings)
|
|
{
|
|
Settings = settings;
|
|
}
|
|
|
|
|
|
public IAsyncEnumerable<SearchResult> SearchAsync(ReadOnlySpan<char> search, CancellationToken token)
|
|
{
|
|
return EverythingApi.SearchAsync(
|
|
new EverythingSearchOption(search, Settings.SortOption),
|
|
token);
|
|
}
|
|
public IAsyncEnumerable<SearchResult> ContentSearchAsync(ReadOnlySpan<char> plainSearch,
|
|
ReadOnlySpan<char> contentSearch, CancellationToken token)
|
|
{
|
|
if (!Settings.EnableEverythingContentSearch)
|
|
{
|
|
return AsyncEnumerable.Empty<SearchResult>();
|
|
}
|
|
|
|
return EverythingApi.SearchAsync(
|
|
new EverythingSearchOption(
|
|
plainSearch,
|
|
Settings.SortOption,
|
|
true,
|
|
contentSearch),
|
|
token);
|
|
}
|
|
public IAsyncEnumerable<SearchResult> EnumerateAsync(ReadOnlySpan<char> path, ReadOnlySpan<char> search, bool recursive, CancellationToken token)
|
|
{
|
|
return EverythingApi.SearchAsync(
|
|
new EverythingSearchOption(search,
|
|
Settings.SortOption,
|
|
ParentPath: path,
|
|
IsRecursive: recursive),
|
|
token);
|
|
}
|
|
}
|
|
}
|