diff --git a/src/common/UITestAutomation/UITestAutomation.csproj b/src/common/UITestAutomation/UITestAutomation.csproj
index 17841e0a60..add7acfeb9 100644
--- a/src/common/UITestAutomation/UITestAutomation.csproj
+++ b/src/common/UITestAutomation/UITestAutomation.csproj
@@ -17,8 +17,6 @@
-
-
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.Common/Microsoft.CmdPal.Common.csproj b/src/modules/cmdpal/Microsoft.CmdPal.Common/Microsoft.CmdPal.Common.csproj
index 27509d0e5b..d1b847b1b5 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.Common/Microsoft.CmdPal.Common.csproj
+++ b/src/modules/cmdpal/Microsoft.CmdPal.Common/Microsoft.CmdPal.Common.csproj
@@ -16,7 +16,6 @@
-
all
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
index 6b6a579207..cafb351d21 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ContentTreeViewModel.cs
@@ -25,7 +25,7 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference Root => [RootContent];
+ public ObservableCollection Root => RootContent is not null ? [RootContent] : [];
public override void InitializeProperties()
{
@@ -122,7 +122,7 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference _inSuggestion && IsTextToSuggestEnabled;
+
private string? _lastText;
+
private string? _deletedSuggestion;
+ // 0.6+ suggestions
+ private string? _textToSuggest;
+
public PageViewModel? CurrentPageViewModel
{
get => (PageViewModel?)GetValue(CurrentPageViewModelProperty);
@@ -194,7 +206,23 @@ public sealed partial class SearchBar : UserControl,
}
else if (e.Key == VirtualKey.Right)
{
- if (_inSuggestion)
+ // Check if the "replace search text with suggestion" feature from 0.4-0.5 is enabled.
+ // If it isn't, then only use the suggestion when the caret is at the end of the input.
+ if (!IsTextToSuggestEnabled)
+ {
+ if (_textToSuggest != null &&
+ FilterBox.SelectionStart == FilterBox.Text.Length)
+ {
+ FilterBox.Text = _textToSuggest;
+ FilterBox.Select(_textToSuggest.Length, 0);
+ e.Handled = true;
+ }
+
+ return;
+ }
+
+ // Here, we're using the "replace search text with suggestion" feature.
+ if (InSuggestion)
{
_inSuggestion = false;
_lastText = null;
@@ -208,7 +236,7 @@ public sealed partial class SearchBar : UserControl,
e.Handled = true;
}
- if (_inSuggestion)
+ if (InSuggestion)
{
if (
e.Key == VirtualKey.Back ||
@@ -294,7 +322,7 @@ public sealed partial class SearchBar : UserControl,
return;
}
- if (_inSuggestion)
+ if (InSuggestion)
{
// Logger.LogInfo($"-- skipping, in suggestion --");
return;
@@ -316,7 +344,7 @@ public sealed partial class SearchBar : UserControl,
private void DoFilterBoxUpdate()
{
- if (_inSuggestion)
+ if (InSuggestion)
{
// Logger.LogInfo($"--- skipping ---");
return;
@@ -368,6 +396,12 @@ public sealed partial class SearchBar : UserControl,
public void Receive(UpdateSuggestionMessage message)
{
+ if (!IsTextToSuggestEnabled)
+ {
+ _textToSuggest = message.TextToSuggest;
+ return;
+ }
+
var suggestion = message.TextToSuggest;
_queue.TryEnqueue(new(() =>
@@ -457,4 +491,15 @@ public sealed partial class SearchBar : UserControl,
}
}));
}
+
+ private static bool IsTextToSuggestEnabled => _textToSuggestEnabled.Value;
+
+ private static Lazy _textToSuggestEnabled = new(() => QueryTextToSuggestEnabled());
+
+ private static bool QueryTextToSuggestEnabled()
+ {
+ var env = System.Environment.GetEnvironmentVariable("CMDPAL_ENABLE_SUGGESTION_SELECTION");
+ return !string.IsNullOrEmpty(env) &&
+ (env == "1" || env.Equals("true", System.StringComparison.OrdinalIgnoreCase));
+ }
}
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
index b89533035d..82b3d9fb2c 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj
@@ -99,13 +99,6 @@
-
-
-
-
-
-
-