Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
internal static PluginInitContext Context { get; set; }

internal Settings Settings;
internal static Settings Settings { get; set; }

Check failure on line 20 in Plugins/Flow.Launcher.Plugin.Explorer/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

` Settings Settings ` matches a line_forbidden.patterns entry: `\s([A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})\s\g{-1}\s`. (forbidden-pattern)

private SettingsViewModel viewModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
{
internal static class QuickAccess
{
private const int quickAccessResultScore = 100;
private const int QuickAccessResultScore = 100;

internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<AccessLink> accessLinks)
{
Expand All @@ -19,8 +19,9 @@ internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<Acce
.ThenBy(x => x.Name)
.Select(l => l.Type switch
{
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, quickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
_ => throw new ArgumentOutOfRangeException()
})
.ToList();
Expand All @@ -32,8 +33,9 @@ internal static List<Result> AccessLinkListAll(Query query, IEnumerable<AccessLi
.ThenBy(x => x.Name)
.Select(l => l.Type switch
{
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore),
ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore),
ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore),
ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore),
_ => throw new ArgumentOutOfRangeException()
}).ToList();
}
Expand Down
12 changes: 11 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
}
catch (Exception ex)
{
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));

Check warning on line 140 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`opendir` is not a recognized word. (unrecognized-spelling)
return false;
}
}
Expand All @@ -152,7 +152,7 @@
}
catch (Exception ex)
{
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));

Check warning on line 155 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`opendir` is not a recognized word. (unrecognized-spelling)
return false;
}
}
Expand All @@ -171,16 +171,26 @@
};
}

internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score)
{
return CreateDriveSpaceDisplayResult(path, actionKeyword, score, SearchManager.UseIndexSearch(path));
}

internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false)
{
return CreateDriveSpaceDisplayResult(path, actionKeyword, 500, windowsIndexed);
}

private static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score, bool windowsIndexed = false)
{
var progressBarColor = "#26a0da";
var title = string.Empty; // hide title when use progress bar,
var driveLetter = path[..1].ToUpper();
DriveInfo drv = new DriveInfo(driveLetter);
var freespace = ToReadableSize(drv.AvailableFreeSpace, 2);

Check warning on line 190 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`drv` is not a recognized word. (unrecognized-spelling)
var totalspace = ToReadableSize(drv.TotalSize, 2);

Check warning on line 191 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`drv` is not a recognized word. (unrecognized-spelling)
var subtitle = string.Format(Context.API.GetTranslation("plugin_explorer_diskfreespace"), freespace, totalspace);

Check warning on line 192 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`totalspace` is not a recognized word. (unrecognized-spelling)
double usingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100;

Check warning on line 193 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`drv` is not a recognized word. (unrecognized-spelling)

Check warning on line 193 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`drv` is not a recognized word. (unrecognized-spelling)

int? progressValue = Convert.ToInt32(usingSize);

Expand All @@ -188,7 +198,7 @@
progressBarColor = "#da2626";

var tooltip = Settings.DisplayMoreInformationInToolTip
? GetVolumeMoreInfoTooltip(path, freespace, totalspace)

Check warning on line 201 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`totalspace` is not a recognized word. (unrecognized-spelling)
: path;

return new Result
Expand All @@ -197,7 +207,7 @@
SubTitle = subtitle,
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword),
IcoPath = path,
Score = 500,
Score = score,
ProgressBar = progressValue,
ProgressBarColor = progressBarColor,
Preview = new Result.PreviewInfo
Expand Down Expand Up @@ -252,7 +262,7 @@
return new Result
{
Title = Context.API.GetTranslation("plugin_explorer_openresultfolder"),
SubTitle = Context.API.GetTranslation("plugin_explorer_openresultfolder_subtitle"),

Check warning on line 265 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`openresultfolder` is not a recognized word. (unrecognized-spelling)
AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword),
IcoPath = folderPath,
Score = 500,
Expand Down Expand Up @@ -389,7 +399,7 @@
}
}

private static string GetVolumeMoreInfoTooltip(string volumePath, string freespace, string totalspace)

Check warning on line 402 in Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`totalspace` is not a recognized word. (unrecognized-spelling)
{
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_volume"),
volumePath, freespace, totalspace, Environment.NewLine);
Expand Down
12 changes: 12 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken

public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword;

public static bool UseIndexSearch(string path)
{
if (Main.Settings.IndexSearchEngine is not Settings.IndexSearchEngineOption.WindowsIndex)
return false;

// Check if the path is using windows index search
var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);

return !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any(
x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))
&& WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory);
}

private bool UseWindowsIndexForDirectorySearch(string locationPath)
{
Expand Down
Loading