…and if the current indentation is inconsistent, just pick one. It would be way beyond the scope of this request to, for example, figure out the indentation around the current cursor position. In fact I would say that would be too complex, and a bad (inconsistent) user experience.
Bonus $50 for showing the status of the plugin in the status bar, for example: the plugin successfully detected the indentation settings the plugin successfully detected at least the big two settings (expand tabs and spaces per indent), and guessed at one or more of the remaining settings the indentation of the file is inconsistent; the plugin picked one the plugin just used the current NetBeans indentation settings (for example the file is empty and has no indentation yet) > On Dec 12, 2019, at 9:24 AM, Alvin Thompson <[email protected]> wrote: > > Agree. The only settings I really care about it detecting are "expand tabs to > spaces", "spaces per indent", and "continuation indentation". Bonus points > for "label indentation" (and "absolute label indentation"). > > >> On Dec 11, 2019, at 8:51 PM, Tim Boudreau <[email protected] >> <mailto:[email protected]>> wrote: >> >> public class Bar { >>> public int wazoo; >>> } >>> >>> There is enough Information to know that the standard indentation is 1 >>> tab, but you don’t have enough information to know what the label >>> indentation or continuation indentation should be. >> >> >> The hard part is dealing with ambiguity. Real sources with a long history >> may contain a mix of tabs and spaces, different indent levels etc. >> >> Not to mention more esoteric things - for example, spaces inside >> parentheses and how that deals with nested parentheses - e.g. “foo( bar( >> baz ))” good and “foo( bar( baz ) )” bad (I have yet to find an incantation >> off NetBeans’s own formatter that gets this right. >> >> If you just want to detect tabs or spaces and how many, that might be a >> $200 job. For detecting everything and not getting at least one thing >> embarrassingly wrong, likely $100k is not enough. >> >> So if someone does this, choose carefully what problems you DON’T want to >> solve, or plan on going down an infinitely deep rabbit hole. >> >> -Tim >> >>> >> >> >> The plugin would need to fall back to the NetBeans prefs to "figure out" >>> sensible values for these. >>> >>> While not rocket science, this isn’t entirely straightforward because you >>> can’t just copy the NetBeans prefs. Continuing the example above, if >>> NetBeans specifies that the standard indentation is 2 spaces and the >>> continuation indentation is also 2 spaces, you can figure out that the >>> continuation indentation for this file should be one tab. If in NetBeans >>> the continuation indentation was 4 spaces (twice the standard indentation), >>> the continuation indentation for this file should be 2 tabs. >>> >>> -Alvin >>> >>> -- >> http://timboudreau.com <http://timboudreau.com/>
