File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,8 @@ export function location(file) {
65
65
) {
66
66
const offset =
67
67
( point . line > 1 ? indices [ point . line - 2 ] : 0 ) + point . column - 1
68
- // The given `column` could not exist.
69
- if ( offset > value . length ) return
70
- return offset
68
+ // The given `column` could not exist on this line.
69
+ if ( offset < indices [ point . line - 1 ] ) return offset
71
70
}
72
71
}
73
72
}
Original file line number Diff line number Diff line change @@ -61,12 +61,19 @@ test('toOffset(point)', async function (t) {
61
61
await t . test (
62
62
'should return `undefined` for out of bounds input (#1)' ,
63
63
async function ( ) {
64
- assert . equal ( place . toOffset ( { line : 3 , column : 5 } ) , undefined )
64
+ assert . equal ( place . toOffset ( { line : 2 , column : 5 } ) , undefined )
65
65
}
66
66
)
67
67
68
68
await t . test (
69
69
'should return `undefined` for out of bounds input (#2)' ,
70
+ async function ( ) {
71
+ assert . equal ( place . toOffset ( { line : 3 , column : 5 } ) , undefined )
72
+ }
73
+ )
74
+
75
+ await t . test (
76
+ 'should return `undefined` for out of bounds input (#3)' ,
70
77
async function ( ) {
71
78
assert . equal ( place . toOffset ( { line : 4 , column : 1 } ) , undefined )
72
79
}
You can’t perform that action at this time.
0 commit comments