mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 10:30:44 +01:00
fix comment/uncomment to only uncomment when all are commented out
This commit is contained in:
@@ -1176,13 +1176,21 @@ public class Editor extends JFrame {
|
||||
}
|
||||
|
||||
// If the text is empty, ignore the user.
|
||||
// Also ensure that all lines are commented (not just the first)
|
||||
// when determining whether to comment or uncomment.
|
||||
int length = textarea.getDocumentLength();
|
||||
int pos = textarea.getLineStartOffset(startLine);
|
||||
if (pos + 2 > length) return;
|
||||
// Check the first two characters to see if it's already a comment.
|
||||
String begin = textarea.getText(pos, 2);
|
||||
//System.out.println("begin is '" + begin + "'");
|
||||
boolean commented = begin.equals("//");
|
||||
boolean commented = true;
|
||||
for (int i = startLine; commented && (i <= stopLine); i++) {
|
||||
int pos = textarea.getLineStartOffset(i);
|
||||
if (pos + 2 > length) {
|
||||
commented = false;
|
||||
} else {
|
||||
// Check the first two characters to see if it's already a comment.
|
||||
String begin = textarea.getText(pos, 2);
|
||||
//System.out.println("begin is '" + begin + "'");
|
||||
commented = begin.equals("//");
|
||||
}
|
||||
}
|
||||
|
||||
for (int line = startLine; line <= stopLine; line++) {
|
||||
int location = textarea.getLineStartOffset(line);
|
||||
|
||||
5
todo.txt
5
todo.txt
@@ -1,6 +1,8 @@
|
||||
0146 pde
|
||||
X fix problem with comment/uncomment and indent/outdent
|
||||
X when no selection, and on the first pos of the line
|
||||
X on comment/uncomment, need to check if *all* lines are commented
|
||||
X otherwise should be comment (never uncomment unless all selected)
|
||||
|
||||
runner
|
||||
X use debugger to get better exceptions
|
||||
@@ -14,9 +16,6 @@ X probably b/c not catching ex inside the run() method
|
||||
X getMessage() not sufficient for exceptions coming through
|
||||
X get actual message text, plus the exception itself
|
||||
|
||||
_ on comment/uncomment, need to check if *all* lines are commented
|
||||
_ otherwise should be comment (never uncomment unless all selected)
|
||||
|
||||
cleaning
|
||||
X NullPointerException inside setup() comes up weird
|
||||
X because NullPointerException is a RuntimeException
|
||||
|
||||
Reference in New Issue
Block a user