File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
apps/vscode-extension/src
packages/vscode-formatter/src/components Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 11import { has } from "@pretty-ts-errors/utils" ;
22import { formatDiagnostic } from "@pretty-ts-errors/vscode-formatter" ;
33import {
4+ commands ,
5+ env ,
46 ExtensionContext ,
57 languages ,
68 MarkdownString ,
@@ -18,6 +20,16 @@ export function activate(context: ExtensionContext) {
1820 const registeredLanguages = new Set < string > ( ) ;
1921 const converter = createConverter ( ) ;
2022
23+ // register the copy command
24+ context . subscriptions . push (
25+ commands . registerCommand (
26+ "prettyTsErrors.copyError" ,
27+ async ( errorMessage : string ) => {
28+ await env . clipboard . writeText ( errorMessage ) ;
29+ }
30+ )
31+ ) ;
32+
2133 registerSelectedTextHoverProvider ( context ) ;
2234
2335 context . subscriptions . push (
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ export const title = (diagnostic: Diagnostic) => d/*html*/ `
1111 <span style="color:#5f5f5f;">
1212 (TS${ diagnostic . code } )
1313 ${ errorCodeExplanationLink ( diagnostic . code ) } |
14- ${ errorMessageTranslationLink ( diagnostic . message ) }
14+ ${ errorMessageTranslationLink ( diagnostic . message ) } |
15+ ${ copyErrorLink ( diagnostic . message ) }
1516 </span>
1617 `
1718 : ""
@@ -38,3 +39,12 @@ const errorMessageTranslationLink = (message: Diagnostic["message"]) => {
3839 </span>
3940 </a>` ;
4041} ;
42+
43+ const copyErrorLink = ( message : Diagnostic [ "message" ] ) => {
44+ const args = encodeURIComponent ( JSON . stringify ( message ) ) ;
45+ return d /*html*/ `
46+ <a title="Copy error to clipboard" href="command:prettyTsErrors.copyError?${ args } ">
47+ <span class="codicon codicon-copy">
48+ </span>
49+ </a>` ;
50+ } ;
You can’t perform that action at this time.
0 commit comments