Community
Participate
Working Groups
Created attachment 177279 [details] Toggle Comment Empty line patch Example: //foo //bar Selecting the three lines and using "Toggle Comment" will result in ////foo // ////bar I think it should instead remove the comments.
Two suggestions: - use text.trim().length() == 0 instead of the regular expression. - move the test for empty lines before the TextUtilities.indexOf() The method should also not return true when the region contains only empty lines.
Created attachment 177382 [details] Toggle Comment Empty line patch 2 Thanks for the suggestions.
It is now no longer possible to add comments to a block of empty lines. There is no need for a method isBlockEmpty(). Just make sure isBlockCommented() does not return true when the selection contains only empty lines. I also don't understand the special case i != endLine in isBlockCommented(). While testing this I found a strange behavior: If the last line in the selection is completely empty (no space, etc.) it is _not_ commented. The same behavior shows the Java Editor which makes me think it is a platform issue in TextViewer.shift(). BTW, it would be good to have a few JUnit tests for this feature. You could take the AddBlockCommentTest as a boilerplate.
I committed the last patch with a few modifications to re-enable commenting of empty lines.
*** cdt cvs genie on behalf of aleherbau *** Bug 323456 - Uncomment code separated by empty lines Patch from Marc-Andre Laperle [*] ToggleCommentAction.java 1.16 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java?root=Tools_Project&r1=1.15&r2=1.16