[PR #17676] Port selection in conhost and Terminal to use til::generational #31321

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

Original Pull Request: https://github.com/microsoft/terminal/pull/17676

State: closed
Merged: Yes


In #17638, I am moving selection to an earlier phase of rendering (so
that further phases can take it into account). Since I am drafting off
the design of search highlights, one of the required changes is moving
to passing spans of point_spans around to make selection effectively
zero-copy.

We can't easily have zero-copy selection propagation without caching,
and we can't have caching without mandatory cache invalidation.

This pull request moves both conhost and Terminal to use
til::generational for all selection members that impact the ranges
that would be produced from GetSelectionRects.

This required a move from std::optional<> to a boolean to determine
whether a selection was active in Terminal.

We will no longer regenerate the selection rects from the selection
anchors plus the text buffer every single frame.

Apart from being annoying to read, there is one downside.

If you begin a selection on a narrow character, and that narrow
character later turns into a wide character
, we will show it as
half-selected.

This should be a rare-enough case that we can accept it as a regression.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/17676 **State:** closed **Merged:** Yes --- In #17638, I am moving selection to an earlier phase of rendering (so that further phases can take it into account). Since I am drafting off the design of search highlights, one of the required changes is moving to passing `span`s of `point_span`s around to make selection effectively zero-copy. We can't easily have zero-copy selection propagation without caching, and we can't have caching without mandatory cache invalidation. This pull request moves both conhost and Terminal to use `til::generational` for all selection members that impact the ranges that would be produced from `GetSelectionRects`. This required a move from `std::optional<>` to a boolean to determine whether a selection was active in Terminal. We will no longer regenerate the selection rects from the selection anchors plus the text buffer *every single frame*. Apart from being annoying to read, there is one downside. If you begin a selection on a narrow character, _and that narrow character later turns into a wide character_, we will show it as half-selected. This should be a rare-enough case that we can accept it as a regression.
claunia added the pull-request label 2026-01-31 09:46:33 +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#31321