Skip to content

Commit e3c29bd

Browse files
committed
Fix linePosition zero based indexing
Even though the intention was to have the line and the linePosition to be 1-indexed as these numbers are for the user, the linePosition itself was 0-indexed.
1 parent 50b5619 commit e3c29bd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/kotlin/Error.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class JSONParseException(message: String, private val position: JSONPos
1717
return """
1818
error: $lineNumber:$linePosition $message
1919
$lineNumber | $line
20-
${" ".repeat(lineNumber.length)} | ${" ".repeat(linePosition)}${"^".repeat(length)}
20+
${" ".repeat(lineNumber.length)} | ${" ".repeat(linePosition - 1)}${"^".repeat(length)}
2121
""".trimIndent()
2222
}
2323
}

src/main/kotlin/lexer/StringJSONLexer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class StringJSONLexer(private val content: CharSequence) : JSONLexer {
229229
}
230230

231231
override fun linePosition(): Int {
232-
return position - startLine
232+
return position - startLine + 1
233233
}
234234

235235
override fun getLength(): Int {

0 commit comments

Comments
 (0)