From 9bc68fd89b9653f7afec03c2cdbe43a9d2ea5049 Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Fri, 3 Dec 2021 09:30:47 -0500
Subject: [PATCH] Use suggestion text
Use suggestion text if available
---
Flow.Launcher.Plugin/Result.cs | 9 +-----
Flow.Launcher/MainWindow.xaml | 5 ---
Flow.Launcher/MainWindow.xaml.cs | 4 +++
Flow.Launcher/ViewModel/MainViewModel.cs | 41 ++++++++++--------------
4 files changed, 22 insertions(+), 37 deletions(-)
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.