Skip to content

Commit d1eca9c

Browse files
pankgeorgclaude
andcommitted
fix(terminal): Ctrl-C while queued no longer interrupts the whole notebook
Pluto only offers a notebook-wide interrupt; firing it while the terminal snippet was still waiting in waitForIdle killed unrelated editor executions. The interrupt is now sent only while the snippet is actually running — a queued snippet is cancelled by the generation bump alone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4d419e9 commit d1eca9c

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/plutoTerminal.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export class PlutoTerminalProvider implements vscode.Pseudoterminal {
2525
private inputBuffer = "";
2626
private cursorPosition = 0; // Position in the input buffer
2727
private isExecuting = false;
28+
// True only while our snippet is actually running in Pluto (not while
29+
// queued behind other cells in waitForIdle)
30+
private isRunningInPluto = false;
2831
// Bumped on Ctrl+C and on each new execution; stale executions compare
2932
// against it before touching shared terminal state
3033
private executionGeneration = 0;
@@ -275,11 +278,17 @@ using InteractiveUtils
275278
if (this.isExecuting) {
276279
this.write("\r\n\x1b[31m^C\x1b[0m\r\n");
277280
// Invalidate the in-flight execution so its completion doesn't
278-
// clobber state or print a stray prompt, and ask Pluto to
279-
// interrupt the Julia-side computation
281+
// clobber state or print a stray prompt
280282
this.executionGeneration++;
281283
this.isExecuting = false;
282-
this.interruptExecution();
284+
// Pluto only offers a notebook-wide interrupt, which would kill
285+
// unrelated editor executions — send it only when our snippet is
286+
// actually running; a snippet still queued behind other cells is
287+
// cancelled by the generation bump alone
288+
if (this.isRunningInPluto) {
289+
this.interruptExecution();
290+
}
291+
this.isRunningInPluto = false;
283292
this.writePrompt();
284293
} else {
285294
this.inputBuffer = "";
@@ -550,7 +559,9 @@ using InteractiveUtils
550559
}
551560

552561
// Execute code ephemerally using PlutoManager
562+
this.isRunningInPluto = true;
553563
const result = await this.plutoManager.executeCodeEphemeral(worker, code);
564+
this.isRunningInPluto = false;
554565

555566
// Render output — unless the user cancelled with Ctrl+C meanwhile
556567
if (generation === this.executionGeneration) {
@@ -570,6 +581,7 @@ using InteractiveUtils
570581
// a stale completion must not reset state or print another prompt
571582
if (generation === this.executionGeneration) {
572583
this.isExecuting = false;
584+
this.isRunningInPluto = false;
573585
this.write("\r\n");
574586
this.writePrompt();
575587
}

0 commit comments

Comments
 (0)