[PR #13907] [MERGED] Revert "Remove most uses of CompareInBounds (#13244)" #29825

Open
opened 2026-01-31 09:37:06 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13907
Author: @carlos-zamora
Created: 9/2/2022
Status: Merged
Merged: 9/2/2022
Merged by: @undefined

Base: mainHead: dev/cazamor/a11y/revert-13244


📝 Commits (1)

📊 Changes

6 files changed (+60 additions, -55 deletions)

View changed files

📝 src/buffer/out/textBuffer.cpp (+10 -20)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+3 -3)
📝 src/interactivity/win32/ut_interactivity_win32/UiaTextRangeTests.cpp (+2 -2)
📝 src/types/UiaTextRangeBase.cpp (+26 -23)
📝 src/types/inc/viewport.hpp (+2 -2)
📝 src/types/viewport.cpp (+17 -5)

📄 Description

This reverts commit f785168aac (PR #13244)

The error logged to NVDA was caused by the following line of code in _getTextValue():
THROW_HR_IF(E_FAIL, !bufferSize.IsInBounds(_start) || !bufferSize.IsInBounds(_end));
NVDA would expand a text range to encompass the document in the alt buffer. This means that the "end" would be set to the dangling "endExclusive" point (x = left, y = one past the end of the buffer). This is a valid range!
However, upon extracting the text, we would hit the code above. The exclusive end doesn't actually point to anything in the buffer, so we would falsly throw E_FAIL.

Though this could be fixed by adding a special check for the endExclusive in the line above, I suspect there are other places throughout the UIA code that hit this problem too. The safest course of action is to revert this commit entirely since it was a code health commit (it doesn't actually close an issue).

Closes #13866


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13907 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 9/2/2022 **Status:** ✅ Merged **Merged:** 9/2/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/cazamor/a11y/revert-13244` --- ### 📝 Commits (1) - [`b0e1094`](https://github.com/microsoft/terminal/commit/b0e1094b44235e8aa2f3303203ac7300a2ae3f83) Revert "Remove most uses of `CompareInBounds` (#13244)" ### 📊 Changes **6 files changed** (+60 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/textBuffer.cpp` (+10 -20) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+3 -3) 📝 `src/interactivity/win32/ut_interactivity_win32/UiaTextRangeTests.cpp` (+2 -2) 📝 `src/types/UiaTextRangeBase.cpp` (+26 -23) 📝 `src/types/inc/viewport.hpp` (+2 -2) 📝 `src/types/viewport.cpp` (+17 -5) </details> ### 📄 Description This reverts commit f785168aacf79e2923f0d140e17fdd4c9364e51d (PR #13244) The error logged to NVDA was caused by the following line of code in `_getTextValue()`: `THROW_HR_IF(E_FAIL, !bufferSize.IsInBounds(_start) || !bufferSize.IsInBounds(_end));` NVDA would expand a text range to encompass the document in the alt buffer. This means that the "end" would be set to the dangling "endExclusive" point (x = left, y = one past the end of the buffer). This is a valid range! However, upon extracting the text, we would hit the code above. The exclusive end doesn't actually point to anything in the buffer, so we would falsly throw `E_FAIL`. Though this could be fixed by adding a special check for the `endExclusive` in the line above, I suspect there are other places throughout the UIA code that hit this problem too. The safest course of action is to revert this commit entirely since it was a code health commit (it doesn't actually close an issue). Closes #13866 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:37:06 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29825