Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format on save #34

Open
SamuFinnos opened this issue Mar 16, 2021 · 13 comments
Open

Format on save #34

SamuFinnos opened this issue Mar 16, 2021 · 13 comments
Assignees

Comments

@SamuFinnos
Copy link

Pretty self explanatory but would be an amazing feature.

@Barteling
Copy link
Collaborator

I consider this, on the other hand this might also be something which comes with STweep CLI. See : #32

@GISED-Link
Copy link

This could be a good idea. Since I have a bug on a specific section of my code, I would prefer to have first a flag/decorator that can stop STweep from running on a given set of lines (I haven't found anything on the documentation). So if STweep still has trouble with some lines of code, I could ignore them until the bug is fixed 👍🏻

@HAHermsen
Copy link

IMHO this is not such a good idea as I have the autosave feature anabled and the project I am working on is currently 1200+ (and growing) objects. I'd rather see STweep either be enabled by the user or by some agent script on commit via webhooks.

@nbuchele-KAMP
Copy link

I agree with @HAHermsen. Instead, I'd rather see a format on Build. Builds happen with less frequently than saves, so it wouldn't be overly intrusive. You might need to add some sort of flag to track if a file has already been formatted and has not been changed. Then you wouldn't have to waste time formatting files that don't need it.

@Rednas83
Copy link

I would love to have this feature too.

Why not make it as a configurable option?

Something like:
image

@slimeth
Copy link

slimeth commented Apr 5, 2023

What's the status on this feature?

@HAHermsen
Copy link

Guessing from the previous replies it's under consideration for STweep CLI.

Besides that I strongly disagree with this implementing this option in any user interactive GUI. A user should decide when to apply the STweep rather then run it automatically after each SAVE. This makes no sense and hinders any normal workflow significantly.

@slimeth
Copy link

slimeth commented Apr 6, 2023

@HAHermsen I agree with you that the user should be able to decide if the feature is enabled or not. Certain users might strongly disagree with this feature while others would strongly benefit from a well formatted code base at every commit. Because it can quickly happen that someone forgets to format a file before a commit by accident.

@HAHermsen
Copy link

If you want to enforce a STweep action after a commit, one should use a webhook. Besides that, a commit is not equal to a save action. Therefore I seriously doubt the usefulness of a "STweep on Save".
But a "STweep on Commit" webhook however is something I'd like to see so that everyone's code at least is styled the same. In order to enable a "STweep on Commit" under CODESYS, I asked for Python API acces in STweep, while STweep CLI for TwinCAT already is capable of being triggered via webooks. Check it out, you probably already can achieve what you want to use.

I hope this helps.

@Rednas83
Copy link

Rednas83 commented Apr 6, 2023

In vscode format on save works perfectly. I don't see why it wouldn't work.
image

Adding formatting to your pipeline is of course also a very good practice.

Perhaps it's better to create an issue for vs for this?

@slimeth
Copy link

slimeth commented Apr 13, 2023

What I would like to avoid is that the local and remote repository commits differ after every push which would happen with the proposed webhook. I would like to use the pipeline rather to verify that the code is properly formatted before every merge and otherwise block it until it is resolved.

The format on save in vs code is great, unfortunately I'm usually using the TwinCAT XAE Shell for the PLC programming. So I would love to see a similar feature in the STweep TwinCAT XAE Shell plugin.

@Barteling
Copy link
Collaborator

I still have this option on the list, but i dont expect it on short notice,
i do know several stweepers using stweep CLI in combination with a pre commit hook.
See also https://cookncode.com/twincat/2022/04/14/pre-commit.html

@MEbneter
Copy link

Would like to see that too. (I was send here by your friendly support after asking about 'formatt on save')
@Barteling ,thats a good tip. I will try that out and maybe use it until this feature is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants