diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index d1315540c..13d13af21 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -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); diff --git a/todo.txt b/todo.txt index ef51e4f2e..4cef25af2 100644 --- a/todo.txt +++ b/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