Skip to content

Commit ce92b18

Browse files
Fix overwrite key binding warning in the SUI (#17763)
Fixes a regression from the actions MVVM change in #14292 - attempting to overwrite a keybinding was displaying a warning but propagating the change before the user acknowledged it. The overwrite key binding warning in the SUI works like before Closes #17754
1 parent fd1b1c3 commit ce92b18

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
278278
// Check for this special case:
279279
// we're changing the key chord,
280280
// but the new key chord is already in use
281+
bool conflictFound{ false };
281282
if (isNewAction || args.OldKeys().Modifiers() != args.NewKeys().Modifiers() || args.OldKeys().Vkey() != args.NewKeys().Vkey())
282283
{
283284
const auto& conflictingCmd{ _Settings.ActionMap().GetActionByKeyChord(args.NewKeys()) };
284285
if (conflictingCmd)
285286
{
287+
conflictFound = true;
286288
// We're about to overwrite another key chord.
287289
// Display a confirmation dialog.
288290
TextBlock errorMessageTB{};
@@ -324,13 +326,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
324326
}
325327
}
326328

327-
// update settings model and view model
328-
applyChangesToSettingsModel();
329+
// if there was a conflict, the flyout we created will handle whether changes need to be propagated
330+
// otherwise, go ahead and apply the changes
331+
if (!conflictFound)
332+
{
333+
// update settings model and view model
334+
applyChangesToSettingsModel();
329335

330-
// We NEED to toggle the edit mode here,
331-
// so that if nothing changed, we still exit
332-
// edit mode.
333-
senderVM.ToggleEditMode();
336+
// We NEED to toggle the edit mode here,
337+
// so that if nothing changed, we still exit
338+
// edit mode.
339+
senderVM.ToggleEditMode();
340+
}
334341
}
335342

336343
void ActionsViewModel::_KeyBindingViewModelDeleteNewlyAddedKeyBindingHandler(const Editor::KeyBindingViewModel& senderVM, const IInspectable& /*args*/)

0 commit comments

Comments
 (0)