anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

[Feature] Run Code Cleanup on Staged Files in the Active Project #542

Open cegekaJG opened 6 months ago

cegekaJG commented 6 months ago

I believe the ability to run Code Cleanup on staged files only is better than the current command that cleans up all uncommitted files for two reasons:

1) It's possible to exclude dirty files by leaving them unstaged 2) Any changes made to a file by the extension will be unstaged and thus remain separate from your own changes

I am not a fan of cleaning up unstaged files, because you can't keep your own and the automated changes apart. Being able to clean up all changed files is good, but it's not very useful if you can't revert the cleanup easily. Furthermore, the action should only be possible if none of the staged files have additional, unstaged changes - this ensures any change performed by the command can be observed in isolation, and reverted.

anzwdev commented 6 months ago

It can be added, but I don't think that it will be much better than running cleanup on uncommited files.

It does not matter if you run it on uncommited or staged files, both versions expect people to always remember to run command before commit and we are just humans, we are forgetting things or are distracted sometimes. If you forget to run it, you may never fix that one or two files that really need cleanup.

Maybe there is a better way to achieve what you want? What is your scenario here, why do you want to cleanup just a few files in the project? Is it because you have big solution and running command on all files is slow or is it something else?

I don't know yet if it is possible, but maybe "run on files changes in the current branch only" will be better?

cegekaJG commented 6 months ago

Ideally, I want to always clean up files before they are committed, but I also want a way to tell what changes the cleanup made. As for why I would want only clean up select files, I might be working on an active legacy project that hasn't been cleaned up at all or just rarely. If I were to create a new object and edit a line in an older object, the command would clean both files. Which isn't a bad thing in isolation, but with other people actively changing the same file, a cleanup could cause lots of conflicts that cost time.