-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Visible whitespace only for selections #2208
Visible whitespace only for selections #2208
Conversation
This is my first foray into rust so the code may not be idomatic |
2597768
to
a5825b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay on this. Admittedly it took me a while to figure out how this was working despite being familiar with these parts of the codebase 😅
a5825b0
to
9a8bea1
Compare
I'm not sure this makes sense or if it's too much of a micro optimization but we could not emit selection events when none of the WhitespaceRenderValues are for select. What do you think? |
Sure, done in latest revision |
helix-core/src/syntax.rs
Outdated
SelectionStart, | ||
SelectionEnd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took a while! I wonder if we could avoid additional event types and instead just track this in the render loop. When HighlightStart(selection scope)
is emitted we'd toggle a local bool to true, then false when it's popped off the scope stack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I hope I've understood your suggestion properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think archseer is saying that you can track this without changing the helix_core::syntax
by looking up the scope for the highlight event and seeing if it's a selection scope:
HighlightEvent::HighlightStart(span) => {
if theme
.scopes()
.get(span.0)
.map(|scope| scope.starts_with("ui.selection"))
.unwrap_default()
{
selecting = true;
}
spans.push(span);
}
// and for HighlightEnd, check that the popped scope starts with "ui.selection"
that snippet ☝️ isn't very performant though - we should calculate which indices in theme.scopes()
correspond to selection highlights outside of the for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clarifying. I think I've done it in the latest revision
It looks like whitespace ends up not getting rendered for the cursor. For that we may need to include |
I've done some simplifications, this way we can avoid comparing spans against the set of selection scopes in most cases. I'm also thinking if we want to remove that render closure for a regular function |
Thanks for the commits @archseer ! I've added a fix for |
With #5420 merged this PR will need to be ported to the new text rendering in |
clsoing this one as stale as the rendering code has been entirely replaced. Thank you for contributing |
No description provided.