Skip to content

[FR] Option to disable code reformatting when saving file #1971

Open

Description

@agagalski

Feature Request

Please add option to disable code reformatting when saving file in RIDE.

When .robot file is not initially created in RIDE it usually has different robotframework code formatting/style - indentations, number of spaces, breaks into multiple lines and so on. When such file will be edited in RIDE, structure of the file is changed completely, even if just one value was changed.
As a consequence, such example small change is obscured with massive changes of RIDE and not visible in versioning control systems (i.e. GIT)
Also such reformat makes the code not well readable afterwards in other (text) editors than RIDE.

Activity

  1. added
    enhancement
    on Jul 30, 2019
  2. jasksoren commented on Sep 2, 2019

    @jasksoren

    Hi

    I agree with agagalski.
    We are different users, using RobotFW. We use different editors. I use RIDE.
    But as described above, RIDE is changing the content/syntax in a file, if I just change a single value/argument.

    My test below is tested with:
    robotframework 3.1.2
    robotframework-ride 1.7.4b1
    wxPython 4.0.4

    Create a suite with the content below, and name it "TestSuite_001.txt" (I know the extension is the old .txt)
    Open file with Total Commandor (F3)
    *** Test Cases ***
    TC_001_001
    TC_Log 1 2 3 4 5 6 7

    *** Keywords ***
    TC_Log
    [Arguments] ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6} ${arg7}
    Log ${arg1}
    Log ${arg2}
    Log ${arg3}
    Log ${arg4}
    Log ${arg5}
    Log ${arg6}
    Log ${arg7}

    Open RIDE
    View the content with RIDE on the "Text Edit"-tab
    *** Test Cases ***
    TC_001_001
    TC_Log 1 2 3 4 5 6
    ... 7

    *** Keywords ***
    TC_Log
    [Arguments] ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6}
    ... ${arg7}
    Log ${arg1}
    Log ${arg2}
    Log ${arg3}
    Log ${arg4}
    Log ${arg5}
    Log ${arg6}
    Log ${arg7}

    In the ”Edit”-tab of RIDE, I now change the log-value ”7” to “8” (in TC_001_001) and Saves the file via RIDE. And I then close RIDE.

    Now I open the file with Total Commandor (F3). Now the “…” have been inserted by RIDE (2 places).
    *** Test Cases ***
    TC_001_001
    TC_Log 1 2 3 4 5 6
    ... 8

    *** Keywords ***
    TC_Log
    [Arguments] ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6}
    ... ${arg7}
    Log ${arg1}
    Log ${arg2}
    Log ${arg3}
    Log ${arg4}
    Log ${arg5}
    Log ${arg6}
    Log ${arg7}

    Re-open RIDE
    View the content with RIDE on the "Text Edit"-tab
    *** Test Cases ***
    TC_001_001
    TC_Log 1 2 3 4 5 6
    ... 8

    *** Keywords ***
    TC_Log
    [Arguments] ${arg1} ${arg2} ${arg3} ${arg4} ${arg5} ${arg6}
    ... ${arg7}
    Log ${arg1}
    Log ${arg2}
    Log ${arg3}
    Log ${arg4}
    Log ${arg5}
    Log ${arg6}
    Log ${arg7}

    Since we are many users, that add tests in RobotFW with different editors, I see this “feature” as a blocking issue for us to continue using RIDE. Because, fixing/changing just a single comma or value, will reformat, maybe, several hundreds lines making the commit-diff very difficult to overview.

  3. added
    prio-high
    on Sep 2, 2019
  4. jasksoren commented on Sep 4, 2019

    @jasksoren

    Hi
    @HelioGuilherme66

    I will allow my self to follow up on this issue, since I can see, you have marked it as "prio-high".

    Can you give an estimate of the future handling of this issue, please?

    My colleagues and I shall decide what way to go. I.e. keep using different editors, that suites the users or select one editor, that we all use.

    I prefer using a pure graphical editor, i.e. RIDE. But I know that my colleagues do not prefer this.

    If you prioritize this issue, I could help testing it by installing a developer build from you.

  5. HelioGuilherme66 commented on Sep 4, 2019

    @HelioGuilherme66
    Member

    @jasksoren I cannot give an estimate, because depends on how the code is implemented. I need to study the code, and I suspect that the reformat is done by the robotframework library. If I find a workaround or fix, I'll add to a milestone.

  6. jasksoren commented on Sep 5, 2019

    @jasksoren

    Hi
    @HelioGuilherme66

    Thank you for your answer.

    Whether the reason for the automatic edit is due to RIDE or Robot Framework, I can not say at the moment.

    But as I see it, I can not get rid of the following Error/Warning, which I see in the "Parser Log"-tab on RIDE, unless I do a manually re-format of my files several places.

    Error in file 'C:
    	\...\<filename>.txt': Invalid syntax in test case 'Test xx': Ignoring lines with only continuation marker '...' is deprecated.
    

    The above error comes from the line below, which a collegue has inserted in another editor than RIDE to document the different columns. Total Commandor F3 shows (as expected):

        Comment    #    # 1st party    # 2nd party    # min packets from 1st    # max packets from 1st    # min packets from 2nd    # max packets from 2nd
    

    In RIDE->"Text Edit" it is shown as:

        Comment    #    # 1st party    # 2nd party    # min packets from 1st    # max packets from 1st    # min packets from 2nd
        ...    # max packets from 2nd
    

    And when I save the file, it is saved with the continuation marker (...).
    I close RIDE.
    And opens RIDE again - and then I get the Error/Warning above, due to the new handling in "robotframework/robotframework#3107"

    • See comment "This change affects also cases where there's a comment after ... like"
  7. HelioGuilherme66 commented on Sep 5, 2019

    @HelioGuilherme66
    Member

    The ... issue is related with #1966. Will change robotframework library to increase the column size.

  8. added this to the v1.7.4 milestone on Sep 5, 2019
  9. HelioGuilherme66 commented on Sep 5, 2019

    @HelioGuilherme66
    Member

    Fixed with this commit

  10. agagalski commented on Nov 12, 2019

    @agagalski
    Author

    The ... issue is related with #1966. Will change robotframework library to increase the column size.
    @HelioGuilherme66 Isuue #1966 is just little related to more general issue which I described initially. Probably it can be fixed by introducing option to not perform robot-tidy code clean up at every file save in RIDE. For a start it can be command line option.

    Fixed with this commit
    This commit doesn't fix the issue, please see explanation above. @HelioGuilherme66 can you please reopen, I don't see such option.

  11. HelioGuilherme66 commented on Dec 11, 2019

    @HelioGuilherme66
    Member

    We need to release 1.7.4rc1 soon, so this issue will be targeted in next version.

  12. modified the milestones: Future, v2.0 on Jul 21, 2020
  13. vncs1880 commented on Apr 17, 2021

    @vncs1880

    its awesome except for this issue
    EDIT: v2.0b1

  14. added
    WORK IN PROGRESS
    on Oct 22, 2021
  15. added
    fixed
    and removed
    WORK IN PROGRESS
    on May 2, 2022
  16. HelioGuilherme66 commented on May 2, 2022

    @HelioGuilherme66
    Member

    @agagalski @jasksoren @yncs1880
    You can now try a fix for this on current master branch.

  17. agagalski commented on May 3, 2022

    @agagalski
    Author

    Thanks for fix / enhancement!
    Currently I stopped automating with robot (temporary I hope). I quickly installed v2.0b2.dev6 - it looks completely different than robot from 3 years ago when I reported this issue., so it's hard for me to test.
    On example file, even though I have option 'Reformat' deselected (in Saving card), after I press ctr+s code is automaticaly reformatted still (or even after opening the file?).

    example diff (I just added space):
    image

  18. removed
    fixed
    on May 3, 2022
  19. modified the milestones: v2.0, v2.1 on Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementprio-high

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions