on master help sign in
Fix indentation lines (#6134) (#6136)
c082ef2NomisIV
helix-term/src/ui/document.rs+11−8
@@ -322,7 +322,7 @@ pub struct TextRenderer<'a> {
322 pub nbsp: String,
322 pub nbsp: String,
323 pub space: String,
323 pub space: String,
324 pub tab: String,
324 pub tab: String,
325− pub tab_width: u16,
325+ pub indent_width: u16,
326 pub starting_indent: usize,
326 pub starting_indent: usize,
327 pub draw_indent_guides: bool,
327 pub draw_indent_guides: bool,
328 pub col_offset: usize,
328 pub col_offset: usize,
@@ -370,16 +370,19 @@ impl<'a> TextRenderer<'a> {
370
370
371 let text_style = theme.get("ui.text");
371 let text_style = theme.get("ui.text");
372
372
373+ let indent_width = doc.indent_style.indent_width(tab_width) as u16;
374+
373 TextRenderer {
375 TextRenderer {
374 surface,
376 surface,
375 indent_guide_char: editor_config.indent_guides.character.into(),
377 indent_guide_char: editor_config.indent_guides.character.into(),
376 newline,
378 newline,
377 nbsp,
379 nbsp,
378 space,
380 space,
379− tab_width: tab_width as u16,
380 tab,
381 tab,
381 whitespace_style: theme.get("ui.virtual.whitespace"),
382 whitespace_style: theme.get("ui.virtual.whitespace"),
383+ indent_width,
382− starting_indent: (col_offset / tab_width)
384+ starting_indent: col_offset / indent_width as usize
385+ + (col_offset % indent_width as usize != 0) as usize
383 + editor_config.indent_guides.skip_levels as usize,
386 + editor_config.indent_guides.skip_levels as usize,
384 indent_guide_style: text_style.patch(
387 indent_guide_style: text_style.patch(
385 theme
388 theme
@@ -461,14 +464,14 @@ impl<'a> TextRenderer<'a> {
461 // Don't draw indent guides outside of view
464 // Don't draw indent guides outside of view
462 let end_indent = min(
465 let end_indent = min(
463 indent_level,
466 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
465 // indent might be a bit after offset.col
468 // indent might be a bit after offset.col
466− self.col_offset + self.viewport.width as usize + (self.tab_width - 1) as usize,
469+ self.col_offset + self.viewport.width as usize + (self.indent_width as usize - 1),
467− ) / self.tab_width as usize;
470+ ) / self.indent_width as usize;
468
471
469 for i in self.starting_indent..end_indent {
472 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;
472 let y = self.viewport.y + row;
475 let y = self.viewport.y + row;
473 debug_assert!(self.surface.in_bounds(x, y));
476 debug_assert!(self.surface.in_bounds(x, y));
474 self.surface
477 self.surface