Skip to content

ParsingException doesn't allow pointing to the last character #625

Description

@mega12345mega

In ParsingException, the int column variable is 1-indexed. However, it checks if column < context.length() rather than <=, which means pointing to the last character in the context is not possible:

message.append(System.lineSeparator()).append(this.context);
if (this.column >= 0 && this.column < this.context.length()) {
message.append(System.lineSeparator());
if (this.column > 0) {
final char[] spaces = new char[this.column - 1];
Arrays.fill(spaces, ' ');
message.append(spaces);
}
message.append(POSITION_MARKER);
}

It is also not clear to me why it allows column to equal 0 (and renders it as if column equals 1), but this isn't as big of a concern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions