示例#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("%\\");
        internal List <Result> Search(Query query)
        {
            var results = new List <Result>();

            var querySearch = query.Search;

            var quickFolderLinks = quickFolderAccess.FolderList(query, settings.QuickFolderAccessLinks, context);

            if (quickFolderLinks.Count > 0)
            {
                return(quickFolderLinks);
            }

            if (string.IsNullOrEmpty(querySearch))
            {
                return(results);
            }

            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.Substring(1).Contains("%\\");

            if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath)
            {
                return(WindowsIndexFilesAndFoldersSearch(query, querySearch));
            }

            var locationPath = querySearch;

            if (isEnvironmentVariablePath)
            {
                locationPath = EnvironmentVariables.TranslateEnvironmentVariablePath(locationPath);
            }

            if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath)))
            {
                return(results);
            }

            var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);

            results.Add(resultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));

            results.AddRange(TopLevelDirectorySearchBehaviour(WindowsIndexTopLevelFolderSearch,
                                                              DirectoryInfoClassSearch,
                                                              useIndexSearch,
                                                              query,
                                                              locationPath));

            return(results);
        }