Skip to content

Commit ac42f96

Browse files
committed
Breakpoints don't 'jump' after hitting Enter on blank line
1 parent e8056a9 commit ac42f96

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

java/src/processing/mode/java/debug/LineID.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ public synchronized void startTracking(Document doc) {
147147
return; // line doesn't exist
148148
}
149149
String lineText = doc.getText(line.getStartOffset(), line.getEndOffset() - line.getStartOffset());
150-
// set tracking position at (=before) first non-white space character on line
150+
// set tracking position at (=before) first non-white space character on line,
151+
// or, if the line consists of entirely white spaces, just before the newline
152+
// character
151153
pos = doc.createPosition(line.getStartOffset() + nonWhiteSpaceOffset(lineText));
152154
this.doc = doc;
153155
doc.addDocumentListener(this);
@@ -222,7 +224,14 @@ protected static int nonWhiteSpaceOffset(String str) {
222224
return i;
223225
}
224226
}
225-
return str.length();
227+
228+
/* If we've reached here, that implies the line consists of purely white
229+
* space. So return at a position just after the whitespace (i.e.,
230+
* just before the newline).
231+
*
232+
* The " - 1" part resolves issue #3552
233+
*/
234+
return str.length() - 1;
226235
}
227236

228237
/**

0 commit comments

Comments
 (0)