Skip to content

Commit 82cfddb

Browse files
committed
add ordering to file and folder results
1 parent a196c4f commit 82cfddb

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private List<Result> DirectorySearch(SearchOption searchOption, Query query, str
9090
}
9191

9292
// Intial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
93-
return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList(); //<============= MOVE OUT
93+
return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList();
9494
}
9595
}
9696
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Data.OleDb;
6+
using System.Linq;
67
using System.Text.RegularExpressions;
78

89
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
@@ -29,6 +30,8 @@ internal IndexSearch(PluginInitContext context)
2930

3031
internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string connectionString, Query query)
3132
{
33+
var folderResults = new List<Result>();
34+
var fileResults = new List<Result>();
3235
var results = new List<Result>();
3336

3437
try
@@ -48,11 +51,18 @@ internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string
4851
{
4952
if (dataReaderResults.GetValue(0) != DBNull.Value && dataReaderResults.GetValue(1) != DBNull.Value)
5053
{
51-
results.Add(CreateResult(
52-
dataReaderResults.GetString(0),
53-
dataReaderResults.GetString(1),
54-
dataReaderResults.GetString(2),
55-
query));
54+
if (dataReaderResults.GetString(2) == "Directory")
55+
{
56+
folderResults.Add(resultManager.CreateFolderResult(
57+
dataReaderResults.GetString(0),
58+
Constants.DefaultFolderSubtitleString,
59+
dataReaderResults.GetString(1),
60+
query, true, true));
61+
}
62+
else
63+
{
64+
fileResults.Add(resultManager.CreateFileResult(dataReaderResults.GetString(1), query, true, true));
65+
}
5666
}
5767
}
5868
}
@@ -70,17 +80,8 @@ internal List<Result> ExecuteWindowsIndexSearch(string indexQueryString, string
7080
LogException("General error from performing index search", e);
7181
}
7282

73-
return results;
74-
}
75-
76-
private Result CreateResult(string filename, string path, string fileType, Query query)
77-
{
78-
if (fileType == "Directory")
79-
return resultManager.CreateFolderResult(filename, Constants.DefaultFolderSubtitleString, path, query, true, true);
80-
else
81-
{
82-
return resultManager.CreateFileResult(path, query, true, true);
83-
}
83+
// Intial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
84+
return results.Concat(folderResults.OrderBy(x => x.Title)).Concat(fileResults.OrderBy(x => x.Title)).ToList(); ;
8485
}
8586

8687
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery, Query query)

0 commit comments

Comments
 (0)