Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Dec 5, 2025

The BufferReader.lineNumber property had a bug where it used fullBuffer[offset: 1] to check for newline characters. Since offset: is relative to the start of the buffer, this always checked the same byte (the second byte) regardless of the current cursor position p.

This caused incorrect line counting:

  • If the second byte happened to be \n, it would increment the count on every iteration, overcounting lines
  • If the second byte was not \n, standalone newlines (without preceding \r) would never be counted, undercounting lines.

The `BufferReader.lineNumber` property had a bug where it used `fullBuffer[offset: 1]` to check for newline characters. Since `offset:` is relative to the start of the buffer, this always checked the same byte (the second byte) regardless of the current cursor position `p`.

This caused incorrect line counting:
- If the second byte happened to be `\n`, it would increment the count on every iteration, overcounting lines
- If the second byte was not `\n`, standalone newlines (without preceding `\r`) would never be counted, undercounting lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant