diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs index c70796a6d..c4533c019 100644 --- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs +++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs @@ -44,6 +44,12 @@ namespace Flow.Launcher.Converters return string.Empty; // When user typed lower case and result title is uppercase, we still want to display suggestion + + string _suggestion = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length); + if (String.IsNullOrEmpty(selectedResult.SuggestionText)) + { + selectedItem.Result.SuggestionText = _suggestion; + } return queryText + selectedResultPossibleSuggestion.Substring(queryText.Length); } catch (Exception e) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 2675dd882..3d383d7d8 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -41,6 +41,13 @@ + + + { + var results = SelectedResults; + + var result = results.SelectedItem?.Result; + if (result != null) // SelectedItem returns null if selection is empty. + { + string _newText = String.IsNullOrEmpty(result.SuggestionText) ? result.Title : result.SuggestionText; + + var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers(); + if (SpecialKeyState.ShiftPressed) + { + _newText = result.SubTitle; + } + ChangeQueryText(_newText); + } + }); + LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) @@ -315,24 +333,7 @@ namespace Flow.Launcher.ViewModel } QueryTextCursorMovedToEnd = true; } - public void InsertSuggestion(string suggestion) - { - var results = SelectedResults; - var result = results.SelectedItem?.Result; - if (result != null) // SelectedItem returns null if selection is empty. - { - suggestion = String.IsNullOrEmpty(suggestion) ? result.Title : suggestion; - string _newText = String.IsNullOrEmpty(result.SuggestionText) ? suggestion : result.SuggestionText; - - var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers(); - if (SpecialKeyState.ShiftPressed) - { - _newText = result.SubTitle; - } - ChangeQueryText(_newText); - } - } public bool LastQuerySelected { get; set; } // This is not a reliable indicator of the cursor's position, it is manually set for a specific purpose. @@ -399,7 +400,7 @@ namespace Flow.Launcher.ViewModel public ICommand OpenSettingCommand { get; set; } public ICommand ReloadPluginDataCommand { get; set; } public ICommand ClearQueryCommand { get; private set; } - public ICommand ReplaceQueryWithResult { get; set; } + public ICommand InsertSuggestion { get; set; } public string OpenResultCommandModifiers { get; private set; }