@@ -2,15 +2,18 @@ import { Diagnostic } from "vscode-languageserver-types";
2
2
import { compressToEncodedURIComponent , d } from "../utils" ;
3
3
import { KNOWN_ERROR_NUMBERS } from "./consts/knownErrorNumbers" ;
4
4
import { miniLine } from "./miniLine" ;
5
+ import { Uri } from 'vscode' ;
6
+ import { PRETTY_TS_ERRORS_SCHEME } from '../provider/textDocumentProvider' ;
5
7
6
- export const title = ( diagnostic : Diagnostic ) => d /*html*/ `
8
+ export const title = ( diagnostic : Diagnostic , uri : Uri ) => d /*html*/ `
7
9
<span style="color:#f96363;">⚠ Error </span>${
8
10
typeof diagnostic . code === "number"
9
11
? d /*html*/ `
10
12
<span style="color:#5f5f5f;">
11
- (TS${ diagnostic . code } )
12
- ${ errorCodeExplanationLink ( diagnostic . code ) } |
13
+ (TS${ diagnostic . code } )
14
+ ${ errorCodeExplanationLink ( diagnostic . code ) } |
13
15
${ errorMessageTranslationLink ( diagnostic . message ) }
16
+ ${ errorMessageInANewFile ( diagnostic , uri ) }
14
17
</span>
15
18
`
16
19
: ""
@@ -37,3 +40,15 @@ export const errorMessageTranslationLink = (message: Diagnostic["message"]) => {
37
40
</span>
38
41
</a>` ;
39
42
} ;
43
+
44
+ export const errorMessageInANewFile = ( diagnostic : Diagnostic , uri : Uri ) => {
45
+ const range = `${ diagnostic . range . start . line } :${ diagnostic . range . start . character } -${ diagnostic . range . end . line } :${ diagnostic . range . end . character } ` ;
46
+ const virtualFileUri = Uri . parse ( `${ PRETTY_TS_ERRORS_SCHEME } :${ encodeURIComponent ( uri . fsPath + '.md' ) } ?range=${ encodeURIComponent ( range ) } ` ) ;
47
+ const args = [ virtualFileUri ] ;
48
+ const href = Uri . parse ( `command:markdown.showPreview?${ encodeURIComponent ( JSON . stringify ( args ) ) } ` ) ;
49
+ return d /*html*/ `
50
+ <a title="Open in new tab" href="${ href } ">
51
+ <span class="codicon codicon-new-file">
52
+ </span>
53
+ </a>` ;
54
+ } ;
0 commit comments