Repository: microsoft/terminal (language: cpp)

Issue:
[Terminal Chat] Shift+Enter should add a newline in the textbox
I pressed "Shift+Enter" expecting a newline and accidentally submitted my query.

With the text box being so large, it feels like "Shift+Enter" should be accepted to add newlines.

I _think_ this is an easy fix. We might just have to use this property: https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.textbox.acceptsreturn?view=winrt-26100#windows-ui-xaml-controls-textbox-acceptsreturn


Discussion / hints:

Fix patch:
diff --git a/src/cascadia/QueryExtension/ExtensionPalette.cpp b/src/cascadia/QueryExtension/ExtensionPalette.cpp
index 61657a7810a..bfae56125be 100644
--- a/src/cascadia/QueryExtension/ExtensionPalette.cpp
+++ b/src/cascadia/QueryExtension/ExtensionPalette.cpp
@@ -382,6 +382,7 @@ namespace winrt::Microsoft::Terminal::Query::Extension::implementation
         const auto key = e.OriginalKey();
         const auto coreWindow = CoreWindow::GetForCurrentThread();
         const auto ctrlDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Control), CoreVirtualKeyStates::Down);
+        const auto shiftDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Shift), CoreVirtualKeyStates::Down);
 
         if (key == VirtualKey::Escape)
         {
@@ -393,7 +394,7 @@ namespace winrt::Microsoft::Terminal::Query::Extension::implementation
 
             e.Handled(true);
         }
-        else if (key == VirtualKey::Enter)
+        else if (key == VirtualKey::Enter && !shiftDown)
         {
             if (const auto& textBox = e.OriginalSource().try_as<TextBox>())
             {
diff --git a/src/cascadia/QueryExtension/ExtensionPalette.xaml b/src/cascadia/QueryExtension/ExtensionPalette.xaml
index 2f807a86e4a..f6f3dce09ff 100644
--- a/src/cascadia/QueryExtension/ExtensionPalette.xaml
+++ b/src/cascadia/QueryExtension/ExtensionPalette.xaml
@@ -392,6 +392,7 @@
                      Height="100"
                      Margin="16,0,16,4"
                      Padding="18,8,8,8"
+                     AcceptsReturn="True"
                      IsSpellCheckEnabled="False"
                      PlaceholderText="{x:Bind QueryBoxPlaceholderText}"
                      Text=""


Test patch: