@@ -15,6 +15,8 @@ describe("isMarkdownFileLinkLabel", () => {
1515 [ "validates the input" , "/repo/src/example.ts:12" , false ] ,
1616 [ "example.ts:12" , "/repo/src/example.ts:12" , true ] ,
1717 [ "example.ts:99" , "/repo/src/example.ts:12" , false ] ,
18+ [ "example.ts:12-20" , "/repo/src/example.ts:12-20" , true ] ,
19+ [ "example.ts:12-20" , "/repo/src/example.ts:12" , false ] ,
1820 ] ) ( "classifies %s for %s" , ( label , href , expected ) => {
1921 expect ( isMarkdownFileLinkLabel ( label , href ) ) . toBe ( expected ) ;
2022 } ) ;
@@ -25,6 +27,8 @@ describe("inlineCodeFilePathCandidate", () => {
2527 it . each ( [
2628 [ "src\\main.ts" , "src/main.ts" ] ,
2729 [ "allocator.cc:217" , "allocator.cc:217" ] ,
30+ [ "src/http.ts:42-64" , "src/http.ts:42-64" ] ,
31+ [ "http.ts:42-64" , "http.ts:42-64" ] ,
2832 [ "origin/main" , null ] ,
2933 [ "z-ai/glm-5.3" , null ] ,
3034 [ "share/man/ls.1" , "share/man/ls.1" ] ,
@@ -101,6 +105,19 @@ describe("parseMarkdownFileLink", () => {
101105 expect ( parseMarkdownFileLink ( "/srv/app/Makefile" ) ) . toEqual ( { path : "/srv/app/Makefile" } ) ;
102106 } ) ;
103107
108+ it ( "reads line ranges and opens them at their first line" , ( ) => {
109+ expect ( parseMarkdownFileLink ( "/repo/src/http.ts:42-64" ) ) . toEqual ( {
110+ path : "/repo/src/http.ts" ,
111+ line : 42 ,
112+ endLine : 64 ,
113+ } ) ;
114+ expect ( parseMarkdownFileLink ( "/repo/src/http.ts#L42-L64" ) ) . toEqual ( {
115+ path : "/repo/src/http.ts" ,
116+ line : 42 ,
117+ endLine : 64 ,
118+ } ) ;
119+ } ) ;
120+
104121 it ( "reads positions from suffixes and line anchors" , ( ) => {
105122 expect ( parseMarkdownFileLink ( "/Users/julius/project/src/main.ts#L42C7" ) ) . toEqual ( {
106123 path : "/Users/julius/project/src/main.ts" ,
0 commit comments