From 0473430282c01be361f4d0711612ca5d6b5d394d Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Mon, 25 Jul 2022 10:27:57 -0700 Subject: [PATCH] fix announcement for duplicate tab/pane --- .../Resources/en-US/Resources.resw | 6 +++-- src/cascadia/TerminalApp/TabManagement.cpp | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index e953ab35ac..76aacd7c0f 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -747,9 +747,11 @@ {0} will be replaced with a number. - {} profile tab created successfully + A new tab for the "{}" profile was created successfully + {} will be replaced with the name of the profile (i.e. PowerShell, Command Prompt, etc.). The name may span multiple words. This announcement is read by a screen reader. - {} profile pane created successfully + A new pane for the "{}" profile was created successfully + {} will be replaced with the name of the profile (i.e. PowerShell, Command Prompt, etc.). The name may span multiple words. This announcement is read by a screen reader. \ No newline at end of file diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp index ebd36cfa8e..4f9ef8b174 100644 --- a/src/cascadia/TerminalApp/TabManagement.cpp +++ b/src/cascadia/TerminalApp/TabManagement.cpp @@ -87,15 +87,6 @@ namespace winrt::TerminalApp::implementation // case above with the _maybeElevate call. _CreateNewTabFromPane(_MakePane(newTerminalArgs, false, existingConnection)); - if (_autoPeer) - { - _autoPeer.RaiseNotificationEvent( - Automation::Peers::AutomationNotificationKind::ActionCompleted, - Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, - fmt::format(std::wstring_view{ RS_(L"NewTabAnnouncement") }, settings.DefaultSettings().ProfileName()), - L"NewTab" /* unique name for this notification category */); - } - const auto tabCount = _tabs.Size(); const auto usedManualProfile = (newTerminalArgs != nullptr) && (newTerminalArgs.ProfileIndex() != nullptr || @@ -297,6 +288,20 @@ namespace winrt::TerminalApp::implementation { auto newTabImpl = winrt::make_self(pane); _InitializeTab(newTabImpl); + + if (_autoPeer) + { + // we can't check if this is a leaf pane, + // but getting the profile returns null if we aren't, so that works! + if (const auto profile{ pane->GetProfile() }) + { + _autoPeer.RaiseNotificationEvent( + Automation::Peers::AutomationNotificationKind::ActionCompleted, + Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, + fmt::format(std::wstring_view{ RS_(L"NewTabAnnouncement") }, profile.Name()), + L"NewTab" /* unique name for this notification category */); + } + } } }