[FIX] tests: don't count EOL chars when checking remaining line space

This commit fixes a bug in the `check_early_line_breaks` test that would
systematically consider the `\n` character as being part of the line,
hence counting it when computing the line length.

closes odoo/documentation#12268

X-original-commit: e1a8a55c4f
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv)
2025-03-05 12:52:36 +00:00
parent ad80ee8d29
commit a69a838df1

View File

@@ -139,12 +139,13 @@ def check_early_line_breaks(file, lines, options=None):
for lno, line in enumerate(lines):
if lno + 1 < len(lines):
next_line = lines[lno + 1]
if (is_valid_line(line, ('+', '|'))
if (
is_valid_line(line, ('+', '|'))
and is_valid_line(next_line, ('+', '|', '- ', '* ', '#. '))
):
current_line_remaining_space = options.max_line_length - len(line)
current_line_remaining_space = options.max_line_length - len(line.rstrip())
next_line_first_word = get_next_line_first_word(next_line).rstrip()
if current_line_remaining_space > len(next_line_first_word):
if current_line_remaining_space >= len(next_line_first_word + ' '):
yield lno + 1, f"consider moving \"{next_line_first_word}\" to line {lno + 1}"