This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE 7.1 (Build 201112071828) Operating System = Linux version 3.0.0-14-generic-pae running on i386 Java; VM; Vendor = 1.6.0_23 Runtime = OpenJDK Client VM 20.0-b11 Example: <?php function funct() { $a = ''; // comment } ?> Source->Format (Alt-Shift-F) will not indent the comment line unless it is already off the left edge. Initial formats of existing code since upgrading to 7.1 from 7.0x seem to have moved some (or all ?) comments to the left edge. Am having to fix each one by indenting manually then formatting.
Sorry, but it's a feature. It's the same behavior as is for Java files. Line comments which are at the start of the line, are not indented by formatter.
More on this one ... If the formatter can't format due to error in code, it will remove all formatting. This places everything at column one. If you now fix the code (eg put in the missing }) it formats again, but now all comments are left at column one due to the `feature` mentioned earlier. The only way out is to undo the format before making the fix, or manually move all your comments off the left column and format again. I guess it would be nice if somehow the formatter could `remember` which lines were indented when it removes all formatting and restore them.
Such a behavior may be an enhancement, definitely not a defect. But the effort to make it is much bigger than a benefit from the result.
I hear you re the work/benefit tradeoff, but it is these little things that drive one nuts (there are of course a few of them). FWIW: Perhaps the answer is not to look at what the formatter is not doing, but what it does ... On being unable to format: Curently: All code is left unindented. Undo gets previous indenting back, but focus goes to (near?) top of file. This is a PITA as you have now lost your position, which is often where the error was created. Suggest: Restore to pre-formatting state, including curser position. Throw a warning (dialogue?). This would fix BOTH problems! Thoughts?
I'm afraid that that "back" action is not handled by PHP itself, but by the upper infrastructure...so we can't restore the previous caret position.
Apologies for laboring the point (last shot). Maybe it is nothing like what it appears to me dumb end user! After a ~successful~ format the curser (same as caret?) is placed where it was before .. which suggest PHP may be able to place the curser. If PHP can indeed somehow place curser ... So leave out the undo. If the formatter kept a copy of the original (and curser position) and simply wrote the original as output on failure, and set the curser ... ?? and released it on success. Not so simple?
One more thought .. The editor knows when there is an error condition, it indicates red markers in the right of the screen. Can the formatter detect the error condition and simply do nothing, similar to how highlighting refuses to work?
For mine you can close this one. I see (finally!) the answer is use c-style comments if you want them always to indent to the surrounding code. The question remains re formatter removing all indentation when it encounters an error. Should I keep that alive by opening a new report?