RIDE icon indicating copy to clipboard operation
RIDE copied to clipboard

[FR] Option to disable code reformatting when saving file

Open agagalski opened this issue 5 years ago • 11 comments

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.

agagalski avatar Jul 30 '19 09:07 agagalski

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.

jasksoren avatar Sep 02 '19 10:09 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.

jasksoren avatar Sep 04 '19 07:09 jasksoren

@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.

HelioGuilherme66 avatar Sep 04 '19 16:09 HelioGuilherme66

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 "https://github.com/robotframework/robotframework/issues/3107"

  • See comment "This change affects also cases where there's a comment after ... like"

jasksoren avatar Sep 05 '19 08:09 jasksoren

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

HelioGuilherme66 avatar Sep 05 '19 18:09 HelioGuilherme66

Fixed with this commit

HelioGuilherme66 avatar Sep 05 '19 19:09 HelioGuilherme66

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.

agagalski avatar Nov 12 '19 17:11 agagalski

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

HelioGuilherme66 avatar Dec 11 '19 11:12 HelioGuilherme66

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

vncs1880 avatar Apr 17 '21 15:04 vncs1880

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

HelioGuilherme66 avatar May 02 '22 19:05 HelioGuilherme66

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

agagalski avatar May 03 '22 09:05 agagalski