Skip to content

Commit 96e40fa

Browse files
committed
fixed an issue where the previous sketch would continue to show logs despite a new one having started
1 parent fbd1cf1 commit 96e40fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

client/src/setupConsole.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ export default function setupConsole(context: ExtensionContext) {
4040
}
4141
);
4242
proc.stdout.on("data", (data) => {
43+
if(proc != sketchProcesses[0]) {
44+
// If this is not the most recent process, ignore its output
45+
return;
46+
}
4347
provider.webview?.webview.postMessage({ type: 'stdout', value: data?.toString() });
4448
});
4549
proc.stderr.on("data", (data) => {
50+
if (proc != sketchProcesses[0]) {
51+
// If this is not the most recent process, ignore its output
52+
return;
53+
}
4654
provider.webview?.webview.postMessage({ type: 'stderr', value: data?.toString() });
4755
// TODO: Handle and highlight errors in the editor
4856
});
@@ -53,7 +61,7 @@ export default function setupConsole(context: ExtensionContext) {
5361
});
5462
provider.webview?.show?.(true);
5563
provider.webview?.webview.postMessage({ type: 'clear'});
56-
sketchProcesses.push(proc);
64+
sketchProcesses.unshift(proc);
5765
commands.executeCommand('setContext', 'processing.sketch.running', true);
5866
});
5967

0 commit comments

Comments
 (0)