-
Notifications
You must be signed in to change notification settings - Fork 60
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
no excessive highlighting #263
base: master
Are you sure you want to change the base?
Conversation
multiline labels are not highlighted any more
Sorry for my slow review on this - need to figure out whether I'm happy with how we're iterating over the characters of a source line. |
let text_end = source | ||
.char_indices() | ||
.rev() | ||
.take_while(|(_, c)| c.is_whitespace()) | ||
.last() | ||
.map(|(index, _)| index) | ||
.unwrap_or_else(|| source.len()); |
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.
This could also be rewritten using str::rfind, but because we have to find the first trailing non-whitespace character, we would have to find the char lengt of the character to adjust, which makes it not much clearer than the curren solution.
let text_end = source | |
.char_indices() | |
.rev() | |
.take_while(|(_, c)| c.is_whitespace()) | |
.last() | |
.map(|(index, _)| index) | |
.unwrap_or_else(|| source.len()); | |
let text_end = source | |
.rfind(|c| !char::is_whitespace(c)) | |
.map(|index| | |
index + source[index..] | |
.chars() | |
.next() | |
.map_or(0, |c| c.len_utf8()) | |
) | |
.unwrap_or_else(|| source.len()); |
@brendanzab any feedback on this? |
This should resolve #261.
Is this just okay like this, or should this be configurable?