From 910c5f2797c19546185986237c777d3186d143df Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 9 Sep 2023 01:49:00 +0800 Subject: [PATCH 1/3] Move equality test cases --- Flow.Launcher.Test/FilesFoldersTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher.Test/FilesFoldersTest.cs b/Flow.Launcher.Test/FilesFoldersTest.cs index d16826053..75a0f67fb 100644 --- a/Flow.Launcher.Test/FilesFoldersTest.cs +++ b/Flow.Launcher.Test/FilesFoldersTest.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin.SharedCommands; +using Flow.Launcher.Plugin.SharedCommands; using NUnit.Framework; namespace Flow.Launcher.Test @@ -33,21 +33,21 @@ namespace Flow.Launcher.Test [TestCase(@"c:\foo", @"c:\foo\..\bar\baz", false)] [TestCase(@"c:\bar", @"c:\foo\..\bar\baz", true)] [TestCase(@"c:\barr", @"c:\foo\..\bar\baz", false)] - // Equality - [TestCase(@"c:\foo", @"c:\foo", false)] - [TestCase(@"c:\foo\", @"c:\foo", false)] - [TestCase(@"c:\foo", @"c:\foo\", false)] public void GivenTwoPaths_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult) { Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path)); } + // Equality + [TestCase(@"c:\foo", @"c:\foo", false)] + [TestCase(@"c:\foo\", @"c:\foo", false)] + [TestCase(@"c:\foo", @"c:\foo\", false)] [TestCase(@"c:\foo", @"c:\foo", true)] [TestCase(@"c:\foo\", @"c:\foo", true)] [TestCase(@"c:\foo", @"c:\foo\", true)] - public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeTrue(string parentPath, string path, bool expectedResult) + public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult) { - Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, true)); + Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, expectedResult)); } } } From ec58939e555c92f2d112b4027b89d063cdcbcaf0 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 9 Sep 2023 01:49:18 +0800 Subject: [PATCH 2/3] Fix exclude path check for index search --- Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs | 2 +- Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs index dd4dcc7a4..4137ca8d0 100644 --- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs +++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs @@ -263,7 +263,7 @@ namespace Flow.Launcher.Plugin.SharedCommands } /// - /// Returns if contains . + /// Returns if contains . Equal paths are not considered to be contained by default. /// From https://stackoverflow.com/a/66877016 /// /// Parent path diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index f58ac43e8..28b25b59c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -123,7 +123,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } results.RemoveWhere(r => Settings.IndexSearchExcludedSubdirectoryPaths.Any( - excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle))); + excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle, true))); return results.ToList(); } From 992f6d11dc373547cc4cf10770c3e1e1e2dd722c Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 11 Sep 2023 21:16:01 +1000 Subject: [PATCH 3/3] add allowEqual parameter name to call to make it clearer --- Flow.Launcher.Test/FilesFoldersTest.cs | 2 +- Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Test/FilesFoldersTest.cs b/Flow.Launcher.Test/FilesFoldersTest.cs index 75a0f67fb..3dead9918 100644 --- a/Flow.Launcher.Test/FilesFoldersTest.cs +++ b/Flow.Launcher.Test/FilesFoldersTest.cs @@ -47,7 +47,7 @@ namespace Flow.Launcher.Test [TestCase(@"c:\foo", @"c:\foo\", true)] public void GivenTwoPathsAreTheSame_WhenCheckPathContains_ThenShouldBeExpectedResult(string parentPath, string path, bool expectedResult) { - Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, expectedResult)); + Assert.AreEqual(expectedResult, FilesFolders.PathContains(parentPath, path, allowEqual: expectedResult)); } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 28b25b59c..5fe01d3a5 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -123,7 +123,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } results.RemoveWhere(r => Settings.IndexSearchExcludedSubdirectoryPaths.Any( - excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle, true))); + excludedPath => FilesFolders.PathContains(excludedPath.Path, r.SubTitle, allowEqual: true))); return results.ToList(); }