Skip to content
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

Fix indentation lines (#6134) #6136

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions helix-term/src/ui/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub struct TextRenderer<'a> {
pub nbsp: String,
pub space: String,
pub tab: String,
pub tab_width: u16,
pub indent_width: u16,
pub starting_indent: usize,
pub draw_indent_guides: bool,
pub col_offset: usize,
Expand Down Expand Up @@ -370,16 +370,19 @@ impl<'a> TextRenderer<'a> {

let text_style = theme.get("ui.text");

let indent_width = doc.indent_style.indent_width(tab_width) as u16;

TextRenderer {
surface,
indent_guide_char: editor_config.indent_guides.character.into(),
newline,
nbsp,
space,
tab_width: tab_width as u16,
tab,
whitespace_style: theme.get("ui.virtual.whitespace"),
starting_indent: (col_offset / tab_width)
indent_width,
starting_indent: col_offset / indent_width as usize
+ (col_offset % indent_width as usize != 0) as usize
+ editor_config.indent_guides.skip_levels as usize,
indent_guide_style: text_style.patch(
theme
Expand Down Expand Up @@ -461,14 +464,14 @@ impl<'a> TextRenderer<'a> {
// Don't draw indent guides outside of view
let end_indent = min(
indent_level,
// Add tab_width - 1 to round up, since the first visible
// Add indent_width - 1 to round up, since the first visible
// indent might be a bit after offset.col
self.col_offset + self.viewport.width as usize + (self.tab_width - 1) as usize,
) / self.tab_width as usize;
self.col_offset + self.viewport.width as usize + (self.indent_width as usize - 1),
) / self.indent_width as usize;

for i in self.starting_indent..end_indent {
let x =
(self.viewport.x as usize + (i * self.tab_width as usize) - self.col_offset) as u16;
let x = (self.viewport.x as usize + (i * self.indent_width as usize) - self.col_offset)
as u16;
let y = self.viewport.y + row;
debug_assert!(self.surface.in_bounds(x, y));
self.surface
Expand Down