Skip to content

Commit

Permalink
Fix indentation lines (helix-editor#6134) (helix-editor#6136)
Browse files Browse the repository at this point in the history
  • Loading branch information
NomisIV authored and estin committed Mar 4, 2023
1 parent 1a0b6c7 commit 2944b0d
Showing 1 changed file with 11 additions and 8 deletions.
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

0 comments on commit 2944b0d

Please sign in to comment.