Exemple #1
0
        internal async Task <List <Result> > SearchAsync(Query query, CancellationToken token)
        {
            var results = new HashSet <Result>(PathEqualityComparator.Instance);

            var querySearch = query.Search;

            if (IsFileContentSearch(query.ActionKeyword))
            {
                return(await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false));
            }

            // This allows the user to type the assigned action keyword and only see the list of quick folder links
            if (string.IsNullOrEmpty(query.Search))
            {
                return(QuickAccess.AccessLinkListAll(query, settings.QuickAccessLinks));
            }

            var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, settings.QuickAccessLinks);

            if (quickaccessLinks.Count > 0)
            {
                results.UnionWith(quickaccessLinks);
            }

            var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch);

            if (isEnvironmentVariable)
            {
                return(EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, context));
            }

            // Query is a location path with a full environment variable, eg. %appdata%\somefolder\
            var isEnvironmentVariablePath = querySearch[1..].Contains("%\\");
Exemple #2
0
        internal async Task <List <Result> > SearchAsync(Query query, CancellationToken token)
        {
            var querySearch = query.Search;

            var results = new HashSet <Result>(PathEqualityComparator.Instance);

            // This allows the user to type the below action keywords and see/search the list of quick folder links
            if (ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword) ||
                ActionKeywordMatch(query, Settings.ActionKeyword.QuickAccessActionKeyword) ||
                ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword))
            {
                if (string.IsNullOrEmpty(query.Search))
                {
                    return(QuickAccess.AccessLinkListAll(query, Settings.QuickAccessLinks));
                }

                var quickaccessLinks = QuickAccess.AccessLinkListMatched(query, Settings.QuickAccessLinks);

                results.UnionWith(quickaccessLinks);
            }

            if (IsFileContentSearch(query.ActionKeyword))
            {
                return(await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false));
            }

            if (ActionKeywordMatch(query, Settings.ActionKeyword.PathSearchActionKeyword) ||
                ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword))
            {
                results.UnionWith(await PathSearchAsync(query, token).ConfigureAwait(false));
            }

            if ((ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) ||
                 ActionKeywordMatch(query, Settings.ActionKeyword.SearchActionKeyword)) &&
                querySearch.Length > 0 &&
                !querySearch.IsLocationPathString())
            {
                results.UnionWith(await WindowsIndexFilesAndFoldersSearchAsync(query, querySearch, token)
                                  .ConfigureAwait(false));
            }

            return(results.ToList());
        }