From 953a8eab50c88a2b5821ccf9e5aa17dd6cc7a9fc Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Wed, 5 Mar 2025 12:52:36 +0000 Subject: [PATCH] [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#12273 X-original-commit: e1a8a55c4f4f4a58eedb776b4d0a0f324b8a048a Signed-off-by: Antoine Vandevenne (anv) --- tests/checkers/rst_style.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/checkers/rst_style.py b/tests/checkers/rst_style.py index c8ad549d8..050e57329 100644 --- a/tests/checkers/rst_style.py +++ b/tests/checkers/rst_style.py @@ -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}"