@@ -8,26 +8,24 @@ const lastLineTypeMessage = (raw: string) => {
88} ;
99
1010export const skulptAdapter : AdapterFn = ( raw , code ) => {
11- // Skulpt traces vary - we accept both "Traceback..." and editor summaries
11+ if ( ! / s k u l p t / i. test ( raw ) && ! / T r a c e b a c k / i. test ( raw ) ) {
12+ // still try; skulpt often includes "on line X of", etc.
13+ }
1214 const { type, message, tail, lines } = lastLineTypeMessage ( raw ) ;
1315 let file : string | undefined , line : number | undefined , col : number | undefined ;
1416
15- // standard Python-style frames (Skulpt often emits these)
1617 for ( const L of lines ) {
1718 const mm = L . match ( / F i l e \s + " ( [ ^ " ] + ) " , \s + l i n e \s + ( \d + ) / i) ;
1819 if ( mm ) {
1920 file = mm [ 1 ] ;
2021 line = parseInt ( mm [ 2 ] , 10 ) ;
2122 }
2223 }
23-
2424 if ( ! line ) {
25- const m1 = raw . match ( / o n \s + l i n e \s + ( \d + ) \s + o f \s + ( [ ^ \s : ] + ) (?: : \s * ( [ \s \S ] * ) ) ? / i) ;
26- if ( m1 ) {
27- line = parseInt ( m1 [ 1 ] , 10 ) ;
28- file = m1 [ 2 ] ;
29- const afterColon = ( m1 [ 3 ] || "" ) . split ( / \r ? \n / ) ;
30- const snippet = afterColon . find ( s => s . trim ( ) && ! / ^ \s * \^ + \s * $ / . test ( s ) ) ;
25+ const loc = tail . match ( / \b (?: o n | a t ) \s + l i n e \s + ( \d + ) \s + (?: o f | i n ) \s + ( [ ^ \s : ] + ) \b / i) ;
26+ if ( loc ) {
27+ line = parseInt ( loc [ 1 ] , 10 ) ;
28+ file = loc [ 2 ] ;
3129 }
3230 }
3331
@@ -48,20 +46,10 @@ export const skulptAdapter: AdapterFn = (raw, code) => {
4846 } ;
4947
5048 if ( code && line ) {
51- const codeLines = code . split ( / \r ? \n / ) ;
52- t . codeLine = codeLines [ line - 1 ] ?. trim ( ) ;
53- t . codeBefore = codeLines . slice ( Math . max ( 0 , line - 3 ) , line - 1 ) ;
54- t . codeAfter = codeLines . slice ( line , line + 2 ) ;
55- } else {
56- const m1 = raw . match ( / o n \s + l i n e \s + \d + \s + o f \s + [ ^ \s : ] + : (?: \s * ( [ \s \S ] * ) ) ? / i) ;
57- if ( m1 && m1 [ 1 ] ) {
58- const snippet = m1 [ 1 ] . split ( / \r ? \n / ) . find ( s => s . trim ( ) && ! / ^ \s * \^ + \s * $ / . test ( s ) ) ;
59- if ( snippet ) t . codeLine = snippet . trim ( ) ;
60- }
49+ const lines = code . split ( / \r ? \n / ) ;
50+ t . codeLine = lines [ line - 1 ] ?. trim ( ) ;
51+ t . codeBefore = lines . slice ( Math . max ( 0 , line - 3 ) , line - 1 ) ;
52+ t . codeAfter = lines . slice ( line , line + 2 ) ;
6153 }
62-
63- const looksLikeError = / E r r o r \b / i. test ( raw ) || / T r a c e b a c k / i. test ( raw ) || / s k u l p t / i. test ( raw ) ;
64- if ( ! looksLikeError ) return null ;
65-
6654 return t ;
6755} ;
0 commit comments