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.
05832f9Triton171
helix-core/src/indent.rs+7−1
@@ -662,7 +662,13 @@ pub fn treesitter_indent_for_pos(
662 node = parent;
662 node = parent;
663 first_in_line.pop();
663 first_in_line.pop();
664 } else {
664 } else {
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+ {
665− result.add_line(&indent_for_line_below);
670+ result.add_line(&indent_for_line_below);
671+ }
666 result.add_line(&indent_for_line);
672 result.add_line(&indent_for_line);
667 break;
673 break;
668 }
674 }