-
-
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
Prevent whitespace from rendering inside inlay hints #6312
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,9 +287,11 @@ pub fn render_text<'t>( | |
style_span.0 | ||
}; | ||
|
||
let virt = grapheme.is_virtual().clone(); | ||
renderer.draw_grapheme( | ||
grapheme.grapheme, | ||
grapheme_style, | ||
virt, | ||
&mut last_line_indent_level, | ||
&mut is_in_indent_area, | ||
pos, | ||
|
@@ -392,6 +394,7 @@ impl<'a> TextRenderer<'a> { | |
&mut self, | ||
grapheme: Grapheme, | ||
mut style: Style, | ||
is_virtual: bool, | ||
last_indent_level: &mut usize, | ||
is_in_indent_area: &mut bool, | ||
position: Position, | ||
|
@@ -405,14 +408,16 @@ impl<'a> TextRenderer<'a> { | |
} | ||
|
||
let width = grapheme.width(); | ||
let space = if is_virtual { " " } else { &self.space }; | ||
let nbsp = if is_virtual { " " } else { &self.nbsp }; | ||
let grapheme = match grapheme { | ||
Grapheme::Tab { width } => { | ||
let grapheme_tab_width = char_to_byte_idx(&self.tab, width); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To properly render tabs you need to add a second field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. I believe its a bit verbose inside the Grapheme::Tab match, but it should now handle the tab rendering There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good now but I would prefer if you could move the if condition outside the match and handle it just like the other variables (so I thought it was quite clean how you did it for the other whitespace chars so it would be great if tab was the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, done. |
||
&self.tab[..grapheme_tab_width] | ||
} | ||
// TODO special rendering for other whitespaces? | ||
Grapheme::Other { ref g } if g == " " => &self.space, | ||
Grapheme::Other { ref g } if g == "\u{00A0}" => &self.nbsp, | ||
Grapheme::Other { ref g } if g == " " => space, | ||
Grapheme::Other { ref g } if g == "\u{00A0}" => nbsp, | ||
Grapheme::Other { ref g } => g, | ||
Grapheme::Newline => &self.newline, | ||
}; | ||
|
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.
Doesn't really make a difference but cloning a
bool
is kind of pointlessThere 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.
Had this as a relic when I was working with &bool