Merge pull request #89 from Flow-Launcher/fix_environmentpath_caseinsensitive

Fix environment variable search to be case insensitive
This commit is contained in:
Jeremy Wu 2020-06-29 22:36:45 +10:00 committed by GitHub
commit 718f68344a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -18,12 +18,14 @@ namespace Flow.Launcher.Plugin.Explorer.Search
internal static Dictionary<string, string> LoadEnvironmentStringPaths()
{
var envStringPaths = new Dictionary<string, string>();
var envStringPaths = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
foreach (DictionaryEntry special in Environment.GetEnvironmentVariables())
{
if (Directory.Exists(special.Value.ToString()))
{
// Variables are returned with a mixture of all upper/lower case.
// Call ToLower() to make the results look consistent
envStringPaths.Add(special.Key.ToString().ToLower(), special.Value.ToString());
}
}
@ -82,11 +84,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
foreach (var p in environmentVariables)
{
if (p.Key.StartsWith(search))
if (p.Key.StartsWith(search, StringComparison.InvariantCultureIgnoreCase))
{
results.Add(new ResultManager(context).CreateFolderResult($"%{p.Key}%", p.Value, p.Value, query));
}
}
return results;
}
}