on master help sign in
Fix a bug that caused the indent for the line below to also be added in rare cases at the beginning of a file.
commit05832f90cbff18a8d8f0ccb6680cd74e19c75378 authorTriton171 <triton0171@gmail.com> dateThu 11 Aug 2022, 10:56 (4 years ago) parent1ceecbd
1 file changed+7−1
helix-core/src/indent.rs+7−1
helix-core/src/indent.rs+7−1
@@ -662,7 +662,13 @@ pub fn treesitter_indent_for_pos(
662662 node = parent;
663663 first_in_line.pop();
664664 } else {
665− result.add_line(&indent_for_line_below);
665+ // Only add the indentation for the line below if that line
666+ // is not after the line that the indentation is calculated for.
667+ if (node.start_position().row < line)
668+ || (new_line && node.start_position().row == line && node.start_byte() < byte_pos)
669+ {
670+ result.add_line(&indent_for_line_below);
671+ }
666672 result.add_line(&indent_for_line);
667673 break;
668674 }