Use suggestion text

Use suggestion text if available
This commit is contained in:
Garulf 2021-12-03 09:30:47 -05:00
parent 919d4515b9
commit 9bc68fd89b
4 changed files with 22 additions and 37 deletions

View file

@ -31,14 +31,7 @@ namespace Flow.Launcher.Plugin
/// </summary>
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
{

View file

@ -41,11 +41,6 @@
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}" />
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
<KeyBinding Key="Tab" Command="{Binding ReplaceQueryWithResult}" />
<KeyBinding
Key="Tab"
Command="{Binding ReplaceQueryWithResult}"
Modifiers="Shift" />
<KeyBinding
Key="I"
Command="{Binding OpenSettingCommand}"

View file

@ -469,6 +469,10 @@ namespace Flow.Launcher
e.Handled = true;
}
break;
case Key.Tab:
_viewModel.InsertSuggestion(QueryTextSuggestionBox.Text);
e.Handled = true;
break;
default:
break;

View file

@ -228,29 +228,6 @@ namespace Flow.Launcher.ViewModel
}
});
ReplaceQueryWithResult = new RelayCommand(index =>
{
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.