From eddeaab829cbd6cbd870c4aceb238dc236d72edb Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 23 Mar 2022 14:20:03 -0700 Subject: [PATCH] [Conhost] Notify UIA when letter deleted via backspace (#12735) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary of the Pull Request Fixes a bug in ConHost where Narrator wouldn't read the deleted letter after the user pressed backspace. ## References MSFT:31748387 ## Detailed Description of the Pull Request / Additional comments `WriteCharsLegacy()` already calls `NotifyAccessibilityEventing()` when text is inserted into the buffer ([see code](https://github.com/microsoft/terminal/blob/855e1360c0ff810decf862f1d90e15b5f49e7bbd/src/host/_stream.cpp#L559-L563)). However, when backspace is pressed, the entire if-condition is skipped over, resulting in the accessibility event not being fired. `WriteCharsLegacy()` has a separate branch that is dedicated to handling backspace, so I added a call to the relevant logic to notify UIA at the end of that. ## Validation Steps Performed ✅ Backspace deletes a character and Narrator reads it ✅ Backspace still works with NVDA and JAWS (unchanged behavior) ✅ if the input buffer had wrapped text, the above scenario works as expected ✅ scenario works for CMD, PowerShell Core, and WSL --- src/host/_stream.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/host/_stream.cpp b/src/host/_stream.cpp index 544b89af995..8407f5e0759 100644 --- a/src/host/_stream.cpp +++ b/src/host/_stream.cpp @@ -765,6 +765,15 @@ using Microsoft::Console::VirtualTerminal::StateMachine; Status = AdjustCursorPosition(screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY); } } + // Notify accessibility to read the backspaced character. + // See GH:12735, MSFT:31748387 + if (screenInfo.HasAccessibilityEventing()) + { + if (IConsoleWindow* pConsoleWindow = ServiceLocator::LocateConsoleWindow()) + { + LOG_IF_FAILED(pConsoleWindow->SignalUia(UIA_Text_TextChangedEventId)); + } + } break; } case UNICODE_TAB: