@@ -11,7 +11,12 @@ const CODEBLOCK = '```';
11
11
// bad. It doesn't properly handle escaping back ticks, so we instead insert zero width spaces
12
12
// so that users cannot escape our code block.
13
13
function escapeCode ( code : string ) {
14
- return code . replace ( / ` ` ` / g, '`\u200B`\u200B`' ) ;
14
+ return code . replace ( / ` (? = ` ) / g, '`\u200B' ) ;
15
+ }
16
+
17
+ // Remove `@noErrorTruncation` from the source; this can cause lag/crashes for large errors
18
+ function redactNoErrorTruncation ( code : string ) {
19
+ return code . replace ( / @ n o E r r o r T r u n c a t i o n / g, '' ) ;
15
20
}
16
21
17
22
export class TwoslashModule extends Module {
@@ -40,7 +45,7 @@ export class TwoslashModule extends Module {
40
45
`:warning: could not find any TypeScript codeblocks in the past 10 messages` ,
41
46
) ;
42
47
43
- const ret = twoslasher ( code , 'ts' , {
48
+ const ret = twoslasher ( redactNoErrorTruncation ( code ) , 'ts' , {
44
49
defaultOptions : { noErrorValidation : true } ,
45
50
} ) ;
46
51
@@ -85,7 +90,7 @@ export class TwoslashModule extends Module {
85
90
}
86
91
87
92
private async twoslashBlock ( msg : Message , code : string ) {
88
- const ret = twoslasher ( code , 'ts' , {
93
+ const ret = twoslasher ( redactNoErrorTruncation ( code ) , 'ts' , {
89
94
defaultOptions : {
90
95
noErrorValidation : true ,
91
96
noStaticSemanticInfo : false ,
0 commit comments