Skip to content

Commit 33d46c0

Browse files
authored
Fix separator for BREAK and CONTINUE in infline IF (#423)
1 parent 2f983ea commit 33d46c0

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

docs/releasenotes/3.3.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ English language is supported by default.
3333

3434
Fixes
3535
------
36-
* Add missing ``--skip-comments`` option (#418)
36+
* Added missing ``--skip-comments`` option (#418)
37+
* ``CONTINUE`` and ``BREAK`` statements in inline IFs are now intended correctly (#422)
3738

3839
Other
3940
-----

robotidy/transformers/NormalizeSeparators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def visit_Comment(self, node): # noqa
144144
return self.visit_Statement(node)
145145

146146
def is_keyword_inside_inline_if(self, node):
147-
return self.is_inline and (
148-
isinstance(node, KeywordCall) or ReturnStatement and isinstance(node, ReturnStatement)
149-
)
147+
return self.is_inline and not isinstance(node, InlineIfHeader)
150148

151149
@skip_if_disabled
152150
def visit_Statement(self, statement): # noqa

tests/atest/transformers/NormalizeSeparators/expected/inline_if_2indent_2spaces.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Simple IF
33
IF $condition1 Keyword argument
44
IF $condition1 RETURN
5+
IF $condition1 CONTINUE
6+
IF $condition BREAK
57

68
Nested IF
79
FOR ${var} IN RANGE 10

tests/atest/transformers/NormalizeSeparators/expected/inline_if_2indent_4spaces.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Simple IF
33
IF $condition1 Keyword argument
44
IF $condition1 RETURN
5+
IF $condition1 CONTINUE
6+
IF $condition BREAK
57

68
Nested IF
79
FOR ${var} IN RANGE 10

tests/atest/transformers/NormalizeSeparators/expected/inline_if_4indent_2spaces.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Simple IF
33
IF $condition1 Keyword argument
44
IF $condition1 RETURN
5+
IF $condition1 CONTINUE
6+
IF $condition BREAK
57

68
Nested IF
79
FOR ${var} IN RANGE 10

tests/atest/transformers/NormalizeSeparators/source/inline_if.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Simple IF
33
IF $condition1 Keyword argument
44
IF $condition1 RETURN
5+
IF $condition1 CONTINUE
6+
IF $condition BREAK
57

68
Nested IF
79
FOR ${var} IN RANGE 10

0 commit comments

Comments
 (0)