[postgis-devel] Code formatting digging in

Regina Obe lr at pcorp.us
Sat Mar 3 10:50:51 PST 2018


>> Sandro, it's not how editorconfig works. What it does is setting editor's tab stops width and type of characters to generate on pressing tab on the start of the line.
>> Think of it as of a replacement for vim's ModeLines, that used to be /* vim: set ts=8 sw=4 tw=0 noet : */.

 
>> It's going to auto-set the cursor to right spot for the newly written code after typing {<enter>, but not perform a reflow and fix a mismatch in indentation (error in 


>> level, not type) of old code.


> Not sure how it works in other editors but I think in VS Code it rewrites the file cause if say there is no new line at the end of the file > where we dictate there should, it changes it.

>It also trims spaces in areas of code I never touched.  I see this on the commit diff.

I think I may have been mistaken in my prior comments about VS Code.  I put it in a project that has spaces for indentation that I wanted to convert to tabs, and you are right, only seems to correct the tab/space formatting in the area where I am changing the code.

However if there is a new line rule, that does take affect right after I save the file.  I think that's why I thought it always reformatted.
I haven't confirmed the trimming white space if that always happens on save or just in area I am editing. I suspect that happens everywhere which is why I thought it always applied all rules.

Though if the code was formatted right to begin with would be a non-issue.

Doesn't even Github nowadays internally support .editorconfig https://stackoverflow.com/questions/33892410/editorconfig-file-in-github/  (though sounds like it may not support all featues), so if you using GitHub browsing as your editor of choice, it will format it right anyway?

Anyway I thought strk's integration of .editorconfig into the project was brilliant.  I never had to remember if it's tab or space or whatever and didn't have an extra formatting step to contend with.  To Bborie's point about editors, I think most editors nowadays support editorconfig plugin, that it should be a non-issue regardless of editor you are using.

https://github.com/editorconfig/

>From my perspective, the 3 most important things about consistent convention are:

1) Tab or Space for indenting (and if space how many spaces)
2) LF or CRLF for line end
3) character set (this has bitten us in the past with people editing the NEWS file and changing the encoding to Latin or something and screwing up people's names)


Everything else, honestly I could care less about.  The hassle of worrying about the other minutia is more stressful than whatever perceived problem such things cause and the possible corruption of code trying to fix it would cause.
If you are that bothered by it, I would recommend getting your doctor to prescribe you some Prozac. It may help calm your obsessiveness.

Thanks,
Regina













More information about the postgis-devel mailing list