Skip to content

Commit 280ff09

Browse files
AlejandroBlanco2001DHowett
authored andcommitted
Update CommandPalette.cpp to ignore _filterTextChanged on TabSwitchMode (#16858)
As mentioned in #11146, when the "Next/Prev" command is executed from the command line with a string in the search bar, this is setting always the first tab. When using the command "Next/Previous Tab" from the command line, we are creating another tab (as if we are using the keyboard shortcut), and this triggers the `_filterTextChanged` that resets the index to the first item in because the current mode that it has. This could be cause because, It seems that it detects as if we are deleting the entered letter or creating an empty string, causing the execution of the mentioned method and resetting its index to 0. To avoid this, we are making sure that when this action is triggerd and we are in the `TabSwitchMode`, we should ignore the following execution of the method. ## Validation Steps Performed I tested out the following scenarios: 1. Performing the action with the keyboard shorcut 2. Perfoming the action with an empty string 3. Performing the action with a string in the search bar. Also validated with the current tests. Closes #11146 (cherry picked from commit 806d5e2) Service-Card-Id: 92139799 Service-Version: 1.19
1 parent 24cb2df commit 280ff09

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/cascadia/TerminalApp/CommandPalette.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,16 @@ namespace winrt::TerminalApp::implementation
843843
void CommandPalette::_filterTextChanged(const IInspectable& /*sender*/,
844844
const Windows::UI::Xaml::RoutedEventArgs& /*args*/)
845845
{
846+
// When we are executing the _SelectNextTab in the TabManagement.cpp, this method
847+
// is getting triggered because we set up the default value for that CommandPalette
848+
// with an empty string. Therefore, to avoid the reset of the index when executing
849+
// the Next/Prev tab command, we are skipping this execution.
850+
// Check issue https://github.com/microsoft/terminal/issues/11146
851+
if (_currentMode == CommandPaletteMode::TabSwitchMode)
852+
{
853+
return;
854+
}
855+
846856
if (_currentMode == CommandPaletteMode::CommandlineMode)
847857
{
848858
_evaluatePrefix();

0 commit comments

Comments
 (0)