Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overwrite key binding warning in the SUI #17763

Merged
merged 2 commits into from
Aug 21, 2024
Merged
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
19 changes: 13 additions & 6 deletions src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// Check for this special case:
// we're changing the key chord,
// but the new key chord is already in use
bool conflictFound{ false };
if (isNewAction || args.OldKeys().Modifiers() != args.NewKeys().Modifiers() || args.OldKeys().Vkey() != args.NewKeys().Vkey())
{
const auto& conflictingCmd{ _Settings.ActionMap().GetActionByKeyChord(args.NewKeys()) };
if (conflictingCmd)
{
conflictFound = true;
// We're about to overwrite another key chord.
// Display a confirmation dialog.
TextBlock errorMessageTB{};
Expand Down Expand Up @@ -324,13 +326,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
}

// update settings model and view model
applyChangesToSettingsModel();
// if there was a conflict, the flyout we created will handle whether changes need to be propagated
// otherwise, go ahead and apply the changes
if (!conflictFound)
{
// update settings model and view model
applyChangesToSettingsModel();

// We NEED to toggle the edit mode here,
// so that if nothing changed, we still exit
// edit mode.
senderVM.ToggleEditMode();
// We NEED to toggle the edit mode here,
// so that if nothing changed, we still exit
// edit mode.
senderVM.ToggleEditMode();
}
}

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