File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
app/src/processing/app/ui Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -2136,13 +2136,26 @@ protected void handleCommentUncomment() {
21362136
21372137 // log("Commented: " + commented);
21382138
2139- // This is the line start offset of the first line , which is added to
2140- // all other lines while adding a comment. Required when commenting
2139+ // This is the min line start offset of the selection , which is added to
2140+ // all lines while adding a comment. Required when commenting
21412141 // lines which have uneven whitespaces in the beginning. Makes the
21422142 // commented lines look more uniform.
21432143 int lso = Math .abs (textarea .getLineStartNonWhiteSpaceOffset (startLine )
21442144 - textarea .getLineStartOffset (startLine ));
21452145
2146+ if (!commented ) {
2147+ // get min line start offset of all selected lines
2148+ for (int line = startLine +1 ; line <= stopLine ; line ++) {
2149+ String lineText = textarea .getLineText (line );
2150+ if (lineText .trim ().length () == 0 ) {
2151+ continue ; //ignore blank lines
2152+ }
2153+ int so = Math .abs (textarea .getLineStartNonWhiteSpaceOffset (line )
2154+ - textarea .getLineStartOffset (line ));
2155+ lso = Math .min (lso , so );
2156+ }
2157+ }
2158+
21462159 for (int line = startLine ; line <= stopLine ; line ++) {
21472160 int location = textarea .getLineStartNonWhiteSpaceOffset (line );
21482161 String lineText = textarea .getLineText (line );
You can’t perform that action at this time.
0 commit comments