Conversation
Render whitespace with similar logic to VSCode. Notably this doesn't take selected text into account.
bugadani
left a comment
There was a problem hiding this comment.
Thank you, this looks promising!
I have one nit to pick: would it be possible to replace the "push-in-loop" style appending with string.extend(iter) instead?
I'm also cc'ing #302 - if we'll ever have dropdowns, we could think about turning the setting into an enum and avoid string comparisons.
This comment was marked as off-topic.
This comment was marked as off-topic.
Line 2027: for c in whitespace_buffer.iter() {
rendered_whitespaces.push(c);
}And line 2043: whitespace_buffer
.iter()
.for_each(|c| rendered_whitespaces.push(*c));Can be easily turned into rendered_whitespaces.extend(whitespace_buffer.iter());And I agree that it's a lot cleaner that way. Would that be enough? I think removing other "push-in-loops" require rewriting the whole logic.
I agree with using enums. They are easy to implement, easy to understand and the comparisons are fast. And they even work well if/when the UI starts supporting translations. |
Why do you think that it will be required. |
Not really, I was only referring to those 3-liner snippets you quoted (I saw 3 of those I think). So yup, that's probably enough here :) |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Added a commit that uses extend where it makes sense.
There was 3 but one of those was pushing |
* Render whitespace Render whitespace with similar logic to VSCode. Notably this doesn't take selected text into account. * Make clippy happy * Use extend instead of pushing in loops
Adding simple logic for whitespace rendering. Rendering logic is similar to VSCode.
Notably this doesn't take selected text into account. So this doesn't implement the
selectionwhitespace rendering option.Feature request: #249