Fix parser error pointing to wrong line when last line has no trailing newline (#1041)
When parsing a key without '=' at EOF (e.g., "a = 1\nb = 2\nc"), the error highlight was an empty slice, causing subsliceOffset to return 0 and the error to point at line 1 instead of line 3. Pass the consumed key bytes as the highlight instead of the empty remainder. Fixes #1032 https://claude.ai/code/session_01UWv8pyc8P1ktAPfHpveixj Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -259,6 +259,12 @@ func TestDecodeError_Position(t *testing.T) {
|
||||
expectedRow: 3,
|
||||
minCol: 5,
|
||||
},
|
||||
{
|
||||
name: "missing equals on last line without trailing newline",
|
||||
doc: "a = 1\nb = 2\nc",
|
||||
expectedRow: 3,
|
||||
minCol: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, e := range examples {
|
||||
|
||||
Reference in New Issue
Block a user