Skip to content

Commit 39eef6c

Browse files
committed
fix
1 parent 085c6ae commit 39eef6c

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

app/terminal/editor.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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

app/terminal/exec.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff 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");

packages/jsEval/src/stackTrace.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

packages/runtime/src/typescript/runtime.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff 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({

0 commit comments

Comments
 (0)