rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 302 forks source link

Request: Trim trailing whitespace before exporting #3756

Open cxw42 opened 6 years ago

cxw42 commented 6 years ago

I am using manual source control (not Rubberduck integrated control). Rubberduck | Tools | Export Active Project makes that very easy --- I just export into my working directory, then git commit -a in my terminal. I would like to request an option to remove trailing whitespace from any exported file before exporting. That would reduce spurious changes in a commit, which I have sometimes seen in the past when exporting manually. Also, I wouldn't get ugly red blocks in the git diff output :) .

My preference would be to also modify the VBA project to remove the trailing whitespace. However, omitting trailing whitespace from the exported files, without touching the project, would also satisfy my use case.

Thanks for considering this request!

Rubberduck version: Version 2.1.1.2532 Operating System: Microsoft Windows NT 6.2.9200.0, x64

retailcoder commented 6 years ago

FWIW The VBE isn't making this simple - it tends to arbitrarily add empty lines on import; we're already working around a VBE bug that inserts an empty line at the top of a module when importing a UserForm. This is about arbitrary empty lines at the bottom of modules, correct?

Vogel612 commented 6 years ago

@retailcoder traditionally that also refers to syntactically unnecessary whitespace at the end of lines

retailcoder commented 6 years ago

Then we're no longer talking about using the VBIDE API's Export method at all, we're looking at an full-on rewrite of the API feature... and I think I like it. Our wrappers can do it.

Hosch250 commented 6 years ago

We rolled our own Print command, so why not?

cxw42 commented 6 years ago

@Vogel612 @retailcoder Yes, I was thinking of extra whitespace at the end of lines, including whitespace on otherwise-blank lines.

I have noticed the extra bottom lines appearing on manual export, and chopping those would be a nice bonus. It would keep my vi modelines from being pushed out of detection range :) . (Edit to explain: my workaround for this in the past has been to copy a whole module into vi, do s/\s\+$//, and then copy and paste it back into the VBE. Ugh. But that's why I care about vi modelines.)