diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs index deb225100..45f3e7663 100644 --- a/Flow.Launcher.Plugin/Result.cs +++ b/Flow.Launcher.Plugin/Result.cs @@ -31,14 +31,7 @@ namespace Flow.Launcher.Plugin /// public string ActionKeywordAssigned { get; set; } - public string InsertText - { - get { return string.IsNullOrEmpty(_insertText) ? Title : _insertText; } - set - { - _insertText = value; - } - } + public string SuggestionText { get; set; } = string.Empty; public string IcoPath { diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 563038504..2675dd882 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -41,11 +41,6 @@ - - - { - var results = SelectedResults; - - if (index != null) - { - results.SelectedIndex = int.Parse(index.ToString()); - } - - var result = results.SelectedItem?.Result; - if (result != null) // SelectedItem returns null if selection is empty. - { - string _newText = String.Empty; - _newText = result.Title; - var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers(); - if (SpecialKeyState.ShiftPressed) - { - _newText = result.SubTitle; - } - ChangeQueryText(_newText); - } - }); - LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) @@ -310,7 +287,6 @@ namespace Flow.Launcher.ViewModel public bool GameModeStatus { get; set; } private string _queryText; - public string QueryText { get => _queryText; @@ -339,7 +315,24 @@ 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.