Skip to content

Commit ef84b2b

Browse files
Merge pull request #2332 from VictoriousRaptor/fix-exclude-path-check
Fix exclude path check for index search
2 parents acfdb09 + 992f6d1 commit ef84b2b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public static string ReturnPreviousDirectoryIfIncompleteString(string path)
263263
}
264264

265265
/// <summary>
266-
/// Returns if <paramref name="parentPath"/> contains <paramref name="subPath"/>.
266+
/// Returns if <paramref name="parentPath"/> contains <paramref name="subPath"/>. Equal paths are not considered to be contained by default.
267267
/// From https://stackoverflow.com/a/66877016
268268
/// </summary>
269269
/// <param name="parentPath">Parent path</param>

Flow.Launcher.Test/FilesFoldersTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Plugin.SharedCommands;
1+
using Flow.Launcher.Plugin.SharedCommands;
22
using NUnit.Framework;
33

44
namespace Flow.Launcher.Test
@@ -33,21 +33,21 @@ public class FilesFoldersTest
3333
[TestCase(@"c:\foo", @"c:\foo\..\bar\baz", false)]
3434
[TestCase(@"c:\bar", @"c:\foo\..\bar\baz", true)]
3535
[TestCase(@"c:\barr", @"c:\foo\..\bar\baz", false)]
36-
// Equality
37-
[TestCase(@"c:\foo", @"c:\foo", false)]
38-
[TestCase(@"c:\foo\", @"c:\foo", false)]
39-
[TestCase(@"c:\foo", @"c:\foo\", false)]
4036
public void GivenTwoPaths_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult)
4137
{
4238
Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path));
4339
}
4440

41+
// Equality
42+
[TestCase(@"c:\foo", @"c:\foo", false)]
43+
[TestCase(@"c:\foo\", @"c:\foo", false)]
44+
[TestCase(@"c:\foo", @"c:\foo\", false)]
4545
[TestCase(@"c:\foo", @"c:\foo", true)]
4646
[TestCase(@"c:\foo\", @"c:\foo", true)]
4747
[TestCase(@"c:\foo", @"c:\foo\", true)]
48-
public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeTrue(string parentPath, string path, bool expectedResult)
48+
public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult)
4949
{
50-
Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, true));
50+
Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, allowEqual: expectedResult));
5151
}
5252
}
5353
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
123123
}
124124

125125
results.RemoveWhere(r => Settings.IndexSearchExcludedSubdirectoryPaths.Any(
126-
excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle)));
126+
excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle, allowEqual: true)));
127127

128128
return results.ToList();
129129
}

0 commit comments

Comments
 (0)