on master help sign in
Fix indentation lines (#6134) (#6136)
commitc082ef28632e8a92a91926f3714808942238098b authorNomisIV <47303199+NomisIV@users.noreply.github.com> dateWed 1 Mar 2023, 07:45 (4 years ago) parent27211ab
1 file changed+11−8
helix-term/src/ui/document.rs+11−8
helix-term/src/ui/document.rs+11−8
@@ -322,7 +322,7 @@ pub struct TextRenderer<'a> {
322322 pub nbsp: String,
323323 pub space: String,
324324 pub tab: String,
325− pub tab_width: u16,
325+ pub indent_width: u16,
326326 pub starting_indent: usize,
327327 pub draw_indent_guides: bool,
328328 pub col_offset: usize,
@@ -370,16 +370,19 @@ impl<'a> TextRenderer<'a> {
370370
371371 let text_style = theme.get("ui.text");
372372
373+ let indent_width = doc.indent_style.indent_width(tab_width) as u16;
374+
373375 TextRenderer {
374376 surface,
375377 indent_guide_char: editor_config.indent_guides.character.into(),
376378 newline,
377379 nbsp,
378380 space,
379− tab_width: tab_width as u16,
380381 tab,
381382 whitespace_style: theme.get("ui.virtual.whitespace"),
382− starting_indent: (col_offset / tab_width)
383+ indent_width,
384+ starting_indent: col_offset / indent_width as usize
385+ + (col_offset % indent_width as usize != 0) as usize
383386 + editor_config.indent_guides.skip_levels as usize,
384387 indent_guide_style: text_style.patch(
385388 theme
@@ -461,14 +464,14 @@ impl<'a> TextRenderer<'a> {
461464 // Don't draw indent guides outside of view
462465 let end_indent = min(
463466 indent_level,
464− // Add tab_width - 1 to round up, since the first visible
467+ // Add indent_width - 1 to round up, since the first visible
465468 // indent might be a bit after offset.col
466− self.col_offset + self.viewport.width as usize + (self.tab_width - 1) as usize,
467− ) / self.tab_width as usize;
469+ self.col_offset + self.viewport.width as usize + (self.indent_width as usize - 1),
470+ ) / self.indent_width as usize;
468471
469472 for i in self.starting_indent..end_indent {
470− let x =
471− (self.viewport.x as usize + (i * self.tab_width as usize) - self.col_offset) as u16;
473+ let x = (self.viewport.x as usize + (i * self.indent_width as usize) - self.col_offset)
474+ as u16;
472475 let y = self.viewport.y + row;
473476 debug_assert!(self.surface.in_bounds(x, y));
474477 self.surface