From d64d51cc577fbe536952a9e19492580e2637010f Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 24 Aug 2020 08:21:16 +1000 Subject: [PATCH 1/6] fix localized path when using Explorer plugin --- Flow.Launcher.Test/Plugins/ExplorerTest.cs | 10 +++++----- .../Search/WindowsIndex/IndexSearch.cs | 8 +++++--- .../Search/WindowsIndex/QueryConstructor.cs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher.Test/Plugins/ExplorerTest.cs b/Flow.Launcher.Test/Plugins/ExplorerTest.cs index 0298a4d998b..c9114482599 100644 --- a/Flow.Launcher.Test/Plugins/ExplorerTest.cs +++ b/Flow.Launcher.Test/Plugins/ExplorerTest.cs @@ -58,8 +58,8 @@ public void GivenWindowsIndexSearch_WhenProvidedFolderPath_ThenQueryWhereRestric $"Actual: {result}{Environment.NewLine}"); } - [TestCase("C:\\", "SELECT TOP 100 System.FileName, System.ItemPathDisplay, System.ItemType FROM SystemIndex WHERE directory='file:C:\\'")] - [TestCase("C:\\SomeFolder\\", "SELECT TOP 100 System.FileName, System.ItemPathDisplay, System.ItemType FROM SystemIndex WHERE directory='file:C:\\SomeFolder\\'")] + [TestCase("C:\\", "SELECT TOP 100 System.FileName, System.ItemUrl, System.ItemType FROM SystemIndex WHERE directory='file:C:\\'")] + [TestCase("C:\\SomeFolder\\", "SELECT TOP 100 System.FileName, System.ItemUrl, System.ItemType FROM SystemIndex WHERE directory='file:C:\\SomeFolder\\'")] public void GivenWindowsIndexSearch_WhenSearchTypeIsTopLevelDirectorySearch_ThenQueryShouldUseExpectedString(string folderPath, string expectedString) { // Given @@ -74,7 +74,7 @@ public void GivenWindowsIndexSearch_WhenSearchTypeIsTopLevelDirectorySearch_Then $"Actual string was: {queryString}{Environment.NewLine}"); } - [TestCase("C:\\SomeFolder\\flow.launcher.sln", "SELECT TOP 100 System.FileName, System.ItemPathDisplay, System.ItemType " + + [TestCase("C:\\SomeFolder\\flow.launcher.sln", "SELECT TOP 100 System.FileName, System.ItemUrl, System.ItemType " + "FROM SystemIndex WHERE (System.FileName LIKE 'flow.launcher.sln%' " + "OR CONTAINS(System.FileName,'\"flow.launcher.sln*\"',1033))" + " AND directory='file:C:\\SomeFolder'")] @@ -126,7 +126,7 @@ public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryWhereR $"Actual string was: {resultString}{Environment.NewLine}"); } - [TestCase("flow.launcher.sln", "SELECT TOP 100 \"System.FileName\", \"System.ItemPathDisplay\", \"System.ItemType\" " + + [TestCase("flow.launcher.sln", "SELECT TOP 100 \"System.FileName\", \"System.ItemUrl\", \"System.ItemType\" " + "FROM \"SystemIndex\" WHERE (System.FileName LIKE 'flow.launcher.sln%' " + "OR CONTAINS(System.FileName,'\"flow.launcher.sln*\"',1033)) AND scope='file:'")] public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShouldUseExpectedString( @@ -200,7 +200,7 @@ public void GivenWindowsIndexSearch_WhenQueryWhereRestrictionsIsForFileContentSe $"Actual string was: {resultString}{Environment.NewLine}"); } - [TestCase("some words", "SELECT TOP 100 System.FileName, System.ItemPathDisplay, System.ItemType " + + [TestCase("some words", "SELECT TOP 100 System.FileName, System.ItemUrl, System.ItemType " + "FROM SystemIndex WHERE FREETEXT('some words') AND scope='file:'")] public void GivenWindowsIndexSearch_WhenSearchForFileContent_ThenQueryShouldUseExpectedString( string userSearchString, string expectedString) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index c1793b42bf9..08511091e0e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -51,17 +51,19 @@ internal List ExecuteWindowsIndexSearch(string indexQueryString, string { if (dataReaderResults.GetValue(0) != DBNull.Value && dataReaderResults.GetValue(1) != DBNull.Value) { + var path = new Uri(dataReaderResults.GetString(1)).LocalPath; + if (dataReaderResults.GetString(2) == "Directory") { folderResults.Add(resultManager.CreateFolderResult( dataReaderResults.GetString(0), - dataReaderResults.GetString(1), - dataReaderResults.GetString(1), + path, + path, query, true, true)); } else { - fileResults.Add(resultManager.CreateFileResult(dataReaderResults.GetString(1), query, true, true)); + fileResults.Add(resultManager.CreateFileResult(path, query, true, true)); } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs index 393c1514dd5..5718fdb0a9c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/QueryConstructor.cs @@ -21,7 +21,7 @@ public CSearchQueryHelper CreateBaseQuery() baseQuery.QueryMaxResults = settings.MaxResult; // Set list of columns we want to display, getting the path presently - baseQuery.QuerySelectColumns = "System.FileName, System.ItemPathDisplay, System.ItemType"; + baseQuery.QuerySelectColumns = "System.FileName, System.ItemUrl, System.ItemType"; // Filter based on file name baseQuery.QueryContentProperties = "System.FileName"; From 027fa214d6b7e38c0c75aa54f9a1d43de55c47cc Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 24 Aug 2020 08:48:54 +1000 Subject: [PATCH 2/6] version bump Explorer plugin --- Plugins/Flow.Launcher.Plugin.Explorer/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 4f5a12496f5..6e4074c4021 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -7,7 +7,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.2.0", + "Version": "1.2.1", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", From ac3ef9dbc76a98fd4f0b05b2a392ad9781d357e2 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Tue, 25 Aug 2020 00:20:39 +0300 Subject: [PATCH 3/6] plugin/explorer: ensure env var paths are absolute --- .../Search/EnvironmentVariables.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs index c576d6ee845..e4287a5befc 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs @@ -22,11 +22,18 @@ internal static Dictionary LoadEnvironmentStringPaths() foreach (DictionaryEntry special in Environment.GetEnvironmentVariables()) { - if (Directory.Exists(special.Value.ToString())) + var path = special.Value.ToString(); + if (Directory.Exists(path)) { + // we add a trailing slash to the path to make sure drive paths become valid absolute paths. + // for example, if %systemdrive% is C: we turn it to C:\ + path = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; + // if we don't have an absolute path, we use Path.GetFullPath to get one. + // for example, if %homepath% is \Users\John we turn it to C:\Users\John + path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path); // 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()); + envStringPaths.Add(special.Key.ToString().ToLower(), path); } } From e3df795a2655611cd81152a64f6e1be35a1af428 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 14:57:38 +1000 Subject: [PATCH 4/6] version bump Explorer --- Plugins/Flow.Launcher.Plugin.Explorer/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 6e4074c4021..67d2e731c43 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -7,7 +7,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.2.1", + "Version": "1.2.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", From 17f94a1bd2e7bea50aab8cd7ba5b613933cbf9e4 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 15:00:17 +1000 Subject: [PATCH 5/6] add spacing between comment and code for readability --- .../Search/EnvironmentVariables.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs index e4287a5befc..6a870f1496f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs @@ -28,9 +28,11 @@ internal static Dictionary LoadEnvironmentStringPaths() // we add a trailing slash to the path to make sure drive paths become valid absolute paths. // for example, if %systemdrive% is C: we turn it to C:\ path = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; + // if we don't have an absolute path, we use Path.GetFullPath to get one. // for example, if %homepath% is \Users\John we turn it to C:\Users\John path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path); + // 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(), path); From 012c2522cac03270355e5d544b1baa48b68770fe Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 19:12:32 +1000 Subject: [PATCH 6/6] release version bump to 1.2.1 --- SolutionAssemblyInfo.cs | 6 +++--- appveyor.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SolutionAssemblyInfo.cs b/SolutionAssemblyInfo.cs index f52cb493389..c7c8812f236 100644 --- a/SolutionAssemblyInfo.cs +++ b/SolutionAssemblyInfo.cs @@ -16,6 +16,6 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.2.0")] -[assembly: AssemblyFileVersion("1.2.0")] -[assembly: AssemblyInformationalVersion("1.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.1")] +[assembly: AssemblyFileVersion("1.2.1")] +[assembly: AssemblyInformationalVersion("1.2.1")] \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 1cea5eb8959..703f1cb0001 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: '1.2.0.{build}' +version: '1.2.1.{build}' init: - ps: |