notskm / vscode-clang-tidy

MIT License
48 stars 26 forks source link

Feature Request: fix on save #9

Closed nekko1119 closed 4 years ago

nekko1119 commented 4 years ago

I want to fix auto fixable clang-tidy's checks on save if "editor.formatOnSave" is true or "clang-tidy.autoFixOnSave" (setting name is tentative) is true.

notskm commented 4 years ago

Sounds easy enough. clang-tidy has a flag for that. I'm a bit busy at the moment, but I might take a look sometime within a week.

nekko1119 commented 4 years ago

Thank you for your reply. I'm looking forward to it ! 😄

notskm commented 4 years ago

Currently, the extension will launch an instance of clang-tidy whenever asked, even if it's already running. This is a problem because it can cause fixes to be applied multiple times, producing invalid code.

Additionally, having the extension run clang-tidy --fix results in diagnostics being reported that shouldn't be.

This feature is a bit more complex than I thought initially. It shouldn't be too hard, but I just don't have the time or energy right now. Pull requests are welcome if you'd like to take a shot at it.

nekko1119 commented 4 years ago

I see. I'm not used to writing vscode extensions, but I'll try it. 💪 Thanks.

ErwanDL commented 4 years ago

This would be a great addition the the extension indeed ! @nekko1119 have you had time to work on it ? If not, I could also try to give it a shot.

notskm commented 4 years ago

I recently fixed #12, which also means we should only have 1 instance of clang-tidy running at time now. Adding a clang-tidy.fix-on-save option should be trivial, fingers crossed. That being said, I wonder if using quick fixes would be a better option.

I'll take some time this week to weigh both options.