Open
Conversation
multiline labels are not highlighted any more
Owner
|
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. |
Johann150
commented
Jan 29, 2021
Comment on lines
+247
to
+253
| let text_end = source | ||
| .char_indices() | ||
| .rev() | ||
| .take_while(|(_, c)| c.is_whitespace()) | ||
| .last() | ||
| .map(|(index, _)| index) | ||
| .unwrap_or_else(|| source.len()); |
Contributor
Author
There was a problem hiding this comment.
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.
Suggested change
| 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()); |
Contributor
Author
|
@brendanzab any feedback on this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should resolve #261.
Is this just okay like this, or should this be configurable?