Skip to content

Commit 9f421b7

Browse files
committed
[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 #12270 X-original-commit: e1a8a55 Signed-off-by: Antoine Vandevenne (anv) <[email protected]>
1 parent 70d20fc commit 9f421b7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/checkers/rst_style.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ def get_next_line_first_word(next_line_):
139139
for lno, line in enumerate(lines):
140140
if lno + 1 < len(lines):
141141
next_line = lines[lno + 1]
142-
if (is_valid_line(line, ('+', '|'))
142+
if (
143+
is_valid_line(line, ('+', '|'))
143144
and is_valid_line(next_line, ('+', '|', '- ', '* ', '#. '))
144145
):
145-
current_line_remaining_space = options.max_line_length - len(line)
146+
current_line_remaining_space = options.max_line_length - len(line.rstrip())
146147
next_line_first_word = get_next_line_first_word(next_line).rstrip()
147-
if current_line_remaining_space > len(next_line_first_word):
148+
if current_line_remaining_space >= len(next_line_first_word + ' '):
148149
yield lno + 1, f"consider moving \"{next_line_first_word}\" to line {lno + 1}"
149150

150151

0 commit comments

Comments
 (0)