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

Port selection in conhost and Terminal to use til::generational #17676

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Aug 6, 2024

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.

@DHowett
Copy link
Member Author

DHowett commented Aug 6, 2024

Ugh, I apparently need to split up my commit that fixes the tests for SelectionSpans to move some of the generational changes down here

@DHowett DHowett force-pushed the dev/duhowett/sel-1-generational branch 2 times, most recently from f6f45e5 to f9884e8 Compare August 7, 2024 01:00
We will avoid regenerating the selection rects every time we draw the
screen
@DHowett DHowett force-pushed the dev/duhowett/sel-1-generational branch from f9884e8 to 49a0277 Compare August 7, 2024 16:35
Comment on lines +400 to +402
selection->start = buffer.GetWordStart(selection->start, _wordDelimiters);
selection->pivot = selection->start;
selection->end = buffer.GetWordEnd(selection->end, _wordDelimiters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this have essentially the same issue as the wide <> narrow cell issue you mention in the PR message? So, in a way it's actually perhaps more than fine to ignore the issue for now.

(I wonder if we should have a "SelectionMode" enum or something in the future that can be set to word-wise and then it extends by words in the renderer and clipboard code? Possible over-engineering though hah.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I wonder if we should have a "SelectionMode" enum or something in the future that can be set to word-wise and then it extends by words in the renderer and clipboard code? Possible over-engineering though hah.)

I think wordwise and linewise selection actually impacts the literal selection, rather than only the display of the selection. I think we should not mix those things yet.

auto selection{ m_pSelection->_d.write() };
// #2: right to left selection
selection->coordSelectionAnchor.x = selection->srSelectionRect.right;
VERIFY_IS_TRUE(selection->srSelectionRect.bottom == selection->srSelectionRect.top);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what even is this check? i mean, i guess it's defending the tests against a bad test author. but we set bottom ourselves.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

src/host/selectionInput.cpp Show resolved Hide resolved
@DHowett DHowett merged commit 0199ca3 into main Aug 9, 2024
20 checks passed
@DHowett DHowett deleted the dev/duhowett/sel-1-generational branch August 9, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants