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: indent guides out of bound. #3105

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
18 changes: 12 additions & 6 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,18 @@ impl EditorView {
}

for i in 0..(indent_level / tab_width as u16) {
surface.set_string(
viewport.x + (i * tab_width as u16) - offset.col as u16,
viewport.y + line,
&indent_guide_char,
indent_style,
);
let visual_x = i * tab_width as u16;
let out_of_bounds =
visual_x < offset.col as u16 || visual_x >= viewport.width + offset.col as u16;

if !out_of_bounds {
surface.set_string(
viewport.x + visual_x - offset.col as u16,
viewport.y + line,
&indent_guide_char,
indent_style,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think.. once it goes out_of_bounds the next indent_level can not suddenly be inside again.. or ??

Suggested change
}
} else {
break;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks , i test this, If use break, the indents of the next level will not be rendered.

}
};

Expand Down