Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PreviewDragOver="OnPreviewDragOver"
TextChanged="OnTextChanged"
AllowDrop="True"
Visibility="Visible"
Background="Transparent"
Expand Down
15 changes: 9 additions & 6 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ private void OnLoaded(object sender, RoutedEventArgs _)

break;
}
case nameof(MainViewModel.QueryTextCursorMovedToEnd):
if (_viewModel.QueryTextCursorMovedToEnd)
{
MoveQueryTextToEnd();
_viewModel.QueryTextCursorMovedToEnd = false;
}
break;
}
};
_settings.PropertyChanged += (o, e) =>
Expand Down Expand Up @@ -329,13 +336,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
}
}

private void OnTextChanged(object sender, TextChangedEventArgs e)
private void MoveQueryTextToEnd()
{
if (_viewModel.QueryTextCursorMovedToEnd)
{
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
_viewModel.QueryTextCursorMovedToEnd = false;
}
Comment on lines -332 to -338
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add this once we want to do something else when text changed, but currently it would be better to call it when the property changed.

QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
}
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ public string QueryText
/// <param name="queryText"></param>
public void ChangeQueryText(string queryText)
{
QueryTextCursorMovedToEnd = true;
QueryText = queryText;
QueryTextCursorMovedToEnd = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change order to avoid unintended position changed before the QueryText Changed

}

public bool LastQuerySelected { get; set; }
Expand Down