@@ -27,6 +27,7 @@ const WIN_PATH = new RegExp(`(${WIN_ABSOLUTE_PATH.source}|${WIN_RELATIVE_PATH.so
27
27
const POSIX_PATH = / ( (?: \~ | \. ) ? (?: \/ [ \w \. - ] * ) + ) / ;
28
28
const LINE_COLUMN = / (?: \: ( [ \d ] + ) ) ? (?: \: ( [ \d ] + ) ) ? / ;
29
29
const PATH_LINK_REGEX = new RegExp ( `${ platform . isWindows ? WIN_PATH . source : POSIX_PATH . source } ${ LINE_COLUMN . source } ` , 'g' ) ;
30
+ const LINE_COLUMN_REGEX = / : ( [ \d ] + ) (?: : ( [ \d ] + ) ) ? $ / ;
30
31
31
32
const MAX_LENGTH = 2000 ;
32
33
@@ -104,7 +105,17 @@ export class LinkDetector {
104
105
private createWebLink ( url : string ) : Node {
105
106
const link = this . createLink ( url ) ;
106
107
107
- const uri = URI . parse ( url ) ;
108
+ let uri = URI . parse ( url ) ;
109
+ // if the URI ends with something like `foo.js:12:3`, parse
110
+ // that into a fragment to reveal that location (#150702)
111
+ const lineCol = LINE_COLUMN_REGEX . exec ( uri . path ) ;
112
+ if ( lineCol ) {
113
+ uri = uri . with ( {
114
+ path : uri . path . slice ( 0 , lineCol . index ) ,
115
+ fragment : `L${ lineCol [ 0 ] . slice ( 1 ) } `
116
+ } ) ;
117
+ }
118
+
108
119
this . decorateLink ( link , uri , async ( ) => {
109
120
110
121
if ( uri . scheme === Schemas . file ) {
@@ -119,7 +130,13 @@ export class LinkDetector {
119
130
return ;
120
131
}
121
132
122
- await this . editorService . openEditor ( { resource : fileUri , options : { pinned : true } } ) ;
133
+ await this . editorService . openEditor ( {
134
+ resource : fileUri ,
135
+ options : {
136
+ pinned : true ,
137
+ selection : lineCol ? { startLineNumber : + lineCol [ 1 ] , startColumn : + lineCol [ 2 ] } : undefined ,
138
+ } ,
139
+ } ) ;
123
140
return ;
124
141
}
125
142
0 commit comments