robotframework-tidy icon indicating copy to clipboard operation
robotframework-tidy copied to clipboard

Comments under "Run Keywords" inappropriately moved around

Open gohierf opened this issue 8 months ago • 1 comments

I often use the Run Keywords methods for Setup or Teardown, sometimes I need to disable part of the setup/teardown, and I like to do this by just commenting the line(s) to disable.

Unfortunately, this doesn't work well with tidy... As the commented line is moved above the keyword/setting call.

Not sure which rule(s) is/are involved. But it seems related to keyword with sub-indentation.

For instance, in the example below, tidy does not change the location of message B or message 2, which is what I am expecting. However, the commented No Operation is moved around because it is within Run Keywords.

This looks like a bug/undesired behavior, but it might be a question of configuring correctly one or more rules... Let me know!

Example code

*** Settings ***
Documentation       Example of comments being moved around.

Suite Teardown      Run Keywords
...                     No Operation
# ...                     No Operation
...                     No Operation
Test Setup          Log Many
...                     message A
# ...                     message B
...                     message C


*** Test Cases ***
My test with 2 ident comment
    Run Keywords
    ...    No Operation
    # ...    No Operation
    ...    No Operation

My test with comment
    Log Many
    ...    message 1
    # ...    message 2
    ...    message 3

Desired

image

After formatting

image

gohierf avatar Jun 10 '24 14:06 gohierf