From 6dedb4fc409d3b28b17d791783cf080d7d7f9604 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 24 Jul 2022 11:39:31 +1000 Subject: [PATCH] Release 1.9.4 (#1287) * Merge pull request #1205 from Flow-Launcher/fix_cmd_command_with_blank Fix shell cmd command with quote and space * Bump NuGet.CommandLine from 5.4.0 to 5.7.2 (#1241) * Merge pull request #1098 from Flow-Launcher/ScrollToSelectedPlugin Scroll to selected item when expanded or size changed * fix RemoveOldQueryResults NullPointerException (#1204) * Merge pull request #1005 from Flow-Launcher/KillProcess Use Cancellation Token to avoid potential race tracing issue * Merge pull request #1187 from Flow-Launcher/update_python_download_mirrors Update Python download mirrors * Merge pull request #1108 from Flow-Launcher/CalculatorDecimalSeparator Respect Decimal Separator for query not just result * Merge pull request #1087 from Flow-Launcher/turnoff_replace_win_r_shell Set Shell plugin's default replace Win R hotkey to off * Merge pull request #1077 from Flow-Launcher/fix_explorer_button_visibility Fix incorrect button visibility in Explorer's expander control * Merge pull request #1076 from Flow-Launcher/fix_path_search_with_index Fix the use of index in path search * Merge pull request #1071 from medlir/fix-browser-bookmarks-plugin-exception avoid exception in ChromiumBookmarkLoader.cs * Merge pull request #1056 from Flow-Launcher/fix_context_menu_typo Fix typo for plugin title in context menu and WindowsSettings name * Merge pull request #1119 from onesounds/antialising Remove All Cleartype Rendering * Version bump * Remove Calculator plugin CopyText feature for 1.9.4 release --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs | 7 +- Flow.Launcher/Flow.Launcher.csproj | 2 +- Flow.Launcher/Languages/en.xaml | 2 +- Flow.Launcher/SettingWindow.xaml | 7 +- Flow.Launcher/SettingWindow.xaml.cs | 19 +- Flow.Launcher/Themes/Base.xaml | 197 ++++++++++-------- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- .../ChromiumBookmarkLoader.cs | 5 +- .../Flow.Launcher.Plugin.Calculator/Main.cs | 28 ++- .../Settings.cs | 7 +- .../plugin.json | 2 +- .../Languages/en.xaml | 3 + .../DirectoryInfo/DirectoryInfoSearch.cs | 18 +- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 2 +- .../ViewModels/SettingsViewModel.cs | 11 + .../Views/ExplorerSettings.xaml | 22 +- .../Views/ExplorerSettings.xaml.cs | 26 ++- Plugins/Flow.Launcher.Plugin.Shell/Main.cs | 54 +++-- .../Flow.Launcher.Plugin.Shell/Settings.cs | 2 +- .../Properties/Resources.resx | 4 +- Scripts/post_build.ps1 | 2 +- appveyor.yml | 4 +- 23 files changed, 266 insertions(+), 162 deletions(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index 60c4ec3de..be7b88a27 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -53,7 +53,7 @@ - + diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 4cfa83382..c73efd908 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -241,7 +241,7 @@ namespace Flow.Launcher.Core.Plugin protected async Task ExecuteAsync(ProcessStartInfo startInfo, CancellationToken token = default) { Process process = null; - bool disposed = false; + using var exitTokenSource = new CancellationTokenSource(); try { process = Process.Start(startInfo); @@ -251,6 +251,7 @@ namespace Flow.Launcher.Core.Plugin return Stream.Null; } + await using var source = process.StandardOutput.BaseStream; var buffer = BufferManager.GetStream(); @@ -259,7 +260,7 @@ namespace Flow.Launcher.Core.Plugin { // ReSharper disable once AccessToModifiedClosure // Manually Check whether disposed - if (!disposed && !process.HasExited) + if (!exitTokenSource.IsCancellationRequested && !process.HasExited) process.Kill(); }); @@ -302,8 +303,8 @@ namespace Flow.Launcher.Core.Plugin } finally { + exitTokenSource.Cancel(); process?.Dispose(); - disposed = true; } } diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 35a6389ca..efaaf2931 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -91,7 +91,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index ec355a0ac..4e8adfcd6 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -55,7 +55,7 @@ Shadow effect is not allowed while current theme has blur effect enabled - Plugins + Plugin Find more plugins On Off diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 214c410be..fc4cfd0ff 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -927,7 +927,9 @@ ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedItem="{Binding SelectedPlugin}" - SnapsToDevicePixels="True"> + SelectionChanged="SelectedPluginChanged" + SnapsToDevicePixels="True" + Name="Plugins"> @@ -1116,7 +1118,8 @@ Margin="0" Padding="1" VerticalAlignment="Stretch" - Content="{Binding SettingControl}" /> + Content="{Binding SettingControl}" + SizeChanged="ItemSizeChanged"/> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 15babee8b..120131830 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -13,12 +13,15 @@ using ModernWpf; using System; using System.IO; using System.Windows; +using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; +using System.Windows.Media; using System.Windows.Navigation; using Button = System.Windows.Controls.Button; using Control = System.Windows.Controls.Control; +using ListViewItem = System.Windows.Controls.ListViewItem; using MessageBox = System.Windows.MessageBox; using TextBox = System.Windows.Controls.TextBox; using ThemeManager = ModernWpf.ThemeManager; @@ -44,6 +47,7 @@ namespace Flow.Launcher } #region General + private void OnLoaded(object sender, RoutedEventArgs e) { RefreshMaximizeRestoreButton(); @@ -247,6 +251,7 @@ namespace Flow.Launcher PluginManager.API.OpenDirectory(directory); } } + #endregion #region Proxy @@ -307,7 +312,7 @@ namespace Flow.Launcher private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e) { - if(sender is Button { DataContext: UserPlugin plugin }) + if (sender is Button { DataContext: UserPlugin plugin }) { var pluginsManagerPlugin = PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"); var actionKeyword = pluginsManagerPlugin.Metadata.ActionKeywords.Count == 0 ? "" : pluginsManagerPlugin.Metadata.ActionKeywords[0]; @@ -326,7 +331,7 @@ namespace Flow.Launcher textBox.MoveFocus(tRequest); } - private void ColorSchemeSelectedIndexChanged(object sender, EventArgs e) + private void ColorSchemeSelectedIndexChanged(object sender, EventArgs e) => ThemeManager.Current.ApplicationTheme = settings.ColorScheme switch { Constant.Light => ApplicationTheme.Light, @@ -370,5 +375,13 @@ namespace Flow.Launcher RefreshMaximizeRestoreButton(); } + private void SelectedPluginChanged(object sender, SelectionChangedEventArgs e) + { + Plugins.ScrollIntoView(Plugins.SelectedItem); + } + private void ItemSizeChanged(object sender, SizeChangedEventArgs e) + { + Plugins.ScrollIntoView(Plugins.SelectedItem); + } } -} +} \ No newline at end of file diff --git a/Flow.Launcher/Themes/Base.xaml b/Flow.Launcher/Themes/Base.xaml index 454904f3a..087606d04 100644 --- a/Flow.Launcher/Themes/Base.xaml +++ b/Flow.Launcher/Themes/Base.xaml @@ -1,15 +1,16 @@ - + - + - - - + - - + + - - - - + @@ -152,7 +158,7 @@ - + @@ -160,44 +166,50 @@ - - + + - - + + - + - + @@ -249,12 +263,12 @@ - - + + - - - \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 437464c2b..08a95bdfb 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -625,7 +625,7 @@ namespace Flow.Launcher.ViewModel private void RemoveOldQueryResults(Query query) { - if (_lastQuery.ActionKeyword != query.ActionKeyword) + if (_lastQuery?.ActionKeyword != query?.ActionKeyword) { Results.Clear(); } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs index d7b412392..735530520 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs @@ -37,7 +37,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark return new(); foreach (var folder in rootElement.EnumerateObject()) { - EnumerateFolderBookmark(folder.Value, bookmarks, source); + if (folder.Value.ValueKind == JsonValueKind.Object) + EnumerateFolderBookmark(folder.Value, bookmarks, source); } return bookmarks; } @@ -64,4 +65,4 @@ namespace Flow.Launcher.Plugin.BrowserBookmark } } -} \ No newline at end of file +} diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs index 7de4d30fe..3198222aa 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs @@ -6,7 +6,6 @@ using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using Mages.Core; -using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Plugin.Caculator.ViewModels; using Flow.Launcher.Plugin.Caculator.Views; @@ -25,6 +24,9 @@ namespace Flow.Launcher.Plugin.Caculator @")+$", RegexOptions.Compiled); private static readonly Regex RegBrackets = new Regex(@"[\(\)\[\]]", RegexOptions.Compiled); private static Engine MagesEngine; + private const string comma = ","; + private const string dot = "."; + private PluginInitContext Context { get; set; } private static Settings _settings; @@ -35,7 +37,7 @@ namespace Flow.Launcher.Plugin.Caculator Context = context; _settings = context.API.LoadSettingJsonStorage(); _viewModel = new SettingsViewModel(_settings); - + MagesEngine = new Engine(new Configuration { Scope = new Dictionary @@ -54,7 +56,19 @@ namespace Flow.Launcher.Plugin.Caculator try { - var expression = query.Search.Replace(",", "."); + string expression; + + switch (_settings.DecimalSeparator) + { + case DecimalSeparator.Comma: + case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",": + expression = query.Search.Replace(",", "."); + break; + default: + expression = query.Search; + break; + } + var result = MagesEngine.Interpret(expression); if (result?.ToString() == "NaN") @@ -119,6 +133,10 @@ namespace Flow.Launcher.Plugin.Caculator return false; } + if ((query.Search.Contains(dot) && GetDecimalSeparator() != dot) || + (query.Search.Contains(comma) && GetDecimalSeparator() != comma)) + return false; + return true; } @@ -142,8 +160,8 @@ namespace Flow.Launcher.Plugin.Caculator switch (_settings.DecimalSeparator) { case DecimalSeparator.UseSystemLocale: return systemDecimalSeperator; - case DecimalSeparator.Dot: return "."; - case DecimalSeparator.Comma: return ","; + case DecimalSeparator.Dot: return dot; + case DecimalSeparator.Comma: return comma; default: return systemDecimalSeperator; } } diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs index 10cee364b..615514873 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Calculator/Settings.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace Flow.Launcher.Plugin.Caculator { public class Settings diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json index 0b0921868..771babb90 100644 --- a/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Calculator/plugin.json @@ -4,7 +4,7 @@ "Name": "Calculator", "Description": "Provide mathematical calculations.(Try 5*3-2 in Flow Launcher)", "Author": "cxfksword", - "Version": "1.1.9", + "Version": "1.1.10", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Caculator.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index e23bd77bd..e703d8545 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -15,6 +15,7 @@ To fix this, start the Windows Search service. Select here to remove this warning The warning message has been switched off. As an alternative for searching files and folders, would you like to install Everything plugin?{0}{0}Select 'Yes' to install Everything plugin, or 'No' to return Explorer Alternative + Error occurred during search: {0} Delete @@ -23,6 +24,8 @@ Customise Action Keywords Quick Access Links Index Search Excluded Paths + Use Index Search For Path Search + Turning this on will return indexed directories/files faster, but if a directory/file is not indexed it will not show up. If a directory/file has been added to Index Search Excluded Path then it will still show up even if this option is on Indexing Options Search: Path Search: diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index 14c90d57f..93b68675f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; using System; using System.Collections.Generic; @@ -58,8 +58,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo { var directoryInfo = new System.IO.DirectoryInfo(path); - foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption) - ) + foreach (var fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(searchCriteria, enumerationOption)) { if (fileSystemInfo is System.IO.DirectoryInfo) { @@ -76,8 +75,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo } catch (Exception e) { - Log.Exception("Flow.Plugin.Explorer.", nameof(DirectoryInfoSearch), e); - results.Add(new Result {Title = e.Message, Score = 501}); + Log.Exception(nameof(DirectoryInfoSearch), "Error occured while searching path", e); + + results.Add( + new Result + { + Title = string.Format(SearchManager.Context.API.GetTranslation( + "plugin_explorer_directoryinfosearch_error"), + e.Message), + Score = 501, + IcoPath = Constants.ExplorerIconImagePath + }); return results; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 351091dfe..90b85d187 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -14,7 +14,7 @@ namespace Flow.Launcher.Plugin.Explorer // as at v1.7.0 this is to maintain backwards compatibility, need to be removed afterwards. public List QuickFolderAccessLinks { get; set; } = new List(); - public bool UseWindowsIndexForDirectorySearch { get; set; } = true; + public bool UseWindowsIndexForDirectorySearch { get; set; } = false; public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 77ec5457b..9167691b4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -52,5 +52,16 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign; + + public bool UseWindowsIndexForDirectorySearch { + get + { + return Settings.UseWindowsIndexForDirectorySearch; + } + set + { + Settings.UseWindowsIndexForDirectorySearch = value; + } + } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index bbaacc18c..0be68e257 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -4,7 +4,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels" xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views" d:DesignHeight="450" d:DesignWidth="800" @@ -89,14 +88,23 @@ - + + + + diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index 6f0bc49ee..1592314b0 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -29,6 +29,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views this.viewModel = viewModel; + DataContext = viewModel; + lbxAccessLinks.ItemsSource = this.viewModel.Settings.QuickAccessLinks; lbxExcludedPaths.ItemsSource = this.viewModel.Settings.IndexSearchExcludedSubdirectoryPaths; @@ -60,9 +62,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending)); - btnDelete.Visibility = Visibility.Hidden; - btnEdit.Visibility = Visibility.Hidden; - btnAdd.Visibility = Visibility.Hidden; + SetButtonVisibilityToHidden(); if (expAccessLinks.IsExpanded || expExcludedPaths.IsExpanded || expActionKeywords.IsExpanded) { @@ -123,8 +123,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views private void expActionKeywords_Collapsed(object sender, RoutedEventArgs e) { - if (!expActionKeywords.IsExpanded) - expActionKeywords.Height = double.NaN; + expActionKeywords.Height = double.NaN; + SetButtonVisibilityToHidden(); } private void expAccessLinks_Click(object sender, RoutedEventArgs e) @@ -143,8 +143,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views private void expAccessLinks_Collapsed(object sender, RoutedEventArgs e) { - if (!expAccessLinks.IsExpanded) - expAccessLinks.Height = double.NaN; + expAccessLinks.Height = double.NaN; + SetButtonVisibilityToHidden(); } private void expExcludedPaths_Click(object sender, RoutedEventArgs e) @@ -161,6 +161,11 @@ namespace Flow.Launcher.Plugin.Explorer.Views RefreshView(); } + private void expExcludedPaths_Collapsed(object sender, RoutedEventArgs e) + { + SetButtonVisibilityToHidden(); + } + private void btnDelete_Click(object sender, RoutedEventArgs e) { var selectedRow = lbxAccessLinks.SelectedItem as AccessLink ?? lbxExcludedPaths.SelectedItem as AccessLink; @@ -309,6 +314,13 @@ namespace Flow.Launcher.Plugin.Explorer.Views { viewModel.OpenWindowsIndexingOptions(); } + + public void SetButtonVisibilityToHidden() + { + btnDelete.Visibility = Visibility.Hidden; + btnEdit.Visibility = Visibility.Hidden; + btnAdd.Visibility = Visibility.Hidden; + } } public class ActionKeywordView diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs index bed46425d..dd8a05b0f 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Main.cs @@ -61,24 +61,26 @@ namespace Flow.Launcher.Plugin.Shell if (basedir != null) { - var autocomplete = Directory.GetFileSystemEntries(basedir). - Select(o => dir + Path.GetFileName(o)). - Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && - !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && - !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); + var autocomplete = + Directory.GetFileSystemEntries(basedir) + .Select(o => dir + Path.GetFileName(o)) + .Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && + !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && + !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); + autocomplete.Sort(); + results.AddRange(autocomplete.ConvertAll(m => new Result { Title = m, IcoPath = Image, Action = c => { - var runAsAdministrator = ( + var runAsAdministrator = c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed && !c.SpecialKeyState.AltPressed && - !c.SpecialKeyState.WinPressed - ); + !c.SpecialKeyState.WinPressed; Execute(Process.Start, PrepareProcessStartInfo(m, runAsAdministrator)); return true; @@ -113,12 +115,11 @@ namespace Flow.Launcher.Plugin.Shell IcoPath = Image, Action = c => { - var runAsAdministrator = ( + var runAsAdministrator = c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed && !c.SpecialKeyState.AltPressed && - !c.SpecialKeyState.WinPressed - ); + !c.SpecialKeyState.WinPressed; Execute(Process.Start, PrepareProcessStartInfo(m.Key, runAsAdministrator)); return true; @@ -143,12 +144,11 @@ namespace Flow.Launcher.Plugin.Shell IcoPath = Image, Action = c => { - var runAsAdministrator = ( + var runAsAdministrator = c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed && !c.SpecialKeyState.AltPressed && - !c.SpecialKeyState.WinPressed - ); + !c.SpecialKeyState.WinPressed; Execute(Process.Start, PrepareProcessStartInfo(cmd, runAsAdministrator)); return true; @@ -168,12 +168,11 @@ namespace Flow.Launcher.Plugin.Shell IcoPath = Image, Action = c => { - var runAsAdministrator = ( + var runAsAdministrator = c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed && !c.SpecialKeyState.AltPressed && - !c.SpecialKeyState.WinPressed - ); + !c.SpecialKeyState.WinPressed; Execute(Process.Start, PrepareProcessStartInfo(m.Key, runAsAdministrator)); return true; @@ -203,8 +202,21 @@ namespace Flow.Launcher.Plugin.Shell case Shell.Cmd: { info.FileName = "cmd.exe"; - info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c"); - info.ArgumentList.Add(command); + info.Arguments = $"{(_settings.LeaveShellOpen ? "/k" : "/c")} {command}"; + + //// Use info.Arguments instead of info.ArgumentList to enable users better control over the arguments they are writing. + //// Previous code using ArgumentList, commands needed to be seperated correctly: + //// Incorrect: + // info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c"); + // info.ArgumentList.Add(command); //<== info.ArgumentList.Add("mkdir \"c:\\test new\""); + + //// Correct version should be: + //info.ArgumentList.Add(_settings.LeaveShellOpen ? "/k" : "/c"); + //info.ArgumentList.Add("mkdir"); + //info.ArgumentList.Add(@"c:\test new"); + + //https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0#remarks + break; } @@ -366,7 +378,7 @@ namespace Flow.Launcher.Plugin.Shell Title = context.API.GetTranslation("flowlauncher_plugin_cmd_run_as_different_user"), Action = c => { - Task.Run(() =>Execute(ShellCommand.RunAsDifferentUser, PrepareProcessStartInfo(selectedResult.Title))); + Task.Run(() => Execute(ShellCommand.RunAsDifferentUser, PrepareProcessStartInfo(selectedResult.Title))); return true; }, IcoPath = "Images/user.png" @@ -396,4 +408,4 @@ namespace Flow.Launcher.Plugin.Shell return resultlist; } } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs index 042fd0dd3..a3cac1cb8 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs @@ -6,7 +6,7 @@ namespace Flow.Launcher.Plugin.Shell { public Shell Shell { get; set; } = Shell.Cmd; - public bool ReplaceWinR { get; set; } = true; + public bool ReplaceWinR { get; set; } = false; public bool LeaveShellOpen { get; set; } diff --git a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.resx b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.resx index 6bb283e7b..dc6895d21 100644 --- a/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.resx +++ b/Plugins/Flow.Launcher.Plugin.WindowsSettings/Properties/Resources.resx @@ -1,4 +1,4 @@ - +