From 5a733d05dbc4c85dfe27ca152f06da496cd6910d Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Wed, 1 Dec 2021 04:20:54 -0500
Subject: [PATCH 01/12] Initial Tab complete
---
Flow.Launcher/MainWindow.xaml | 2 +-
Flow.Launcher/ViewModel/MainViewModel.cs | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index dd897965075..31f2c528c5d 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -41,7 +41,7 @@
-
+
+ {
+ 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.
+ {
+ ChangeQueryText(result.Title, true);
+ }
+ });
+
LoadContextMenuCommand = new RelayCommand(_ =>
{
if (SelectedIsFromQueryResults())
@@ -383,6 +399,7 @@ private ResultsViewModel SelectedResults
public ICommand OpenSettingCommand { get; set; }
public ICommand ReloadPluginDataCommand { get; set; }
public ICommand ClearQueryCommand { get; private set; }
+ public ICommand ReplaceQueryWithResult { get; set; }
public string OpenResultCommandModifiers { get; private set; }
From d61ac8548f01f4e787305d051ce7262428437c70 Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Wed, 1 Dec 2021 05:13:30 -0500
Subject: [PATCH 02/12] Remove requery bool
---
Flow.Launcher/ViewModel/MainViewModel.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 8e9ed5bf2de..73a0820ac4d 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -240,7 +240,7 @@ private void InitializeKeyCommands()
var result = results.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
- ChangeQueryText(result.Title, true);
+ ChangeQueryText(result.Title);
}
});
From f4edff71fecf35a1dd8edad455ef6873882fb353 Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Fri, 3 Dec 2021 05:44:33 -0500
Subject: [PATCH 03/12] Add field for tab complete
---
Flow.Launcher.Plugin/Result.cs | 11 +++++++++++
Flow.Launcher/ViewModel/MainViewModel.cs | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index 833ada9cda1..deb22510077 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -13,6 +13,8 @@ public class Result
private string _icoPath;
+ private string _insertText;
+
///
/// Provides the title of the result. This is always required.
///
@@ -29,6 +31,15 @@ public class Result
///
public string ActionKeywordAssigned { get; set; }
+ public string InsertText
+ {
+ get { return string.IsNullOrEmpty(_insertText) ? Title : _insertText; }
+ set
+ {
+ _insertText = value;
+ }
+ }
+
public string IcoPath
{
get { return _icoPath; }
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 73a0820ac4d..dc9fd5dd1e7 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -240,7 +240,7 @@ private void InitializeKeyCommands()
var result = results.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
- ChangeQueryText(result.Title);
+ ChangeQueryText(result.InsertText);
}
});
From 919d4515b9070ecea2a3619f127b60e0c2b12eae Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Fri, 3 Dec 2021 05:53:36 -0500
Subject: [PATCH 04/12] Insert subtitle when shift is held
---
Flow.Launcher/MainWindow.xaml | 2 +-
Flow.Launcher/ViewModel/MainViewModel.cs | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 31f2c528c5d..563038504a2 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -44,7 +44,7 @@
Date: Fri, 3 Dec 2021 09:30:47 -0500
Subject: [PATCH 05/12] 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 deb22510077..45f3e7663c8 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -31,14 +31,7 @@ public class Result
///
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 563038504a2..2675dd8825a 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 @@ private void InitializeKeyCommands()
public bool GameModeStatus { get; set; }
private string _queryText;
-
public string QueryText
{
get => _queryText;
@@ -339,7 +315,24 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
}
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.
From 5d9a897453c752bf1d2185c91cef9e6970e89291 Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Fri, 3 Dec 2021 10:31:59 -0500
Subject: [PATCH 06/12] Have QuerySuggection converter handle suggestions
---
.../Converters/QuerySuggestionBoxConverter.cs | 6 +++
Flow.Launcher/MainWindow.xaml | 7 ++++
Flow.Launcher/MainWindow.xaml.cs | 4 --
Flow.Launcher/ViewModel/MainViewModel.cs | 37 ++++++++++---------
4 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
index c70796a6d4e..c4533c019eb 100644
--- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
+++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
@@ -44,6 +44,12 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
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 2675dd8825a..3d383d7d8a7 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 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
}
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 @@ private ResultsViewModel SelectedResults
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; }
From 1d9bc990b29f7fca82220f064b23f843e59b36b4 Mon Sep 17 00:00:00 2001
From: Garulf <535299+Garulf@users.noreply.github.com>
Date: Sat, 4 Dec 2021 10:20:00 -0500
Subject: [PATCH 07/12] Remove unused variable
Co-authored-by: Jeremy Wu
---
Flow.Launcher.Plugin/Result.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index 45f3e7663c8..55c14b2c7b1 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -13,8 +13,6 @@ public class Result
private string _icoPath;
- private string _insertText;
-
///
/// Provides the title of the result. This is always required.
///
From 02b92c0a2aec8ffd01e29ee36cd4f3051fe3792f Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Sun, 5 Dec 2021 18:40:43 +1100
Subject: [PATCH 08/12] change variable name to AutoCompleteText
---
Flow.Launcher.Plugin/Result.cs | 7 ++++++-
.../Converters/QuerySuggestionBoxConverter.cs | 11 +++++------
Flow.Launcher/ViewModel/MainViewModel.cs | 2 +-
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index 55c14b2c7b1..29f8198ab44 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -29,7 +29,12 @@ public class Result
///
public string ActionKeywordAssigned { get; set; }
- public string SuggestionText { get; set; } = string.Empty;
+ ///
+ /// This holds the text which can be provided by plugin to help Flow autocomplete text
+ /// for user on the plugin result. If autocomplete action for example is tab, pressing tab will have
+ /// the default constructed autocomplete text (result's Title), or the text provided here if not empty.
+ ///
+ public string AutoCompleteText { get; set; }
public string IcoPath
{
diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
index c4533c019eb..6aa1facbc59 100644
--- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
+++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
@@ -43,13 +43,12 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
return string.Empty;
- // When user typed lower case and result title is uppercase, we still want to display suggestion
-
+ // construct autocomplete with suggestion
string _suggestion = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
- if (String.IsNullOrEmpty(selectedResult.SuggestionText))
- {
- selectedItem.Result.SuggestionText = _suggestion;
- }
+ if (string.IsNullOrEmpty(selectedResult.AutoCompleteText))
+ selectedItem.Result.AutoCompleteText = _suggestion;
+
+ // When user typed lower case and result title is uppercase, we still want to display suggestion
return queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
}
catch (Exception e)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index a8394cc6ba6..984bbecc76d 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -235,7 +235,7 @@ private void InitializeKeyCommands()
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;
+ string _newText = String.IsNullOrEmpty(result.AutoCompleteText) ? result.Title : result.AutoCompleteText;
var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers();
if (SpecialKeyState.ShiftPressed)
From 0fe8c93636a93b4f9fb4f1b89b6f6683baca3fda Mon Sep 17 00:00:00 2001
From: Jeremy Wu
Date: Sun, 5 Dec 2021 18:42:38 +1100
Subject: [PATCH 09/12] simplify code
---
Flow.Launcher/ViewModel/MainViewModel.cs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 984bbecc76d..5cc9d7cad99 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -230,9 +230,7 @@ private void InitializeKeyCommands()
InsertSuggestion = new RelayCommand(_ =>
{
- var results = SelectedResults;
-
- var result = results.SelectedItem?.Result;
+ var result = SelectedResults.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
string _newText = String.IsNullOrEmpty(result.AutoCompleteText) ? result.Title : result.AutoCompleteText;
From 2ba6ce9e874f80db739da756f79e8b6c3b759ed0 Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Sun, 5 Dec 2021 19:15:32 +1100
Subject: [PATCH 10/12] use ResultViewModel to hold constructed suggestion text
instead
---
.../Converters/QuerySuggestionBoxConverter.cs | 2 +-
Flow.Launcher/ViewModel/MainViewModel.cs | 16 +++++++++++++---
Flow.Launcher/ViewModel/ResultViewModel.cs | 2 ++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
index 6aa1facbc59..1890cba6ed9 100644
--- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
+++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
@@ -46,7 +46,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
// construct autocomplete with suggestion
string _suggestion = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
if (string.IsNullOrEmpty(selectedResult.AutoCompleteText))
- selectedItem.Result.AutoCompleteText = _suggestion;
+ selectedItem.QuerySuggestionText = _suggestion;
// When user typed lower case and result title is uppercase, we still want to display suggestion
return queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 5cc9d7cad99..6f87162d3ff 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -233,14 +233,24 @@ private void InitializeKeyCommands()
var result = SelectedResults.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
- string _newText = String.IsNullOrEmpty(result.AutoCompleteText) ? result.Title : result.AutoCompleteText;
+ var autoCompleteText = result.Title;
+
+ if (!string.IsNullOrEmpty(result.AutoCompleteText))
+ {
+ autoCompleteText = result.AutoCompleteText;
+ }
+ else if (!string.IsNullOrEmpty(SelectedResults.SelectedItem?.QuerySuggestionText))
+ {
+ autoCompleteText = SelectedResults.SelectedItem.QuerySuggestionText;
+ }
var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers();
if (SpecialKeyState.ShiftPressed)
{
- _newText = result.SubTitle;
+ autoCompleteText = result.SubTitle;
}
- ChangeQueryText(_newText);
+
+ ChangeQueryText(autoCompleteText);
}
});
diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs
index ed3d842e3b9..908de0c0993 100644
--- a/Flow.Launcher/ViewModel/ResultViewModel.cs
+++ b/Flow.Launcher/ViewModel/ResultViewModel.cs
@@ -142,6 +142,8 @@ private async ValueTask LoadImageAsync()
public Result Result { get; }
+ public string QuerySuggestionText { get; set; }
+
public override bool Equals(object obj)
{
return obj is ResultViewModel r && Result.Equals(r.Result);
From e3aa648e88b7bc4215f800222eb4c6c0860db38b Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Sun, 5 Dec 2021 19:28:04 +1100
Subject: [PATCH 11/12] rename function to AutocompleteQueryCommand
---
Flow.Launcher/MainWindow.xaml | 4 ++--
Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 3d383d7d8a7..1f449421522 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -43,10 +43,10 @@
+ Command="{Binding AutocompleteQueryCommand}"/>
+ AutocompleteQueryCommand = new RelayCommand(_ =>
{
var result = SelectedResults.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
@@ -408,7 +408,7 @@ private ResultsViewModel SelectedResults
public ICommand OpenSettingCommand { get; set; }
public ICommand ReloadPluginDataCommand { get; set; }
public ICommand ClearQueryCommand { get; private set; }
- public ICommand InsertSuggestion { get; set; }
+ public ICommand AutocompleteQueryCommand { get; set; }
public string OpenResultCommandModifiers { get; private set; }
From 78dbc0c53dbc5c2471dd96e14f6feca38b9a449b Mon Sep 17 00:00:00 2001
From: Jeremy
Date: Sun, 5 Dec 2021 19:40:36 +1100
Subject: [PATCH 12/12] simplify suggestion's autocomplete logic
---
.../Converters/QuerySuggestionBoxConverter.cs | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
index 1890cba6ed9..acbbf6971e1 100644
--- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
+++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
@@ -43,13 +43,11 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
return string.Empty;
- // construct autocomplete with suggestion
- string _suggestion = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
- if (string.IsNullOrEmpty(selectedResult.AutoCompleteText))
- selectedItem.QuerySuggestionText = _suggestion;
-
+ // For AutocompleteQueryCommand.
// When user typed lower case and result title is uppercase, we still want to display suggestion
- return queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
+ selectedItem.QuerySuggestionText = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
+
+ return selectedItem.QuerySuggestionText;
}
catch (Exception e)
{