}
private void updateCursorPosition(int character) {
- //see Java Language Specification : http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.4
- if (character == LF || character == CR) {
- if ((lastChar != LF && lastChar != CR) || lastChar == character || lastChar == LF) {
- cursor.line++;
- }
+ // see Java Language Specification : http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.4
+ if (character == LF || (character == CR && peek() != LF)) {
+ cursor.line++;
cursor.column = 0;
} else if (character == '\t') {
cursor.column += tabWidth;
assertThat(reader.getLinePosition(), is(3));
assertThat((char) reader.pop(), is('s'));
reader.pop(); // \r
- assertThat(reader.getColumnPosition(), is(0));
- assertThat(reader.getLinePosition(), is(4));
+ assertThat(reader.getColumnPosition(), is(2));
+ assertThat(reader.getLinePosition(), is(3));
reader.pop(); // \n
assertThat(reader.getColumnPosition(), is(0));
assertThat(reader.getLinePosition(), is(4));