Skip to content

Commit

Permalink
Fix bobbylight#27: Enter while in MLC in C-like languages doesn't han…
Browse files Browse the repository at this point in the history
…dle trailing whitespace correctly
  • Loading branch information
bobbylight committed Oct 31, 2013
1 parent 48c65fb commit 523ff70
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/org/fife/ui/rsyntaxtextarea/AbstractJFlexCTokenMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ private void insertBreakInMLC(ActionEvent e, RSyntaxTextArea textArea,
Matcher m = null;
int start = -1;
int end = -1;
String text = null;
try {
start = textArea.getLineStartOffset(line);
end = textArea.getLineEndOffset(line);
String text = textArea.getText(start, end-start);
text = textArea.getText(start, end-start);
m = p.matcher(text);
} catch (BadLocationException ble) { // Never happens
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
Expand All @@ -201,6 +202,22 @@ private void insertBreakInMLC(ActionEvent e, RSyntaxTextArea textArea,
}
textArea.setCaretPosition(end-1);
}
else {
// Ensure caret is at the "end" of any whitespace
// immediately after the '*', but before any possible
// non-whitespace chars.
boolean moved = false;
System.out.println("Original dot==" + dot + " (end==" + end + ")");
while (dot<end-1 &&
Character.isWhitespace(text.charAt(dot-start))) {
moved = true;
dot++;
}
if (moved) {
System.out.println("New dot==" + dot);
textArea.setCaretPosition(dot);
}
}

boolean firstMlcLine = mlcMarker.charAt(0)=='/';
boolean nested = appearsNested(textArea, line,
Expand Down

0 comments on commit 523ff70

Please sign in to comment.