mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Have QuerySuggection converter handle suggestions
This commit is contained in:
parent
9bc68fd89b
commit
5d9a897453
4 changed files with 32 additions and 22 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@
|
|||
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
|
||||
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}" />
|
||||
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
|
||||
<KeyBinding
|
||||
Key="Tab"
|
||||
Command="{Binding InsertSuggestion}"/>
|
||||
<KeyBinding
|
||||
Key="Tab"
|
||||
Command="{Binding InsertSuggestion}"
|
||||
Modifiers="Shift" />
|
||||
<KeyBinding
|
||||
Key="I"
|
||||
Command="{Binding OpenSettingCommand}"
|
||||
|
|
|
|||
|
|
@ -469,10 +469,6 @@ namespace Flow.Launcher
|
|||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Key.Tab:
|
||||
_viewModel.InsertSuggestion(QueryTextSuggestionBox.Text);
|
||||
e.Handled = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -228,6 +228,24 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
});
|
||||
|
||||
InsertSuggestion = new RelayCommand(_ =>
|
||||
{
|
||||
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; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue