File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,12 @@ export function EditorComponent(props: EditorProps) {
4343 const theme = useChangeTheme ( ) ;
4444 const { files, writeFile, diagnostics } = useEmbedContext ( ) ;
4545 const fileDiagnostics = useMemo (
46- ( ) => diagnostics [ props . filename ] ?? [ ] ,
46+ ( ) =>
47+ Object . values ( diagnostics )
48+ . flat ( )
49+ . filter ( ( diag ) =>
50+ diag . frames . some ( ( f ) => f . filename === props . filename )
51+ ) ,
4752 [ diagnostics , props . filename ]
4853 ) ;
4954
Original file line number Diff line number Diff line change @@ -100,9 +100,7 @@ export function ExecFile(props: ExecProps) {
100100 // TODO: 1つのファイル名しか受け付けないところに無理やりコンマ区切りで全部のファイル名を突っ込んでいる
101101 const filenameKey = props . filenames . join ( "," ) ;
102102 clearExecResult ( filenameKey ) ;
103- for ( const fname of props . filenames ) {
104- clearDiagnostics ( fname ) ;
105- }
103+ clearDiagnostics ( filenameKey ) ;
106104 setContents ( "" ) ;
107105 let isFirstOutput = true ;
108106 await runFiles (
@@ -130,13 +128,7 @@ export function ExecFile(props: ExecProps) {
130128 setContents ( ( prev ) => prev + output . message + "\n" ) ;
131129 } ,
132130 ( diagnostic ) => {
133- // diagnosticを関連する全ファイルに登録する
134- const relatedFiles = new Set (
135- diagnostic . frames . map ( ( f ) => f . filename )
136- ) ;
137- for ( const fname of relatedFiles ) {
138- addDiagnostic ( fname , diagnostic ) ;
139- }
131+ addDiagnostic ( filenameKey , diagnostic ) ;
140132 }
141133 ) ;
142134 setExecutionState ( "idle" ) ;
Original file line number Diff line number Diff line change @@ -349,7 +349,6 @@ export function findSyntaxErrorLine(code: string): {
349349 for ( let i = 1 ; i <= rawLines . length ; i ++ ) {
350350 const slice = rawLines . slice ( 0 , i ) . join ( "\n" ) ;
351351 try {
352- // eslint-disable-next-line @typescript-eslint/no-implied-eval
353352 ( 0 , eval ) ( `() => {\n${ slice } \n}` ) ;
354353 } catch ( e ) {
355354 if ( e instanceof SyntaxError ) {
Original file line number Diff line number Diff line change @@ -228,13 +228,14 @@ export function useTypeScript(jsEval: RuntimeContext): RuntimeContext {
228228 tsEnv . deleteFile ( filename ) ;
229229 }
230230
231- console . log ( emitOutput ) ;
232- await jsEval . runFiles (
233- [ emitOutput . outputFiles [ 0 ] . name ] ,
234- { ...files , ...emittedFiles } ,
235- onOutput ,
236- onDiagnostic
237- ) ;
231+ if ( emitOutput . outputFiles . length > 0 ) {
232+ await jsEval . runFiles (
233+ [ emitOutput . outputFiles [ 0 ] . name ] ,
234+ { ...files , ...emittedFiles } ,
235+ onOutput ,
236+ onDiagnostic
237+ ) ;
238+ }
238239 } catch ( error ) {
239240 onErrorRef . current ?.( error ) ;
240241 onOutput ( {
You can’t perform that action at this time.
0 commit comments