Skip to content

Commit 9bc68fd

Browse files
committed
Use suggestion text
Use suggestion text if available
1 parent 919d451 commit 9bc68fd

File tree

4 files changed

+22
-37
lines changed

4 files changed

+22
-37
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ public class Result
3131
/// </summary>
3232
public string ActionKeywordAssigned { get; set; }
3333

34-
public string InsertText
35-
{
36-
get { return string.IsNullOrEmpty(_insertText) ? Title : _insertText; }
37-
set
38-
{
39-
_insertText = value;
40-
}
41-
}
34+
public string SuggestionText { get; set; } = string.Empty;
4235

4336
public string IcoPath
4437
{

Flow.Launcher/MainWindow.xaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
4242
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}" />
4343
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
44-
<KeyBinding Key="Tab" Command="{Binding ReplaceQueryWithResult}" />
45-
<KeyBinding
46-
Key="Tab"
47-
Command="{Binding ReplaceQueryWithResult}"
48-
Modifiers="Shift" />
4944
<KeyBinding
5045
Key="I"
5146
Command="{Binding OpenSettingCommand}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ private void OnKeyDown(object sender, KeyEventArgs e)
469469
e.Handled = true;
470470
}
471471
break;
472+
case Key.Tab:
473+
_viewModel.InsertSuggestion(QueryTextSuggestionBox.Text);
474+
e.Handled = true;
475+
break;
472476
default:
473477
break;
474478

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -228,29 +228,6 @@ private void InitializeKeyCommands()
228228
}
229229
});
230230

231-
ReplaceQueryWithResult = new RelayCommand(index =>
232-
{
233-
var results = SelectedResults;
234-
235-
if (index != null)
236-
{
237-
results.SelectedIndex = int.Parse(index.ToString());
238-
}
239-
240-
var result = results.SelectedItem?.Result;
241-
if (result != null) // SelectedItem returns null if selection is empty.
242-
{
243-
string _newText = String.Empty;
244-
_newText = result.Title;
245-
var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers();
246-
if (SpecialKeyState.ShiftPressed)
247-
{
248-
_newText = result.SubTitle;
249-
}
250-
ChangeQueryText(_newText);
251-
}
252-
});
253-
254231
LoadContextMenuCommand = new RelayCommand(_ =>
255232
{
256233
if (SelectedIsFromQueryResults())
@@ -310,7 +287,6 @@ private void InitializeKeyCommands()
310287
public bool GameModeStatus { get; set; }
311288

312289
private string _queryText;
313-
314290
public string QueryText
315291
{
316292
get => _queryText;
@@ -339,7 +315,24 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
339315
}
340316
QueryTextCursorMovedToEnd = true;
341317
}
318+
public void InsertSuggestion(string suggestion)
319+
{
320+
var results = SelectedResults;
342321

322+
var result = results.SelectedItem?.Result;
323+
if (result != null) // SelectedItem returns null if selection is empty.
324+
{
325+
suggestion = String.IsNullOrEmpty(suggestion) ? result.Title : suggestion;
326+
string _newText = String.IsNullOrEmpty(result.SuggestionText) ? suggestion : result.SuggestionText;
327+
328+
var SpecialKeyState = GlobalHotkey.Instance.CheckModifiers();
329+
if (SpecialKeyState.ShiftPressed)
330+
{
331+
_newText = result.SubTitle;
332+
}
333+
ChangeQueryText(_newText);
334+
}
335+
}
343336
public bool LastQuerySelected { get; set; }
344337

345338
// This is not a reliable indicator of the cursor's position, it is manually set for a specific purpose.

0 commit comments

Comments
 (0)