File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
export function fromPoint ( point ) {
17
17
return {
18
- character : point . column - 1 ,
19
- line : point . line - 1
18
+ character : point . column ? point . column - 1 : 0 ,
19
+ line : point . line ? point . line - 1 : 0
20
20
}
21
21
}
22
22
Original file line number Diff line number Diff line change @@ -17,6 +17,19 @@ test('fromPoint', async () => {
17
17
{ line : 42 , character : 99 } ,
18
18
'should convert unist points to LSP positions'
19
19
)
20
+
21
+ assert . deepEqual (
22
+ fromPoint ( { line : 0 , column : 0 } ) ,
23
+ { line : 0 , character : 0 } ,
24
+ 'should convert unist points with zero values'
25
+ )
26
+
27
+ assert . deepEqual (
28
+ // @ts -expect-error We test invalid user input here.
29
+ fromPoint ( { line : null , column : null } ) ,
30
+ { line : 0 , character : 0 } ,
31
+ 'should convert unist points with null values'
32
+ )
20
33
} )
21
34
22
35
test ( 'toPoint' , async ( ) => {
You can’t perform that action at this time.
0 commit comments