Fix a bug that caused the indent for the line below to also be added in rare cases at the beginning of a file.

pull/4202/head
Triton171 2 years ago committed by Blaž Hrastnik
parent 1ceecbd062
commit 05832f90cb

@ -662,7 +662,13 @@ pub fn treesitter_indent_for_pos(
node = parent; node = parent;
first_in_line.pop(); first_in_line.pop();
} else { } else {
// Only add the indentation for the line below if that line
// is not after the line that the indentation is calculated for.
if (node.start_position().row < line)
|| (new_line && node.start_position().row == line && node.start_byte() < byte_pos)
{
result.add_line(&indent_for_line_below); result.add_line(&indent_for_line_below);
}
result.add_line(&indent_for_line); result.add_line(&indent_for_line);
break; break;
} }

Loading…
Cancel
Save